/* JOOSN Admin Dashboard */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3347;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --text-dim: #4b5563;
  --sidebar-w: 220px;
  --radius: 10px;
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.6; display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 10; }
.sidebar-logo { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.logo-text { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; color: var(--primary); display: block; }
.logo-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.nav-section { padding: 16px 20px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 8px 20px; color: var(--text-muted); text-decoration: none; font-size: 13px; transition: all 0.15s; border-left: 2px solid transparent; }
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--primary); border-left-color: var(--primary); background: rgba(99,102,241,0.08); }
.nav-link svg { flex-shrink: 0; }
.nav-agent { font-size: 12px; padding: 6px 20px; }
.agent-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.sidebar-bottom { margin-top: auto; padding: 16px 0; border-top: 1px solid var(--border); }
.nav-logout { color: var(--text-dim); font-size: 12px; }
.nav-logout:hover { color: var(--error); background: rgba(239,68,68,0.08); }

/* Main content */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 32px; max-width: 1200px; }

/* Page header */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--text-muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; font-size: 13px; margin-bottom: 12px; }
.back-link:hover { color: var(--primary); }
.agent-page-title { display: flex; align-items: center; gap: 16px; }
.agent-page-title h1 { font-size: 24px; font-weight: 700; }

/* Agents grid */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.agent-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--text); transition: all 0.2s; display: block; }
.agent-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99,102,241,0.15); }
.agent-card.inactive { opacity: 0.6; }
.agent-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.agent-avatar { width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #8b5cf6); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.agent-avatar-lg { width: 52px; height: 52px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), #8b5cf6); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; flex-shrink: 0; }
.agent-info { flex: 1; min-width: 0; }
.agent-info h3 { font-size: 15px; font-weight: 600; }
.agent-role { font-size: 12px; color: var(--text-muted); }
.agent-email { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.agent-stats { display: flex; gap: 20px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.stat { text-align: center; }
.stat-value { display: block; font-size: 22px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.agent-latest { font-size: 12px; color: var(--text-muted); }
.latest-label { color: var(--text-dim); }
.latest-subject { display: block; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* Status badges */
.status-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-left: auto; }
.status-badge.active { background: rgba(34,197,94,0.15); color: var(--success); }
.status-badge.inactive { background: rgba(75,85,99,0.2); color: var(--text-dim); }
.badge-lg { font-size: 12px; padding: 4px 14px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 18px; text-decoration: none; color: var(--text-muted); font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Email list */
.email-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.email-count { font-size: 12px; color: var(--text-muted); }
.email-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.email-row { display: grid; grid-template-columns: 200px 1fr 150px; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); transition: background 0.1s; }
.email-row:last-child { border-bottom: none; }
.email-row:hover { background: var(--surface2); }
.email-from { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-subject { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-date { font-size: 12px; color: var(--text-dim); text-align: right; white-space: nowrap; }

/* Email view */
.email-view-subject { font-size: 22px; font-weight: 600; }
.email-view-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.email-meta { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.meta-row { display: flex; gap: 12px; font-size: 13px; }
.meta-label { color: var(--text-muted); width: 60px; flex-shrink: 0; }
.email-body { padding: 24px; font-family: 'SF Mono', 'Fira Mono', monospace; font-size: 13px; line-height: 1.8; white-space: pre-wrap; color: var(--text); }

/* Settings form */
.settings-form { display: block; }
.settings-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; margin-bottom: 24px; }
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.settings-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 20px; color: var(--text); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.form-control { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 13px; font-family: inherit; transition: border-color 0.15s; resize: vertical; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-group small { display: block; font-size: 11px; color: var(--text-dim); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-checkbox label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); }
.form-checkbox input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 10px; }
.info-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.info-row { display: flex; justify-content: space-between; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-row span:first-child { color: var(--text-muted); }
.api-hint { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 12px; color: var(--text-muted); }
.api-hint code { font-family: monospace; color: var(--primary); font-size: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; border: none; cursor: pointer; text-decoration: none; transition: all 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--text-dim); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-text { font-size: 28px; display: block; }
.login-logo .logo-sub { font-size: 13px; color: var(--text-muted); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

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