/* ============================================================
   CONSULTORA MO – Sistema de Tickets
   Hoja de estilos principal
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-50:   #E6F1FB; --blue-100: #B5D4F4; --blue-600: #185FA5; --blue-800: #0C447C;
  --teal-50:   #E1F5EE; --teal-600: #0F6E56; --teal-800: #085041;
  --amber-50:  #FAEEDA; --amber-100:#FAC775;  --amber-600:#854F0B;
  --green-50:  #EAF3DE; --green-100:#C0DD97;  --green-600:#3B6D11;
  --red-50:    #FCEBEB; --red-100:  #F7C1C1;  --red-600:  #A32D2D;
  --purple-50: #EEEDFE; --purple-600:#534AB7;
  --gray-50:   #F1EFE8; --gray-100: #D3D1C7;  --gray-600: #5F5E5A;

  --bg:        #F5F4F0;
  --surface:   #FFFFFF;
  --border:    rgba(0,0,0,.12);
  --border-md: rgba(0,0,0,.20);
  --text-1:    #1A1A18;
  --text-2:    #5F5E5A;
  --text-3:    #9B9A94;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Layout ─────────────────────────────────────────────── */
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text-1); font-size: 14px; line-height: 1.5; }
#app  { display: flex; min-height: 100vh; }
#sidebar { width: 220px; min-width: 220px; background: var(--surface); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 50; }
#main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar-logo { padding: 20px 16px 16px; border-bottom: 0.5px solid var(--border); }
.sidebar-logo .brand { font-weight: 600; font-size: 14px; color: var(--blue-600); }
.sidebar-logo .sub   { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.nav-section { padding: 14px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 16px; cursor: pointer; font-size: 13px; color: var(--text-2); border-right: 3px solid transparent; transition: all .15s; }
.nav-item:hover { background: var(--bg); color: var(--text-1); }
.nav-item.active { background: var(--blue-50); color: var(--blue-600); border-right-color: var(--blue-600); font-weight: 500; }
.nav-item i { font-size: 16px; }
.nav-bottom { margin-top: auto; padding: 12px 16px; border-top: 0.5px solid var(--border); font-size: 12px; color: var(--text-3); }
.nav-bottom strong { display: block; color: var(--text-2); }

/* ── Topbar ──────────────────────────────────────────────── */
#topbar { background: var(--surface); border-bottom: 0.5px solid var(--border); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40; }
#topbar h1 { font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Content ─────────────────────────────────────────────── */
#content { padding: 28px; flex: 1; }

/* ── Metrics ─────────────────────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.metric-card .m-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.metric-card .m-value { font-size: 24px; font-weight: 600; }
.metric-card .m-sub   { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.metric-accent { border-left: 3px solid var(--blue-600); }

/* ── Table ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 0.5px solid var(--border); }
.card-header h2 { font-size: 14px; font-weight: 600; }
.card-body { padding: 16px 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 10px 14px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--bg); border-bottom: 0.5px solid var(--border); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--blue-50); }
tbody td { padding: 12px 14px; border-bottom: 0.5px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; gap: 4px; }
.badge-crit     { background: var(--red-50);    color: var(--red-600); }
.badge-alta     { background: var(--amber-50);  color: var(--amber-600); }
.badge-normal   { background: var(--blue-50);   color: var(--blue-600); }
.badge-abierto  { background: var(--blue-50);   color: var(--blue-600); }
.badge-progreso { background: var(--amber-50);  color: var(--amber-600); }
.badge-resuelto { background: var(--green-50);  color: var(--green-600); }
.badge-cerrado  { background: var(--gray-50);   color: var(--gray-600); }
.badge-sap      { background: var(--amber-50);  color: var(--amber-600); }
.badge-proyecto { background: var(--teal-50);   color: var(--teal-600); }
.badge-ok       { background: var(--green-50);  color: var(--green-600); }
.badge-pend     { background: var(--amber-50);  color: var(--amber-600); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-md); border: 0.5px solid var(--border-md); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-1); transition: all .15s; }
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.btn-primary:hover { background: var(--blue-800); }
.btn-danger  { background: var(--red-50); color: var(--red-600); border-color: var(--red-100); }
.btn i { font-size: 16px; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.form-group input,
.form-group select,
.form-group textarea {
  font-size: 13px; color: var(--text-1); background: var(--surface);
  border: 0.5px solid var(--border-md); border-radius: var(--radius-md);
  padding: 9px 11px; outline: none; font-family: inherit; width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-50); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Progress bar ────────────────────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; gap: 4px; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-2); }
.progress-track { height: 8px; background: var(--gray-100); border-radius: 99px; overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 99px; transition: width .4s; }
.fill-ok   { background: var(--teal-600); }
.fill-warn { background: var(--amber-100); }
.fill-danger { background: var(--red-600); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius-lg); border: 0.5px solid var(--border); width: 580px; max-width: 96vw; max-height: 90vh; overflow-y: auto; transform: translateY(10px); transition: transform .2s; }
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 0.5px solid var(--border); }
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-body   { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 14px 20px; border-top: 0.5px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Login ───────────────────────────────────────────────── */
#login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border-radius: var(--radius-lg); border: 0.5px solid var(--border); padding: 40px; width: 360px; box-shadow: var(--shadow-sm); }
.login-card .logo { text-align: center; margin-bottom: 28px; }
.login-card .logo .brand { font-size: 20px; font-weight: 700; color: var(--blue-600); }
.login-card .logo .sub   { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.login-card .form-group { margin-bottom: 14px; }
#login-error { color: var(--red-600); font-size: 12px; text-align: center; min-height: 16px; }

/* ── Search & filter bar ────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; align-items: center; }
.search-input { display: flex; align-items: center; gap: 6px; border: 0.5px solid var(--border-md); border-radius: var(--radius-md); padding: 7px 11px; background: var(--surface); }
.search-input input { border: none; outline: none; font-size: 13px; background: transparent; color: var(--text-1); width: 200px; }
.search-input i { color: var(--text-3); font-size: 15px; }
.filter-select { font-size: 13px; padding: 7px 10px; border: 0.5px solid var(--border-md); border-radius: var(--radius-md); background: var(--surface); color: var(--text-1); outline: none; cursor: pointer; }

/* ── Hours log item ──────────────────────────────────────── */
.hora-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 0.5px solid var(--border); }
.hora-item:last-child { border-bottom: none; }
.hora-item .info .title { font-weight: 500; font-size: 13px; }
.hora-item .info .meta  { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.hora-item .right       { text-align: right; flex-shrink: 0; }
.hora-item .hrs         { font-size: 16px; font-weight: 600; color: var(--blue-600); }

/* ── Client avatar ───────────────────────────────────────── */
.c-avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.av-teal   { background: var(--teal-50);   color: var(--teal-600); }
.av-blue   { background: var(--blue-50);   color: var(--blue-600); }
.av-amber  { background: var(--amber-50);  color: var(--amber-600); }
.av-purple { background: var(--purple-50); color: var(--purple-600); }
.cell-client { display: flex; align-items: center; gap: 8px; }

/* ── Utility ─────────────────────────────────────────────── */
.text-muted  { color: var(--text-2); }
.text-small  { font-size: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); font-size: 13px; }
.empty-state i { font-size: 32px; display: block; margin-bottom: 10px; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text-1); color: #fff; padding: 12px 20px; border-radius: var(--radius-md); font-size: 13px; z-index: 999; opacity: 0; transform: translateY(10px); transition: all .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red-600); }
.sla-ok   { color: var(--green-600); }
.sla-warn { color: var(--amber-600); }
.sla-over { color: var(--red-600); font-weight: 600; }

/* ── Timer widget (cronómetro) ──────────────────────────── */
.timer-widget { padding: 12px 16px; border-top: 0.5px solid var(--border); }
.timer-start-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 9px; border-radius: var(--radius-md);
  background: var(--teal-50); color: var(--teal-600); border: 0.5px solid var(--teal-50);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.timer-start-btn:hover { background: var(--teal-50); filter: brightness(0.97); }
.timer-active {
  background: var(--blue-50); border-radius: var(--radius-md); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.timer-active .timer-label { font-size: 11px; color: var(--text-2); }
.timer-active .timer-target { font-size: 13px; font-weight: 600; color: var(--blue-600); }
.timer-active .timer-clock { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-active .timer-actions { display: flex; gap: 6px; margin-top: 4px; }
.timer-active .timer-actions button { flex: 1; padding: 6px; font-size: 12px; }

/* ── Base de conocimiento ────────────────────────────────── */
.kb-solucion-render img { max-width: 100%; border-radius: 8px; margin: 8px 0; display: block; }
.kb-solucion-render ul, .kb-solucion-render ol { margin-left: 20px; margin-top: 6px; margin-bottom: 6px; }
.kb-solucion-render b, .kb-solucion-render strong { font-weight: 600; }
