/* ═══════════════════════════════════════════════════════════════════════
   NANI — Base Styles
   Variables, reset, layout, sidebar, forms, buttons, login, toasts
   ═══════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
  font-family: 'ABChanel Corpo Regular';
  src: url('/static/fonts/ABChanelCorpo-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:         #1D1D1D;
  --bg-sidebar: #141414;
  --surface:    #252525;
  --surface-2:  #2e2e2e;
  --border:     #2e2e2e;
  --border-l:   #3a3a3a;
  --gold:       rgb(213,193,123);
  --gold-dim:   #B8A566;
  --gold-glow:  rgba(213,193,123,.12);
  --accent:     #fff;
  --accent-dim: #ccc;
  --text:       #e5e5e5;
  --text-dim:   #999;
  --text-muted: #666;
  --danger:     #c44;
  --success:    #5a5;
  --radius:     10px;
  --radius-sm:  6px;
  --sidebar-w:  280px;
  --font:       "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-brand: "ABChanel Corpo Regular", serif;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; touch-action: manipulation; }

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

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 8px;
  overflow-y: auto;
  transition: width .25s, min-width .25s, padding .25s;
}
.sidebar.collapsed {
  width: 64px; min-width: 64px; padding: 16px 8px;
  align-items: center;
}
.sidebar.collapsed .brand,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .label { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; border: none; padding-bottom: 8px; }
.sidebar.collapsed .sidebar-action { justify-content: center; padding: 10px; border: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; gap: 0; }
.sidebar.collapsed #btn-collapse { transform: rotate(180deg); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.brand { display: flex; flex-direction: column; }
.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #fff;
  font-family: var(--font-brand);
}
.brand-sub {
  font-size: 9px;
  color: var(--gold);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
  font-family: var(--font-brand);
}

.icon-btn {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.sidebar-action {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: none; border: 1px solid var(--border-l);
  border-radius: var(--radius);
  color: var(--text); font-size: 14px; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.sidebar-action:hover { border-color: var(--text-dim); background: var(--surface); }
.sidebar-action .icon { display: flex; align-items: center; }
.sidebar-action .icon svg { width: 16px; height: 16px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; cursor: pointer;
  transition: color .2s, background .2s;
  text-align: left;
}
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: #fff; background: var(--surface); }
.nav-item .icon { width: 20px; display: flex; align-items: center; justify-content: center; }
.nav-item .icon svg { width: 18px; height: 18px; }

.sidebar-section { margin-top: 16px; flex: 1; overflow-y: auto; }
.sidebar-section-admin { flex: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.sidebar-section-admin .sidebar-nav { margin-top: 0; }
.sidebar.collapsed .sidebar-section-admin { display: none; }
.section-title {
  font-size: 11px; letter-spacing: 1px;
  color: var(--text-muted); padding: 6px 14px; font-weight: 600;
  text-transform: uppercase;
}

.chat-history-list { display: flex; flex-direction: column; gap: 1px; }

.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  text-align: left; width: 100%;
  transition: color .15s, background .15s;
}
.history-item:hover { color: var(--text); background: var(--surface); }
.history-item.active { color: #fff; background: var(--surface); }
.history-item .hist-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .hist-delete {
  display: none; background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0 4px; align-items: center; justify-content: center;
}
.history-item .hist-delete svg { width: 14px; height: 14px; }
.history-item:hover .hist-delete { display: inline-flex; }
.history-item .hist-delete:hover { color: var(--danger); }

/* ── Sidebar user area ───────────────────────────────────────────────── */
.sidebar-user {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar.collapsed .sidebar-user .user-info { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 12px 8px; }

/* ── Main ────────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.panel { display: none; flex: 1; overflow: hidden; }
.panel.active { display: flex; flex-direction: column; }

.panel-scroll { padding: 32px 40px; overflow-y: auto; max-width: 780px; width: 100%; margin: 0 auto; }

/* ── Cards & Forms ───────────────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 700; margin-bottom: 20px; letter-spacing: 1px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.field-label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 4px; color: var(--text);
}
.field-hint {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 6px;
}
.field-val {
  font-weight: 400; color: var(--accent); margin-left: 6px;
}
.mt { margin-top: 18px; }

.input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s;
}
.input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 60px; }

.range { width: 100%; accent-color: #fff; margin-top: 4px; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0; background: var(--border-l);
  border-radius: 12px; cursor: pointer; transition: background .2s;
}
.toggle .slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; bottom: 3px; background: var(--text);
  border-radius: 50%; transition: transform .2s;
}
.toggle input:checked + .slider { background: #fff; }
.toggle input:checked + .slider::before { transform: translateX(18px); background: #111; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 22px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .2s, opacity .2s;
}
.btn.gold { background: #fff; color: #111; }
.btn.gold:hover { opacity: .85; }
.btn.outline { background: none; border: 1px solid var(--border-l); color: var(--text-dim); }
.btn.outline:hover { border-color: var(--accent); color: var(--accent); }
.btn.sm { padding: 5px 14px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.btn.success { background: var(--success); color: #fff; }
.btn.success:hover { opacity: .85; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { opacity: .85; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border-l);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in .25s ease-out;
  transition: opacity .3s;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.fade-out { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── Login overlay ───────────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none !important; }
.login-card {
  text-align: center;
  padding: 48px 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.login-card .brand-name { font-size: 36px; display: block; }
.login-card .brand-sub { font-size: 10px; display: block; margin-bottom: 12px; }
.login-tagline { font-size: 14px; color: var(--text-dim); margin-bottom: 32px; }
.login-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 32px; font-size: 15px;
}

/* ── Utilities ───────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 10; height: 100%; }
  .sidebar.collapsed { width: 64px; min-width: 64px; }
  .panel-scroll { padding: 20px; }
}
