*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f0f0f; --bg-card: #1a1a1a; --bg-card2: #141414;
  --border: #222; --border2: #2a2a2a;
  --text: #e0e0e0; --text-muted: #888; --text-faint: #444;
  --primary: #00d4aa; --primary-dim: #00d4aa20; --primary-border: #00d4aa30;
  --red: #f43f5e; --red-dim: #f43f5e20; --red-border: #f43f5e40;
  --purple: #a78bfa; --purple-dim: #7c3aed20;
  --green: #22c55e; --yellow: #fbbf24;
  --radius: 12px; --radius-sm: 8px; --radius-full: 999px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* ── LOGIN ─────────────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box { width: 360px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-logo { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 28px; text-align: center; }
.login-logo span { color: var(--text-muted); font-weight: 400; font-size: 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.field input { width: 100%; background: var(--bg); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; }
.field input:focus { border-color: var(--primary-border); }
.error-msg { font-size: 12px; color: var(--red); margin-bottom: 12px; padding: 8px; background: var(--red-dim); border-radius: var(--radius-sm); }
.btn-primary { width: 100%; padding: 10px; background: var(--primary); color: #000; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

/* ── DASHBOARD LAYOUT ──────────────────────────────────────────────────────── */
.dashboard { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar { width: 300px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.sidebar-logo { font-size: 16px; font-weight: 700; color: var(--primary); }
.sidebar-logo span { color: var(--text-muted); font-weight: 400; font-size: 13px; }
.agents-count { font-size: 11px; color: var(--text-faint); display: flex; align-items: center; gap: 4px; }
.filters { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filter-btn { padding: 4px 10px; border-radius: var(--radius-full); font-size: 11px; cursor: pointer; border: 1px solid var(--border2); background: transparent; color: var(--text-muted); }
.filter-btn.active { background: var(--primary-dim); border-color: var(--primary-border); color: var(--primary); }
.ticket-list { flex: 1; overflow-y: auto; }
.ticket-item { padding: 12px 14px; border-bottom: 1px solid #111; cursor: pointer; transition: background 0.1s; border-left: 3px solid transparent; }
.ticket-item:hover { background: var(--bg-card); }
.ticket-item.active { background: var(--primary-dim); border-left-color: var(--primary); }
.ticket-item.escalated { border-left-color: var(--red); }
.ticket-top { display: flex; justify-content: space-between; margin-bottom: 3px; }
.ticket-name { font-size: 13px; font-weight: 600; }
.ticket-time { font-size: 11px; color: var(--text-faint); }
.ticket-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
.ticket-badges { display: flex; gap: 4px; align-items: center; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: var(--radius-full); font-weight: 500; }
.badge-premium { background: var(--purple-dim); color: var(--purple); border: 1px solid #7c3aed40; }
.badge-free { background: #33333340; color: #666; border: 1px solid var(--border); }
.badge-escalated { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-border); }
.badge-ai { background: var(--primary-dim); color: var(--primary); border: 1px solid var(--primary-border); }
.badge-resolved { background: #22c55e15; color: var(--green); border: 1px solid #22c55e30; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-left: auto; flex-shrink: 0; }

/* ── MAIN ───────────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stats-bar { display: flex; gap: 20px; padding: 8px 20px; border-bottom: 1px solid #111; background: var(--bg-card2); flex-shrink: 0; }
.stat { display: flex; align-items: center; gap: 6px; }
.stat-num { font-size: 18px; font-weight: 700; }
.stat-num.red { color: var(--red); }
.stat-num.yellow { color: var(--yellow); }
.stat-num.green { color: var(--green); }
.stat-label { font-size: 11px; color: var(--text-faint); }
.stat-divider { width: 1px; background: var(--border); }
.chat-header { padding: 12px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.chat-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--purple-dim); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--purple); flex-shrink: 0; }
.chat-user-info h3 { font-size: 14px; font-weight: 600; }
.chat-user-info p { font-size: 12px; color: var(--text-faint); }
.chat-actions { display: flex; gap: 8px; }
.btn { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; border: none; font-weight: 500; }
.btn-close-ticket { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-border); }
.btn-secondary { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border2); }
.messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 75%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.agent, .msg.ai { align-self: flex-start; }
.msg-label { font-size: 10px; color: var(--text-faint); margin-bottom: 3px; }
.msg-label.ai-label { color: var(--primary); }
.msg-bubble { padding: 9px 13px; border-radius: 14px; font-size: 13px; line-height: 1.5; }
.msg.user .msg-bubble { background: var(--primary); color: #000; border-bottom-right-radius: 3px; }
.msg.agent .msg-bubble { background: var(--bg-card); color: var(--text); border-bottom-left-radius: 3px; border: 1px solid var(--border2); }
.msg.ai .msg-bubble { background: var(--primary-dim); color: #bbb; border-bottom-left-radius: 3px; border: 1px solid var(--primary-border); }
.msg-time { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 14px; }
.input-area { padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.agent-selector { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.agent-selector label { font-size: 12px; color: var(--text-faint); }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-box { flex: 1; background: var(--bg-card); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text); font-size: 13px; resize: none; outline: none; min-height: 38px; max-height: 100px; font-family: inherit; }
.input-box:focus { border-color: var(--primary-border); }
.send-btn { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--primary); border: none; cursor: pointer; color: #000; font-size: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.no-ticket { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 14px; }

/* ── RIGHT PANEL ────────────────────────────────────────────────────────────── */
.right-panel { width: 230px; border-left: 1px solid var(--border); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; flex-shrink: 0; }
.panel-section h4 { font-size: 10px; text-transform: uppercase; color: var(--text-faint); letter-spacing: 1px; margin-bottom: 10px; }
.info-row { display: flex; justify-content: space-between; margin-bottom: 7px; }
.info-label { font-size: 12px; color: var(--text-faint); }
.info-value { font-size: 12px; color: var(--text-muted); }
.info-value.premium { color: var(--purple); }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
.agent-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.agent-avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--primary); }
.agent-item-name { font-size: 12px; }
.agent-item-status { font-size: 11px; color: var(--text-faint); }
.quick-action { padding: 7px 10px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border2); font-size: 12px; color: var(--text-muted); cursor: pointer; display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.quick-action:hover { border-color: var(--border); color: var(--text); }
