@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #0e0f11;
  --bg-card: #16181c;
  --bg-input: #1c1f24;
  --border: #2a2d35;
  --border-focus: #4a8eff;
  --text: #e4e6ea;
  --text-muted: #8b8f98;
  --text-dim: #5c5f68;
  --accent: #4a8eff;
  --accent-hover: #6ba0ff;
  --accent-subtle: rgba(74, 142, 255, 0.12);
  --good: #3fb950;
  --danger: #ef4444;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --radius-sm: 5px;
}

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

html {
  font-size: 15px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

/* ── NAV ─────────────────────────────────────────────────────────────── */
#nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--accent-subtle);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.nav-username {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── BUTTONS ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-focus);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-subtle);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* ── INPUTS ───────────────────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
}

select option {
  background: var(--bg-card);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.form-group {
  margin-bottom: 1rem;
}

/* ── CARDS ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ── CHIPS / TAGS ─────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  user-select: none;
}

.chip-approved {
  background: rgba(63, 185, 80, 0.15);
  border-color: rgba(63, 185, 80, 0.4);
  color: var(--good);
}

.chip-vetoed {
  background: rgba(92, 95, 104, 0.15);
  border-color: var(--border);
  color: var(--text-dim);
  text-decoration: line-through;
}

.chip-added {
  background: var(--accent-subtle);
  border-color: rgba(74, 142, 255, 0.35);
  color: var(--accent);
}

.chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  opacity: 0.7;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.chip-remove:hover {
  opacity: 1;
}

.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ── PROGRESS BAR ─────────────────────────────────────────────────────── */
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ── MODALS ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.modal-close:hover {
  background: var(--accent-subtle);
  color: var(--text);
}

/* ── AUTOCOMPLETE ─────────────────────────────────────────────────────── */
.autocomplete-wrap {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.autocomplete-item {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--accent-subtle);
  color: var(--accent);
}

.autocomplete-count {
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ── SPINNER ──────────────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── TABLES ───────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── UTILITY ──────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-good  { color: var(--good); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }

.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; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-good  { background: rgba(63,185,80,0.15); color: var(--good); }
.badge-muted { background: var(--bg-input); color: var(--text-muted); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ── PAGE WRAPPER ─────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* ── EMPTY STATE ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ── LOGIN PAGE ───────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-align: center;
  margin-bottom: 0.35rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ── TAGGING VIEW ─────────────────────────────────────────────────────── */
.tag-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .tag-layout {
    grid-template-columns: 1fr;
  }
}

.tag-image-wrap {
  position: sticky;
  top: 70px;
}

.tag-image-wrap img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  background: var(--bg-card);
  max-height: 70vh;
  object-fit: contain;
}

.tag-caption {
  margin-top: 0.75rem;
}

.tag-caption h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.tag-caption p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.tag-caption .meta {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.tag-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shortcuts-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.shortcuts-hint kbd {
  display: inline-block;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  font-family: monospace;
  font-size: 0.75rem;
}

/* ── PROGRESS HEADER ──────────────────────────────────────────────────── */
.progress-header {
  margin-bottom: 1.5rem;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.progress-text strong {
  color: var(--text);
}

/* ── BROWSE ───────────────────────────────────────────────────────────── */
.browse-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}

.browse-controls .form-group {
  margin: 0;
  min-width: 140px;
}

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

.photo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.photo-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.photo-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg-input);
}

.photo-card-body {
  padding: 0.6rem 0.75rem;
}

.photo-card-title {
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.3rem;
}

.photo-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.photo-card-tag {
  font-size: 0.7rem;
  background: var(--bg-input);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
}

.browse-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── ANALYTICS ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card .stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 800px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.tag-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
}

.tag-bar-name {
  width: 130px;
  flex-shrink: 0;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.tag-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.tag-bar-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

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

/* ── ADMIN ────────────────────────────────────────────────────────────── */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
}
