/* ============================================================
   Brainlabs Agente IA — Design System
   Aesthetic: Technical / Clean dark
   ============================================================ */

:root {
  --bg:          #09090b;
  --bg-card:     #151922;
  --bg-el:       #13151a;
  --bg-hover:    #232936;
  --border:      #1e2028;
  --border-lg:   #2a2d38;
  --text:        #f4f4f5;
  --muted:       #71717a;
  --dim:         #3f3f46;
  --green:       #4ade80;
  --green-dark:  #3B6D11;
  --green-dim:   rgba(74,222,128,.1);
  --amber:       #facc15;
  --amber-dark:  #BA7517;
  --amber-dim:   rgba(250,204,21,.1);
  --red:         #f87171;
  --red-dark:    #A32D2D;
  --red-dim:     rgba(248,113,113,.1);
  --blue:        #60a5fa;
  --blue-dark:   #185FA5;
  --blue-dim:    rgba(96,165,250,.1);
  --font-sans:   'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:   'IBM Plex Mono', monospace;
  --radius:      8px;
  --radius-lg:   12px;
  --sidebar-w:   220px;
  --topbar-h:    52px;
  --tr:          .18s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; }

/* ── Layout ──────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(
      180deg,
      #181d27 0%,
      #141922 100%
  );
  border-right: 1px solid #2c3442;
  box-shadow: 4px 0 20px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  transition: width var(--tr);
}
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .agent-pill__info,
.sidebar.collapsed .agent-pill__dot,
.sidebar.collapsed .nav-item span:not(.ti),
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .user-details,
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .agent-pill { justify-content: center; padding: 8px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon {
  width: 32px;
  height: 32px;

  background: rgba(96,165,250,.12);
  border: 1px solid rgba(96,165,250,.25);

  border-radius: var(--radius);

  display: flex;
  align-items: center;
  justify-content: center;

  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;

  color: var(--blue);

  flex-shrink: 0;
}
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 13px; font-weight: 600; }
.brand-sub  { font-size: 10px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

/* Agent pill */
.agent-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.agent-pill__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;

  background: rgba(96,165,250,.12);
  border: 1px solid rgba(96,165,250,.25);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 12px;
  font-weight: 600;

  color: var(--blue);

  flex-shrink: 0;
}
.agent-pill__info { flex: 1; min-width: 0; }
.agent-pill__name { display: block; font-size: 12px; font-weight: 500; }
.agent-pill__timer { font-family: var(--font-mono); font-size: 10px; color: var(--amber); }
.agent-pill__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.agent-pill__dot.online  { background: var(--green); box-shadow: 0 0 6px rgba(74,222,128,.4); animation: blink 2s ease-in-out infinite; }
.agent-pill__dot.offline { background: var(--dim); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Nav */
.sidebar-nav {
  flex: 1; padding: 10px 8px; overflow-y: auto;
  scrollbar-width: none;
}
.nav-section {
  font-size: 10px; color: var(--dim);
  padding: 10px 8px 4px; letter-spacing: .08em; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--tr); white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: rgba(96,165,250,.12); color: var(--blue); border: 1px solid rgba(96,165,250,.18);
}
.nav-item .ti { font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--border); color: var(--muted);
  font-family: var(--font-mono); font-size: 10px; padding: 1px 6px;
  border-radius: 20px; min-width: 20px; text-align: center;
}
.nav-badge.red    { background: var(--red-dim); color: var(--red); }
.nav-badge.amber  { background: var(--amber-dim); color: var(--amber); }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue-dim); border: 1px solid rgba(96,165,250,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--blue); flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--muted); }
.logout-btn { color: var(--muted); padding: 4px; transition: color var(--tr); }
.logout-btn:hover { color: var(--red); }
.logout-btn .ti { font-size: 16px; }

/* ── Topbar ───────────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.sidebar-toggle {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 6px; border-radius: var(--radius); transition: all var(--tr);
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-toggle .ti { font-size: 18px; }
.breadcrumb { font-size: 14px; font-weight: 500; color: var(--text); }
.horario-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid;
}
.horario-badge.online  { background: var(--green-dim); border-color: rgba(74,222,128,.3); color: var(--green); }
.horario-badge.offline { background: var(--bg-el); border-color: var(--border); color: var(--muted); }
.horario-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Page content ─────────────────────────────────────────── */
.page-content { flex: 1; overflow-y: auto; padding: 24px 28px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px 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: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body  { padding: 16px 18px; }

/* ── Stats ────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; cursor: default;
  transition: border-color var(--tr);
}
.stat-card:hover { border-color: var(--border-lg); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 600; font-family: var(--font-mono); line-height: 1; margin-bottom: 4px; }
.stat-sub   { font-size: 11px; color: var(--muted); }
.stat-value.green  { color: var(--green); }
.stat-value.amber  { color: var(--amber); }
.stat-value.red    { color: var(--red); }
.stat-value.blue   { color: var(--blue); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge.green  { background: var(--green-dim); color: var(--green); }
.badge.amber  { background: var(--amber-dim); color: var(--amber); }
.badge.red    { background: var(--red-dim);   color: var(--red); }
.badge.blue   { background: var(--blue-dim);  color: var(--blue); }
.badge.gray   { background: var(--bg-el); color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-el);
  color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--tr); white-space: nowrap;
}
.btn:hover  { background: var(--bg-hover); border-color: var(--border-lg); }
.btn-primary { background: var(--green); border-color: var(--green); color: #052e16; font-weight: 600; }
.btn-primary:hover { background: #6ee7a0; }
.btn-danger  { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.btn-danger:hover  { background: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn .ti { font-size: 14px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 10px 14px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
  background: var(--bg-el); border-bottom: 1px solid var(--border);
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: var(--bg-hover); }
.tbl-name { font-weight: 500; }
.tbl-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg-el); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font-sans); font-size: 13.5px;
  outline: none; transition: border-color var(--tr);
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--green); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--dim); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2371717a' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer;
}
.form-help { font-size: 11px; color: var(--muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-lg);
  border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: modal-in .2s ease;
}
@keyframes modal-in { from{opacity:0;transform:translateY(-10px) scale(.97)} to{opacity:1;transform:none} }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; transition: color var(--tr); }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Section header ───────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.section-title { font-size: 20px; font-weight: 600; }
.section-sub   { font-size: 13px; color: var(--muted); margin-top: 3px; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Operator cards ───────────────────────────────────────── */
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.op-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  transition: border-color var(--tr);
}
.op-card.online  { border-color: rgba(74,222,128,.3); }
.op-card.busy    { border-color: rgba(250,204,21,.3); }
.op-card.offline { border-color: var(--border); }
.op-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.op-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0; position: relative;
}
.op-avatar.online  { background: var(--green-dim); color: var(--green); }
.op-avatar.busy    { background: var(--amber-dim); color: var(--amber); }
.op-avatar.offline { background: var(--bg-el); color: var(--muted); }
.op-status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg-card);
}
.op-status-dot.online  { background: var(--green); }
.op-status-dot.busy    { background: var(--amber); }
.op-status-dot.offline { background: var(--dim); }
.op-name    { font-size: 14px; font-weight: 600; }
.op-alias   { font-size: 11px; color: var(--muted); }
.op-stats   { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-bottom: 10px; }
.op-stat    { background: var(--bg-el); border-radius: var(--radius); padding: 6px; text-align: center; }
.op-stat-v  { font-family: var(--font-mono); font-size: 16px; font-weight: 600; }
.op-stat-l  { font-size: 9px; color: var(--muted); margin-top: 1px; }

/* ── Progress bars ────────────────────────────────────────── */
.progress { height: 4px; background: var(--bg-el); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .6s ease; }
.progress-fill.green  { background: var(--green); }
.progress-fill.amber  { background: var(--amber); }
.progress-fill.red    { background: var(--red); }
.progress-fill.blue   { background: var(--blue); }

/* ── Two / Three col ──────────────────────────────────────── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border-lg);
  border-radius: var(--radius-lg); padding: 12px 16px;
  font-size: 13px; min-width: 240px; pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: toast-in .25s ease;
}
.toast.out { animation: toast-out .25s ease forwards; }
.toast.success { border-color: rgba(74,222,128,.3); }
.toast.error   { border-color: rgba(248,113,113,.3); }
.toast .ti { font-size: 16px; flex-shrink: 0; }
.toast.success .ti { color: var(--green); }
.toast.error   .ti { color: var(--red); }
@keyframes toast-in  { from{opacity:0;transform:translateX(16px)} to{opacity:1;transform:none} }
@keyframes toast-out { from{opacity:1} to{opacity:0;transform:translateX(16px)} }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-lg); border-radius: 5px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-lg); font-size: 13px; border: 1px solid; margin-bottom: 16px; }
.alert .ti { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert.info    { background: var(--blue-dim);  border-color: rgba(96,165,250,.3);  color: var(--blue); }
.alert.success { background: var(--green-dim); border-color: rgba(74,222,128,.3);  color: var(--green); }
.alert.warning { background: var(--amber-dim); border-color: rgba(250,204,21,.3);  color: var(--amber); }
.alert.danger  { background: var(--red-dim);   border-color: rgba(248,113,113,.3); color: var(--red); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .ti { font-size: 40px; margin-bottom: 12px; opacity: .3; display: block; }
.empty-state p { font-size: 14px; }

/* ── Login ────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 32px; width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand-icon { width: 48px; height: 48px; margin: 0 auto 10px; font-size: 16px; }
.login-logo h1 { font-size: 20px; font-weight: 600; }
.login-logo p  { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-error { background: var(--red-dim); border: 1px solid rgba(248,113,113,.3); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; color: var(--red); margin-bottom: 16px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-row, .two-col, .three-col { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .op-grid { grid-template-columns: 1fr; }
}
