/* ============================================================
   Catppuccin Latte (light) + Frappe (dark)
   ============================================================ */

:root,
[data-theme="light"] {
  --bg:         #eff1f5;
  --surface0:   #ccd0da;
  --surface1:   #bcc0cc;
  --surface2:   #acb0be;
  --overlay0:   #9ca0b0;
  --text:       #4c4f69;
  --subtext0:   #6c6f85;
  --subtext1:   #5c5f77;
  --blue:       #1e66f5;
  --lavender:   #7287fd;
  --sapphire:   #209fb5;
  --teal:       #179299;
  --green:      #40a02b;
  --yellow:     #df8e1d;
  --red:        #d20f39;
  --mauve:      #8839ef;
  --peach:      #fe640b;
  --mantle:     #e6e9ef;
  --crust:      #dce0e8;
  --border:     #ccd0da;
  --link:       #1e66f5;
  --link-hover: #7287fd;
  --shadow:     rgba(76, 79, 105, 0.10);
}

[data-theme="dark"] {
  --bg:         #303446;
  --surface0:   #414559;
  --surface1:   #51576d;
  --surface2:   #626880;
  --overlay0:   #737994;
  --text:       #c6d0f5;
  --subtext0:   #a5adce;
  --subtext1:   #b5bfe2;
  --blue:       #8caaee;
  --lavender:   #babbf1;
  --sapphire:   #85c1dc;
  --teal:       #81c8be;
  --green:      #a6d189;
  --yellow:     #e5c890;
  --red:        #e78284;
  --mauve:      #ca9ee6;
  --peach:      #ef9f76;
  --mantle:     #292c3c;
  --crust:      #232634;
  --border:     #414559;
  --link:       #8caaee;
  --link-hover: #babbf1;
  --shadow:     rgba(0, 0, 0, 0.30);
}

/* ============================================================
   Reset & base
   ============================================================ */

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ============================================================
   Navbar
   ============================================================ */

.navbar {
  background: var(--mantle);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.navbar-brand:hover { color: var(--blue); text-decoration: none; }
.navbar-brand i { color: var(--mauve); }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--subtext1);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s;
}
.nav-link:hover { background: var(--surface0); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface0); color: var(--text); font-weight: 600; }
.nav-link i { font-size: 0.8rem; }

.navbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.navbar-user {
  font-size: 0.82rem;
  color: var(--subtext0);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-toggle {
  background: var(--surface0);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  color: var(--subtext1);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--surface1); color: var(--text); }
#icon-sun  { color: var(--yellow); }
#icon-moon { color: var(--lavender); }

/* ============================================================
   Main & content wrapper
   ============================================================ */

.main { flex: 1; padding: 2rem 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.main-wide { flex: 1; padding: 2rem 1.5rem; width: 100%; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.page-title i { color: var(--mauve); }

/* ============================================================
   Flash messages
   ============================================================ */

.flash-list { list-style: none; margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.flash-success { background: color-mix(in srgb, var(--green) 15%, var(--bg)); border: 1px solid var(--green); color: var(--green); }
.flash-error   { background: color-mix(in srgb, var(--red) 15%, var(--bg));   border: 1px solid var(--red);   color: var(--red); }
.flash-info    { background: color-mix(in srgb, var(--blue) 15%, var(--bg));  border: 1px solid var(--blue);  color: var(--blue); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn:active { transform: scale(0.97); }

.btn-primary  { background: var(--blue);    color: #fff; }
.btn-success  { background: var(--green);   color: #fff; }
.btn-danger   { background: var(--red);     color: #fff; }
.btn-warning  { background: var(--yellow);  color: #fff; }
.btn-ghost    { background: var(--surface0); color: var(--text); border: 1px solid var(--border); }
.btn-sm       { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg       { padding: 0.75rem 1.75rem; font-size: 1.05rem; border-radius: 12px; }

.btn-keep   { background: var(--green); color: #fff; font-size: 1.1rem; padding: 1rem 2rem; border-radius: 14px; }
.btn-remove { background: var(--red);   color: #fff; font-size: 1.1rem; padding: 1rem 2rem; border-radius: 14px; }
.btn-keep:hover, .btn-remove:hover { opacity: 0.88; }

/* ============================================================
   Cards / panels
   ============================================================ */

.card {
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.folder-card {
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 1px 4px var(--shadow);
  transition: border-color 0.15s;
}
.folder-card:hover { border-color: var(--blue); }

.folder-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.folder-card h3 i { color: var(--yellow); }

.folder-card .meta { font-size: 0.82rem; color: var(--subtext0); }

.folder-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; }

/* ============================================================
   Progress bar
   ============================================================ */

.progress-wrap {
  background: var(--surface0);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress-bar.done { background: var(--green); }

.progress-label { font-size: 0.8rem; color: var(--subtext0); margin-top: 0.25rem; }

/* ============================================================
   Login page
   ============================================================ */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 1.5rem;
}

.login-card {
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 20px var(--shadow);
}

.login-logo {
  text-align: center;
  font-size: 2.5rem;
  color: var(--mauve);
  margin-bottom: 0.5rem;
}

.login-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  color: var(--text);
}

/* ============================================================
   Forms
   ============================================================ */

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; color: var(--subtext1); }

.form-input, .form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus { border-color: var(--blue); }
.form-input::placeholder { color: var(--overlay0); }

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 140px; margin-bottom: 0; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead th {
  background: var(--crust);
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-weight: 600;
  color: var(--subtext1);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--mantle); }

/* ============================================================
   Badges / chips
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: color-mix(in srgb, var(--green)  20%, transparent); color: var(--green);  border: 1px solid var(--green); }
.badge-red    { background: color-mix(in srgb, var(--red)    20%, transparent); color: var(--red);    border: 1px solid var(--red); }
.badge-yellow { background: color-mix(in srgb, var(--yellow) 20%, transparent); color: var(--yellow); border: 1px solid var(--yellow); }
.badge-blue   { background: color-mix(in srgb, var(--blue)   20%, transparent); color: var(--blue);   border: 1px solid var(--blue); }
.badge-gray   { background: var(--surface0); color: var(--subtext0); border: 1px solid var(--border); }

/* ============================================================
   Swipe game
   ============================================================ */

.swipe-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.swipe-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 700px;
}

.swipe-progress-bar { flex: 1; }

.swipe-counter {
  font-size: 0.875rem;
  color: var(--subtext0);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.swipe-photo-wrap {
  width: 100%;
  max-width: 700px;
  aspect-ratio: 3/2;
  background: var(--crust);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 24px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.swipe-filename {
  font-size: 0.78rem;
  color: var(--subtext0);
  text-align: center;
}

.swipe-actions {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: center;
}

.swipe-hint {
  font-size: 0.78rem;
  color: var(--overlay0);
  text-align: center;
  display: flex;
  gap: 1.25rem;
  justify-content: center;
}
.swipe-hint span { display: flex; align-items: center; gap: 0.3rem; }

.swipe-done {
  text-align: center;
  padding: 3rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.swipe-done i { font-size: 3rem; color: var(--green); }
.swipe-done h2 { font-size: 1.5rem; font-weight: 700; }
.swipe-done p  { color: var(--subtext0); }

/* ============================================================
   Review grid
   ============================================================ */

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.review-card {
  background: var(--mantle);
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.review-card.is-keep   { border-color: var(--green); }
.review-card.is-remove { border-color: var(--red); }
.review-card.is-fav    { border-color: var(--yellow); }

.review-card-img {
  aspect-ratio: 3/2;
  background: var(--crust);
  overflow: hidden;
}
.review-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.review-card:hover .review-card-img img { transform: scale(1.03); }

.review-card-footer {
  padding: 0.5rem;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  background: var(--mantle);
  flex-wrap: wrap;
}

.review-filename {
  font-size: 0.7rem;
  color: var(--subtext0);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Admin: final round
   ============================================================ */

.final-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
}

.final-card {
  background: var(--mantle);
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.final-card.is-keep   { border-color: var(--green); }
.final-card.is-remove { border-color: var(--red); }

.final-card-img {
  aspect-ratio: 3/2;
  background: var(--crust);
  overflow: hidden;
  position: relative;
}
.final-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fav-flags {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.fav-flag {
  background: var(--yellow);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  white-space: nowrap;
}

.final-card-footer {
  padding: 0.5rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.final-card-filename {
  font-size: 0.7rem;
  color: var(--subtext0);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Export panel */
.export-panel {
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.export-panel h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.export-panel h2 i { color: var(--teal); }

/* ============================================================
   Stat cards (admin dashboard)
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--subtext0);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--subtext0);
}

/* ============================================================
   Section headers
   ============================================================ */

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

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.section-title i { color: var(--blue); }

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--subtext0);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--mantle);
}
.site-footer a { color: var(--subtext0); }
.site-footer a:hover { color: var(--link); text-decoration: none; }

/* ============================================================
   Utilities
   ============================================================ */

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--subtext0); font-size: 0.875rem; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--subtext0);
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; color: var(--overlay0); }

/* htmx loading indicator */
.htmx-request .btn { opacity: 0.6; pointer-events: none; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 700px) {
  .main { padding: 1.25rem 1rem; }
  .navbar { padding: 0 1rem; }
  .page-title { font-size: 1.25rem; }
  .review-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .final-grid  { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .swipe-actions { gap: 1rem; }
  .btn-keep, .btn-remove { padding: 0.75rem 1.25rem; font-size: 1rem; }
}
