@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --navy:   #0d1b2a;
  --navy2:  #1a2d42;
  --navy3:  #243b55;
  --gold:   #f5c842;
  --gold2:  #e0a800;
  --red:    #e63946;
  --red2:   #c1121f;
  --green:  #2dc653;
  --blue:   #4895ef;
  --white:  #f8f9fa;
  --muted:  #8da9c4;
  --card:   rgba(26,45,66,0.9);
  --border: rgba(245,200,66,0.25);
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--navy);
  color: var(--white);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(245,200,66,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(72,149,239,0.06) 0%, transparent 50%);
}

/* ── Dot grid texture ── */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ── GATE PAGE ── */
.gate-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; position: relative; z-index: 1;
}
.gate-box {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  width: 100%; max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow), 0 0 60px rgba(245,200,66,0.08);
  backdrop-filter: blur(12px);
  animation: fadeUp 0.6s ease;
}
.gate-seal {
  font-size: 4rem; margin-bottom: 0.5rem;
  animation: spin 20s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gate-box h1 {
  font-family: 'Fredoka', sans-serif;
  font-size: 2.2rem; color: var(--gold);
  letter-spacing: 1px; margin-bottom: 0.25rem;
}
.gate-box p { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }

/* ── NAVBAR ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,27,42,0.95);
  border-bottom: 2px solid var(--border);
  backdrop-filter: blur(16px);
  padding: 0 1.5rem;
  display: flex; align-items: center; gap: 0;
  height: 64px;
}
.nav-brand {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem; color: var(--gold);
  text-decoration: none; margin-right: auto;
  display: flex; align-items: center; gap: 0.5rem;
}
.nav-brand span { font-size: 1.4rem; }
.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-links a {
  color: var(--muted); text-decoration: none;
  padding: 0.45rem 0.85rem; border-radius: 10px;
  font-size: 0.85rem; font-weight: 700;
  transition: all 0.2s; white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--border); color: var(--gold);
}
.nav-user {
  display: flex; align-items: center; gap: 0.75rem;
  margin-left: 1rem; padding-left: 1rem;
  border-left: 1px solid var(--border);
}
.nav-badge {
  background: var(--gold); color: var(--navy);
  font-size: 0.75rem; font-weight: 800;
  padding: 0.2rem 0.6rem; border-radius: 20px;
}
.nav-user .citizen-name { font-weight: 700; font-size: 0.9rem; }
.btn-logout {
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px;
  padding: 0.3rem 0.7rem; font-size: 0.8rem;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── MAIN LAYOUT ── */
.main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; position: relative; z-index: 1; }
.page-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 2rem; color: var(--gold); margin-bottom: 1.5rem;
  display: flex; align-items: center; gap: 0.5rem;
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
}
.card-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem; color: var(--gold);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.4rem;
}

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── STAT CARDS ── */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  text-align: center;
}
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-card .stat-val {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem; color: var(--gold); line-height: 1;
}
.stat-card .stat-val small { font-size: 1rem; color: var(--muted); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; font-weight: 600; }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.8rem; font-weight: 700;
  color: var(--muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px;
}
input, select, textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: var(--white);
  padding: 0.65rem 0.9rem; font-size: 0.95rem;
  font-family: 'Nunito', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,200,66,0.15);
}
select option { background: var(--navy2); }
textarea { resize: vertical; min-height: 80px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem; border-radius: 10px;
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 0.9rem;
  cursor: pointer; border: none; transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: var(--gold2); transform: translateY(-1px); }
.btn-danger  { background: var(--red); color: white; }
.btn-danger:hover  { background: var(--red2); }
.btn-green   { background: var(--green); color: var(--navy); }
.btn-green:hover   { filter: brightness(1.1); }
.btn-ghost   { background: transparent; border: 1.5px solid var(--border); color: var(--muted); }
.btn-ghost:hover   { border-color: var(--gold); color: var(--gold); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── TABLES ── */
.tc-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tc-table th {
  text-align: left; padding: 0.75rem 1rem;
  color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.tc-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.tc-table tr:last-child td { border-bottom: none; }
.tc-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── BADGES ── */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem;
  border-radius: 20px; font-size: 0.72rem; font-weight: 800;
}
.badge-gold   { background: rgba(245,200,66,0.15); color: var(--gold); }
.badge-red    { background: rgba(230,57,70,0.15); color: var(--red); }
.badge-green  { background: rgba(45,198,83,0.15); color: var(--green); }
.badge-blue   { background: rgba(72,149,239,0.15); color: var(--blue); }
.badge-muted  { background: rgba(141,169,196,0.15); color: var(--muted); }

/* ── TR CURRENCY ── */
.tr-amount {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem; color: var(--gold);
}
.tr-amount .rs { font-size: 0.75rem; color: var(--muted); font-family: 'Nunito', sans-serif; }

/* ── BROWSER ── */
.browser-bar {
  background: rgba(255,255,255,0.04);
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 0.6rem 1rem;
  display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem;
}
.browser-bar input {
  flex: 1; background: none; border: none; padding: 0;
  font-size: 0.95rem; color: var(--white);
}
.browser-bar input:focus { box-shadow: none; }
.browser-protocol {
  color: var(--green); font-weight: 700; font-size: 0.9rem; white-space: nowrap;
}
.browser-viewport {
  background: white; border-radius: 12px;
  min-height: 420px; overflow: hidden;
  border: 2px solid var(--border);
}
.browser-viewport iframe {
  width: 100%; height: 500px; border: none;
}
.browser-error {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 300px; color: var(--muted); gap: 0.5rem;
}
.browser-error .err-code {
  font-family: 'Fredoka', sans-serif; font-size: 3rem; color: var(--red);
}
.domain-list { display: flex; flex-direction: column; gap: 0.5rem; }
.domain-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.8rem; border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; transition: all 0.2s;
}
.domain-item:hover {
  background: rgba(245,200,66,0.06);
  border-color: var(--border);
}
.domain-item .domain-name { font-weight: 700; color: var(--blue); font-size: 0.9rem; }
.domain-item .domain-owner { font-size: 0.75rem; color: var(--muted); margin-left: auto; }

/* ── NEWS ── */
.news-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  margin-bottom: 1rem; animation: fadeUp 0.4s ease both;
}
.news-card .news-category {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 0.5rem;
}
.news-card .news-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--white);
}
.news-card .news-body { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }
.news-card .news-ts { font-size: 0.75rem; color: var(--muted); margin-top: 0.75rem; }

/* ── HOME WELCOME ── */
.welcome-banner {
  background: linear-gradient(135deg, var(--navy3), var(--navy2));
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  margin-bottom: 1.5rem; position: relative; overflow: hidden;
}
.welcome-banner::after {
  content: '🏛️';
  position: absolute; right: 1.5rem; top: 50%;
  transform: translateY(-50%); font-size: 5rem; opacity: 0.08;
}
.welcome-banner h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem; color: var(--gold); margin-bottom: 0.25rem;
}
.welcome-banner p { color: var(--muted); font-size: 0.9rem; }

/* ── ADMIN TABS ── */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-btn {
  padding: 0.5rem 1.1rem; border-radius: 10px;
  background: transparent; border: 1.5px solid var(--border);
  color: var(--muted); font-family: 'Nunito', sans-serif;
  font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── WALLET CARD ── */
.wallet-card {
  background: linear-gradient(135deg, #1a3a1a, #0d2a0d);
  border: 1px solid rgba(45,198,83,0.3);
  border-radius: var(--radius); padding: 2rem;
  text-align: center; margin-bottom: 1.5rem;
}
.wallet-card .w-label { font-size: 0.8rem; color: var(--green); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.wallet-card .w-amount {
  font-family: 'Fredoka', sans-serif;
  font-size: 3.5rem; color: var(--white); margin: 0.25rem 0;
}
.wallet-card .w-rs { font-size: 1rem; color: rgba(255,255,255,0.4); }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 9999;
  background: var(--navy3); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.5rem;
  font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow); max-width: 320px;
  transform: translateY(100px); opacity: 0;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: var(--green); color: var(--green); }
#toast.error   { border-color: var(--red);   color: var(--red);   }
#toast.info    { border-color: var(--blue);  color: var(--blue);  }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--navy2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem; width: 90%; max-width: 480px;
  transform: scale(0.92); transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal h3 {
  font-family: 'Fredoka', sans-serif; font-size: 1.4rem;
  color: var(--gold); margin-bottom: 1.25rem;
}
.modal-close {
  float: right; background: none; border: none;
  color: var(--muted); font-size: 1.4rem; cursor: pointer;
  line-height: 1; margin-top: -4px;
}

/* ── EMPTY STATE ── */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty p { font-size: 0.9rem; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.5s ease both; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--navy); }
::-webkit-scrollbar-thumb { background: var(--navy3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold2); }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── FINE CARD ── */
.fine-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; border-radius: 12px;
  background: rgba(230,57,70,0.07);
  border: 1px solid rgba(230,57,70,0.2); margin-bottom: 0.75rem;
}
.fine-card .fine-amount {
  font-family: 'Fredoka', sans-serif; font-size: 1.4rem; color: var(--red);
  white-space: nowrap;
}
.fine-card .fine-reason { font-size: 0.9rem; flex: 1; }
.fine-card .fine-ts { font-size: 0.75rem; color: var(--muted); }

/* ── CITIZEN CHIP ── */
.citizen-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(72,149,239,0.1); border: 1px solid rgba(72,149,239,0.2);
  border-radius: 20px; padding: 0.25rem 0.75rem; font-size: 0.82rem;
}
.citizen-chip .chip-icon { font-size: 1rem; }

/* ── CODE EDITOR ─────────────────────────────────────────────────────────── */
.code-editor-wrap {
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 10px; overflow: hidden;
  transition: border-color 0.2s;
}
.code-editor-wrap:focus-within { border-color: var(--gold); }
.code-editor-toolbar {
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: .4rem .75rem;
  display: flex; align-items: center; justify-content: space-between;
}
.code-editor {
  width: 100%; min-height: 180px;
  background: rgba(0,0,0,0.25);
  border: none; border-radius: 0;
  color: #a8d8a8;
  font-family: 'Courier New', Courier, monospace;
  font-size: .85rem; line-height: 1.6;
  padding: .75rem;
  resize: vertical;
  tab-size: 2;
}
.code-editor:focus { box-shadow: none; outline: none; }

/* ── FILE DROP ZONE ──────────────────────────────────────────────────────── */
.file-drop-zone {
  border: 2px dashed rgba(245,200,66,0.3);
  border-radius: 12px; padding: 2rem 1rem;
  text-align: center; cursor: pointer;
  transition: all 0.2s; background: rgba(245,200,66,0.02);
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(245,200,66,0.06);
}
.drop-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.drop-label { font-weight: 700; font-size: .9rem; margin-bottom: .25rem; }
.drop-sub   { font-size: .78rem; color: var(--muted); }

/* ── SRC TOGGLE ACTIVE ───────────────────────────────────────────────────── */
.src-toggle.active, .edit-src-toggle.active {
  background: rgba(245,200,66,0.15);
  border-color: var(--gold); color: var(--gold);
}
