/* ===== DESIGN TOKENS ===== */
:root {
  --primary: #003d99;
  --primary-dark: #001a4d;
  --accent: #c9a84c;
  --accent-light: #e8c97a;
  --bg: #0a2463;
  --text: #f0ece2;
  --text-muted: #a8b8cc;
  --border: rgba(201, 168, 76, 0.25);
  --border-light: rgba(255, 255, 255, 0.15);
  --glass-bg: rgba(10, 36, 99, 0.82);
  --glass-bg-hover: rgba(15, 50, 140, 0.90);
  --card-radius: 14px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0,0,0,0.25);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0,0,0,0.35);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Libre Baskerville', Georgia, serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== BACKGROUND ===== */
#bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: url('/images/rushmore-bg.png') center 40% / cover no-repeat;
}

#bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(5, 26, 75, 0.60) 0%,
    rgba(10, 36, 99, 0.72) 40%,
    rgba(5, 20, 65, 0.90) 100%
  );
}

/* ===== APP SHELL ===== */
#app {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== DESKTOP LAYOUT ===== */
@media (min-width: 768px) {
  #app {
    flex-direction: row;
  }
}

/* ===== SIDEBAR (DESKTOP) ===== */
#sidebar {
  display: none;
}

@media (min-width: 768px) {
  #sidebar {
    display: flex;
    flex-direction: column;
    width: 280px;
    flex-shrink: 0;
    background: rgba(8, 14, 28, 0.88);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow-y: auto;
    padding: 0 0 24px 0;
  }
}

#sidebar-header {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

#sidebar-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
}

#sidebar-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#sidebar-search {
  padding: 0 12px 12px;
}

.sidebar-section-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 16px 4px;
  font-family: 'Libre Baskerville', serif;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 8px;
  margin: 1px 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: all 0.18s ease;
  border: 1px solid transparent;
  background: transparent;
  width: calc(100% - 16px);
  text-align: left;
  font-family: 'Libre Baskerville', serif;
}

.sidebar-nav-item:hover {
  background: rgba(201, 168, 76, 0.08);
  color: var(--text);
  border-color: var(--border);
}

.sidebar-nav-item.active {
  background: rgba(201, 168, 76, 0.14);
  color: var(--accent-light);
  border-color: rgba(201, 168, 76, 0.3);
}

.sidebar-nav-item .nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.5;
}

.sidebar-nav-item.active .nav-dot {
  opacity: 1;
  background: var(--accent);
}

/* ===== MAIN CONTENT ===== */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== MOBILE HEADER ===== */
#mobile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  background: rgba(8, 14, 28, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  #mobile-header {
    display: none;
  }
}

#mobile-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
  flex: 1;
  line-height: 1.2;
}

/* ===== CONTROLS BAR ===== */
#controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(8, 14, 28, 0.7);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  #controls-bar {
    padding: 14px 24px;
    gap: 14px;
  }
}

#jurisdiction-select {
  flex: 1;
  min-width: 160px;
  background: rgba(20, 32, 58, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.875rem;
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color 0.18s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23c9a84c' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

#jurisdiction-select:focus {
  outline: none;
  border-color: var(--accent);
}

#sort-toggle {
  background: rgba(20, 32, 58, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.78rem;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

#sort-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#add-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--primary-dark);
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
}

#add-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

/* ===== RESULTS HEADER ===== */
#results-header {
  padding: 12px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  #results-header {
    padding: 14px 24px 8px;
  }
}

#results-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

@media (min-width: 768px) {
  #results-title {
    font-size: 1.3rem;
  }
}

#results-count {
  font-size: 0.75rem;
  color: var(--accent);
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 20px;
  padding: 3px 10px;
  font-family: 'Libre Baskerville', serif;
  letter-spacing: 0.04em;
}

/* ===== POLICY LIST ===== */
#policy-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 24px;
  scroll-behavior: smooth;
}

@media (min-width: 768px) {
  #policy-list {
    padding: 10px 20px 32px;
  }
}

@media (min-width: 1024px) {
  #policy-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-content: start;
    padding: 10px 24px 32px;
  }
}

#policy-list::-webkit-scrollbar { width: 4px; }
#policy-list::-webkit-scrollbar-track { background: transparent; }
#policy-list::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 2px; }

/* ===== POLICY CARD ===== */
.policy-card {
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--card-radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
  transition: all 0.22s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
  animation: card-in 0.4s ease both;
}

@media (min-width: 1024px) {
  .policy-card {
    margin-bottom: 0;
  }
}

.policy-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s;
}

.policy-card:hover {
  background: var(--glass-bg-hover);
  border-color: rgba(201,168,76,0.25);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}

.policy-card:hover::before {
  opacity: 1;
}

.policy-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.policy-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  flex: 1;
}

.policy-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.card-action-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Libre Baskerville', serif;
}

.card-action-btn:hover {
  background: rgba(201,168,76,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.card-action-btn.delete:hover {
  background: rgba(200,60,60,0.12);
  border-color: rgba(220,80,80,0.4);
  color: #e87070;
}

.policy-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.policy-date {
  font-size: 0.73rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  font-family: 'Libre Baskerville', serif;
}

.policy-jurisdiction-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'Libre Baskerville', serif;
}

.policy-summary {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== EMPTY STATE ===== */
#empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  animation: fade-in 0.4s ease;
}

#empty-state.visible {
  display: flex;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 280px;
}

/* ===== SEARCH INPUT (SIDEBAR) ===== */
.search-input {
  width: 100%;
  background: rgba(20, 32, 58, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.8rem;
  padding: 8px 12px;
  transition: border-color 0.18s;
}

.search-input::placeholder { color: var(--text-muted); opacity: 0.7; }

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== MODAL ===== */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 10, 20, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#modal-overlay.visible {
  display: flex;
}

#modal {
  background: rgba(12, 20, 42, 0.97);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

#modal-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.15s;
}

#modal-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

#modal-body {
  padding: 20px 24px 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  font-family: 'Libre Baskerville', serif;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: rgba(20, 32, 58, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.875rem;
  padding: 10px 12px;
  transition: border-color 0.18s;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23c9a84c' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-select option {
  background: #0d1a2e;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-save {
  flex: 1;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--primary-dark);
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 11px 20px;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 0.02em;
}

.btn-save:hover {
  background: var(--accent-light);
}

.btn-cancel {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.875rem;
  padding: 11px 16px;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-cancel:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

/* ===== CONFIRM DIALOG ===== */
#confirm-dialog {
  background: rgba(12, 20, 42, 0.97);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 360px;
  padding: 24px;
  animation: modal-in 0.25s ease both;
}

#confirm-dialog p {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}

#confirm-dialog .confirm-actions {
  display: flex;
  gap: 10px;
}

#confirm-dialog .btn-danger {
  flex: 1;
  background: rgba(200,60,60,0.2);
  border: 1px solid rgba(220,80,80,0.4);
  border-radius: 8px;
  color: #e87070;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.875rem;
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

#confirm-dialog .btn-danger:hover {
  background: rgba(200,60,60,0.3);
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(14, 24, 48, 0.97);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.85rem;
  padding: 12px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: none;
  white-space: nowrap;
}

#toast.visible {
  display: block;
  animation: playful-toast-in 0.3s ease forwards;
}

#toast.hiding {
  animation: playful-toast-out 0.3s ease forwards;
}

/* ===== KEYFRAMES ===== */
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== MOBILE BOTTOM SELECTOR ===== */
#mobile-selector-bar {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: rgba(8, 14, 28, 0.9);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
  gap: 8px;
}

@media (min-width: 768px) {
  #mobile-selector-bar {
    display: none;
  }
}

/* ===== DESKTOP SEARCH HEADER ===== */
#desktop-search-header {
  display: none;
}

@media (min-width: 768px) {
  #desktop-search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px 0;
    flex-shrink: 0;
  }
}

/* ===== SCROLLBAR STYLES ===== */
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 2px; }
