/* CRM TUIS · Control Center — misma paleta que el CRM de Rosa (AgentInbtel/frontend/src/theme.css) */
:root {
  --color-sidebar: #0f172a;
  --color-sidebar-hover: rgba(255, 255, 255, 0.06);
  --color-primary: #1D4ED8;
  --color-primary-light: #2563EB;
  --color-accent: #3B82F6;
  --color-accent-light: #60A5FA;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-bg: #f8fafc;
  --color-bg-elevated: #ffffff;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-soft-float: 0 12px 32px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px; color: var(--color-text); background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: relative; width: var(--sidebar-width); flex-shrink: 0;
  background: var(--color-sidebar); color: #fff;
  display: flex; flex-direction: column;
  transition: width .2s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sb-toggle {
  position: absolute; top: 36px; right: -12px; z-index: 5;
  width: 24px; height: 24px; border-radius: 50%; padding: 0;
  background: var(--color-primary); color: #fff; border: 2px solid var(--color-bg);
  display: flex; align-items: center; justify-content: center;
}
.sidebar.collapsed .sb-toggle svg { transform: rotate(180deg); }
.sb-brand { padding: 28px 24px 20px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.sb-brand img { height: 38px; width: auto; max-width: 100%; object-fit: contain; object-position: left; filter: drop-shadow(0 2px 8px rgba(0,0,0,.2)); }
.sb-caption {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--color-accent-light); opacity: .6; white-space: nowrap; margin-top: 4px;
}
.sidebar.collapsed .sb-brand { padding: 28px 12px 20px; align-items: center; }
.sidebar.collapsed .sb-brand img { height: 26px; }
.sidebar.collapsed .sb-caption, .sidebar.collapsed .sb-text { display: none; }

.sb-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; overflow-x: hidden; }
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  color: rgba(255,255,255,.7); font-weight: 500; transition: background .2s, color .2s;
}
.sb-item:hover { background: var(--color-sidebar-hover); color: #fff; }
.sb-item.active { background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); color: #fff; font-weight: 700; }
.sb-icon { display: flex; opacity: .8; }
.sb-item.active .sb-icon { opacity: 1; }
.sb-text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; min-width: 0; }
.sb-text small { font-size: 11px; font-weight: 400; opacity: .6; letter-spacing: .2px; }
.sidebar.collapsed .sb-item { justify-content: center; padding: 12px 0; }

.sb-user {
  padding: 20px 24px; border-top: 1px solid rgba(255,255,255,.06); background: rgba(0,0,0,.1);
  display: flex; align-items: center; gap: 12px;
}
.sidebar.collapsed .sb-user { padding: 20px 12px; justify-content: center; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-accent-light), var(--color-primary));
  font-size: 14px; font-weight: 800; color: #fff;
}
.sb-user small { color: rgba(255,255,255,.55); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-height); padding: 0 24px; display: flex; align-items: center; gap: 16px;
  background: var(--color-bg-elevated); border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 3;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--color-text); }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #e2e8f0; color: var(--color-text-muted); }
.pill.ok { background: #d1fae5; color: #065f46; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.btn {
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--color-primary);
  background: var(--color-primary); color: #fff; font-weight: 600;
}
.btn:hover { background: var(--color-primary-light); }
.btn-ghost { background: #fff; color: var(--color-primary); }
.btn-ghost:hover { background: #eff6ff; }

.view { padding: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--color-bg-elevated); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 18px;
}
.stat { border-top: 4px solid var(--stat-color, var(--color-border)); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 6px; color: var(--stat-color, var(--color-text)); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; margin: 0; }
.link { color: var(--color-primary); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--color-text-muted); }
.table td.subject { white-space: normal; min-width: 220px; font-weight: 600; }
.table tr:hover td { background: #f8fafc; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #fff; background: var(--color-text-muted); }
.muted { color: var(--color-text-muted); }
.quick { display: flex; flex-direction: column; gap: 10px; }
.quick-item {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); transition: border-color .2s, background .2s;
}
.quick-item:hover { border-color: var(--color-accent); background: #eff6ff; }
.quick-item small { color: var(--color-text-muted); }
.note { margin-top: 14px; font-size: 12px; color: var(--color-text-muted); }

/* ---------- Tickets (UVdesk embebido) ---------- */
#view-tickets { padding: 0; display: flex; flex-direction: column; height: calc(100vh - var(--topbar-height)); }
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--color-bg-elevated); border-bottom: 1px solid var(--color-border); font-size: 13px;
}
.toolbar-right { display: flex; gap: 8px; }
.frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Responsive ---------- */
.backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 9; }
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s ease; width: var(--sidebar-width) !important; }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sb-toggle { display: none; }
  .sidebar.collapsed .sb-caption, .sidebar.collapsed .sb-text { display: flex; }
  .backdrop.show { display: block; }
  .menu-btn { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
}

/* ---------- Ocultar de verdad lo que lleve [hidden] (gana a display:flex de .app y #view-tickets) ---------- */
[hidden] { display: none !important; }

/* ---------- Pantalla de inicio de sesión ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% 0%, #1e3a8a 0%, var(--color-sidebar) 55%, #020617 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--color-bg-elevated); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(2, 6, 23, .45); overflow: hidden;
}
.login-head { background: var(--color-sidebar); padding: 28px 28px 22px; display: flex; flex-direction: column; gap: 8px; }
.login-head img { height: 40px; width: auto; object-fit: contain; object-position: left; filter: drop-shadow(0 2px 8px rgba(0,0,0,.2)); }
.login-caption { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--color-accent-light); opacity: .7; }
.login-body { padding: 26px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-body h1 { margin: 0; font-size: 20px; }
.login-body p { margin: -6px 0 4px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.field input {
  font: inherit; font-weight: 500; color: var(--color-text); padding: 11px 12px;
  border: 1px solid var(--color-border-strong, #cbd5e1); border-radius: var(--radius-sm); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-text-muted); }
.check input { width: 16px; height: 16px; accent-color: var(--color-primary); }
.login-error { background: #fee2e2; color: #991b1b; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; font-weight: 600; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .7; cursor: default; }

/* ---------- Botón de salir en la tarjeta de usuario ---------- */
.sb-user { position: relative; }
.sb-user .sb-text { flex: 1; min-width: 0; overflow: hidden; }
.sb-user .sb-text b, .sb-user .sb-text small { overflow: hidden; text-overflow: ellipsis; }
.sb-logout {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; border: 0; padding: 0;
  background: transparent; color: rgba(255,255,255,.55); display: flex; align-items: center; justify-content: center;
}
.sb-logout:hover { background: var(--color-sidebar-hover); color: #fff; }
.sidebar.collapsed .sb-logout { display: none; }
