/* =============================================
   SAFLII Legal Database — style.css
   Dark, premium glassmorphism design
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f14;
  --surface:   #13161e;
  --surface2:  #1a1e2a;
  --surface3:  #20253a;
  --border:    #252b3f;
  --border2:   #2e3650;

  --accent:    #4f7df7;
  --accent-lt: #6b96ff;
  --accent-glow: rgba(79,125,247,.25);

  --gold:      #f5c842;
  --green:     #22c55e;
  --red:       #ef4444;
  --orange:    #f97316;

  --text:      #e8eaf2;
  --text-sub:  #8892aa;
  --text-mute: #4a5268;

  --radius:    14px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --topbar-h:  64px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; overflow: hidden; }

/* ── Layout ─────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
  z-index: 100;
}
.sidebar.collapsed { transform: translateX(-100%); }
.main {
  margin-left: var(--sidebar-w);
  height: 100vh; display: flex; flex-direction: column;
  transition: margin .25s ease;
}
.main.expanded { margin-left: 0; }

/* ── Sidebar Brand ───────────────────────────── */
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #7c5ff7);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 4px 16px var(--accent-glow);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.brand-sub  { font-size: 11px; color: var(--text-sub); }

/* ── Nav ─────────────────────────────────────── */
.nav-section { padding: 16px 12px 8px; flex: 0; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
  color: var(--text-mute); text-transform: uppercase;
  padding: 0 8px 8px;
}
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-sub);
  font-size: 14px; font-family: inherit; cursor: pointer;
  transition: all .15s ease; position: relative; text-align: left;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface3); color: var(--accent-lt);
                   box-shadow: inset 2px 0 0 var(--accent); }
.nav-icon { font-size: 16px; width: 20px; }
.nav-badge {
  margin-left: auto; background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 20px; min-width: 24px; text-align: center;
}
.job-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange); margin-left: auto;
  animation: pulse 1.2s ease infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.sidebar-footer {
  margin-top: auto; padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.docs-link {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  color: var(--text-sub); font-size: 13px; text-decoration: none;
  transition: color .15s;
}
.docs-link:hover { color: var(--accent-lt); }

/* ── Top Bar ─────────────────────────────────── */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.menu-btn {
  background: none; border: 1px solid var(--border2); color: var(--text-sub);
  border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.menu-btn:hover { color: var(--text); border-color: var(--accent); }
.breadcrumb { font-weight: 600; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 8px 14px;
  transition: border-color .2s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { font-size: 14px; }
.search-input {
  background: none; border: none; outline: none;
  color: var(--text); font-family: inherit; font-size: 14px;
  width: 220px;
}
.search-input::placeholder { color: var(--text-mute); }
.search-kbd {
  background: var(--surface3); color: var(--text-mute);
  font-size: 11px; padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--border2);
}

/* ── Content Area ────────────────────────────── */
.content-area {
  flex: 1; overflow: hidden; position: relative;
}
.view {
  position: absolute; inset: 0; overflow-y: auto;
  padding: 24px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.view.active { opacity: 1; pointer-events: all; }

/* ── Filter Bar ──────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-bottom: 18px;
}
.filter-label { font-size: 12px; color: var(--text-sub); }
.filter-chip {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-sub); font-size: 12px;
  padding: 6px 14px; border-radius: 20px; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.filter-chip:hover, .filter-chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}
.year-input {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); font-size: 13px; font-family: inherit;
  padding: 6px 12px; border-radius: 8px; width: 90px; outline: none;
}
.year-input:focus { border-color: var(--accent); }

/* ── Results Header ──────────────────────────── */
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.results-count { font-size: 13px; color: var(--text-sub); }
.view-tabs { display: flex; gap: 4px; }
.vtab {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-sub); font-size: 12px; padding: 6px 12px;
  border-radius: 7px; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.vtab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Items Grid / List ───────────────────────── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.items-grid.list-mode { grid-template-columns: 1fr; }
.items-grid.list-mode .item-card {
  flex-direction: row; gap: 16px; align-items: center;
  padding: 14px 18px;
}
.items-grid.list-mode .item-card .item-body { flex: 1; }
.items-grid.list-mode .item-card .item-badge { flex-shrink: 0; }

.item-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; display: flex; flex-direction: column; gap: 10px;
  transition: all .2s ease; position: relative; overflow: hidden;
}
.item-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  opacity: 0; transition: opacity .2s;
}
.item-card:hover { border-color: var(--accent); transform: translateY(-2px);
                   box-shadow: 0 8px 32px rgba(0,0,0,.4); }
.item-card:hover::before { opacity: 1; }

.item-code {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--accent); background: var(--accent-glow);
  padding: 3px 8px; border-radius: 5px; width: fit-content;
}
.item-title { font-size: 14px; font-weight: 500; line-height: 1.4; }
.item-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.item-tag {
  font-size: 11px; color: var(--text-mute);
  background: var(--surface2); padding: 2px 8px; border-radius: 4px;
}
.item-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 4px 10px; border-radius: 20px;
}
.has-content { background: rgba(34,197,94,.12); color: var(--green); }
.no-content  { background: rgba(239,68,68,.10); color: var(--red); }

/* ── Pagination ──────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 32px; padding-bottom: 16px;
}
.page-btn {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-sub); padding: 8px 14px; border-radius: 8px;
  cursor: pointer; font-family: inherit; font-size: 13px; transition: all .15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent-lt); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--text-sub); }

/* ── Detail View ─────────────────────────────── */
.back-btn {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-sub); padding: 9px 16px; border-radius: 9px;
  cursor: pointer; font-family: inherit; font-size: 13px;
  margin-bottom: 20px; transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.back-btn:hover { color: var(--accent-lt); border-color: var(--accent); }
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.detail-header { padding: 28px 28px 24px; border-bottom: 1px solid var(--border); }
.detail-code {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--accent); margin-bottom: 10px;
}
.detail-title { font-size: 22px; font-weight: 600; line-height: 1.3; margin-bottom: 14px; }
.detail-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.detail-tag {
  font-size: 12px; background: var(--surface2); color: var(--text-sub);
  padding: 4px 12px; border-radius: 6px;
}
.detail-url-link {
  font-size: 12px; color: var(--accent); text-decoration: none;
  padding: 4px 12px; background: var(--accent-glow); border-radius: 6px;
  transition: background .15s;
}
.detail-url-link:hover { background: rgba(79,125,247,.35); }
.content-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.ctab {
  padding: 13px 22px; font-size: 13px; font-weight: 500;
  color: var(--text-sub); cursor: pointer; border: none; background: none;
  font-family: inherit; border-bottom: 2px solid transparent;
  transition: all .15s; margin-bottom: -1px;
}
.ctab:hover { color: var(--text); }
.ctab.active { color: var(--accent-lt); border-bottom-color: var(--accent); }
.content-panel { padding: 24px 28px; display: none; }
.content-panel.active { display: block; }
.html-frame {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: #000; min-height: 400px;
}
.markdown-content {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  line-height: 1.7; white-space: pre-wrap; color: var(--text);
  background: var(--bg); padding: 20px; border-radius: 8px;
  border: 1px solid var(--border); max-height: 70vh; overflow: auto;
}
.text-content {
  font-size: 14px; line-height: 1.8; color: var(--text);
  background: var(--bg); padding: 20px; border-radius: 8px;
  border: 1px solid var(--border); max-height: 70vh; overflow: auto;
  white-space: pre-wrap;
}
.no-content-msg {
  color: var(--text-mute); font-size: 13px; font-style: italic;
  padding: 24px; text-align: center;
}

/* ── Scraper Panel ───────────────────────────── */
.panel-title {
  font-size: 20px; font-weight: 600; margin-bottom: 24px;
  display: flex; align-items: center; gap: 14px;
}
.scraper-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; max-width: 680px;
  display: flex; flex-direction: column; gap: 24px;
}
.form-group { display: flex; flex-direction: column; gap: 10px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-sub); }
.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; cursor: pointer;
}
.letter-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.letter-btn {
  width: 36px; height: 36px;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-sub); border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit;
  transition: all .15s;
}
.letter-btn:hover { border-color: var(--accent); color: var(--accent-lt); }
.letter-btn.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c5ff7);
  border: none; color: #fff; font-size: 14px; font-weight: 600;
  padding: 13px 28px; border-radius: 10px; cursor: pointer;
  font-family: inherit; transition: all .2s; box-shadow: 0 4px 20px var(--accent-glow);
  align-self: flex-start;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px var(--accent-glow); }
.btn-primary:active { transform: none; }
.btn-sm {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-sub); padding: 6px 12px; border-radius: 7px;
  cursor: pointer; font-family: inherit; font-size: 12px; transition: all .15s;
}
.btn-sm:hover { color: var(--text); border-color: var(--accent); }
.scrape-result {
  padding: 14px 18px; border-radius: 10px; font-size: 13px;
  display: none;
}
.scrape-result.success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: var(--green); }
.scrape-result.error   { background: rgba(239,68,68,.10); border: 1px solid rgba(239,68,68,.25); color: var(--red); }

/* ── Jobs List ───────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: 12px; }
.job-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: grid; grid-template-columns: 1fr auto; gap: 12px;
}
.job-title { font-size: 14px; font-weight: 600; text-transform: capitalize; margin-bottom: 6px; }
.job-meta  { font-size: 12px; color: var(--text-sub); }
.status-pill {
  font-size: 11px; font-weight: 600; padding: 4px 12px;
  border-radius: 20px; height: fit-content;
}
.status-pill.pending  { background: rgba(249,115,22,.12); color: var(--orange); }
.status-pill.running  { background: rgba(79,125,247,.15); color: var(--accent-lt); }
.status-pill.done     { background: rgba(34,197,94,.12); color: var(--green); }
.status-pill.failed   { background: rgba(239,68,68,.10); color: var(--red); }
.progress-bar-wrap {
  height: 4px; background: var(--surface3); border-radius: 2px;
  margin-top: 10px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-lt));
  border-radius: 2px; transition: width .4s ease;
}

/* ── Empty state ─────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 80px 24px;
  color: var(--text-mute); text-align: center;
}
.empty-icon { font-size: 48px; opacity: .5; }
.empty-msg  { font-size: 15px; }
.empty-sub  { font-size: 13px; max-width: 340px; line-height: 1.6; }

/* ── Skeleton loader ─────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ── Toast ───────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); font-size: 13px; padding: 12px 18px;
  border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,.4);
  animation: slideIn .25s ease;
  max-width: 340px;
}
.toast.error  { border-left: 3px solid var(--red); }
.toast.success{ border-left: 3px solid var(--green); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: none; }
  .main { margin-left: 0; }
  .search-input { width: 140px; }
  .search-kbd { display: none; }
}
