/* =========================================
   CORE.CSS - Shared styles for all pages
   ========================================= */

/* ===== CSS Variables ===== */
:root {
  /* === EXISTING === */
  --bg: #0f0f0f;
  --card: #141414;
  --text: #ddd;
  --muted: #9aa;
  --link: #9cf;
  --border: #2a2a2a;
  --accent: #2a7bd6;
  --radius: 4px;
  --space: 12px;
  --container: 1040px;
  --font: Candara, "Segoe UI", Calibri, Arial, Helvetica, sans-serif;

  /* === THEMEABLE (change with themes) === */
  
  /* Surfaces */
  --hover-bg: #1a1a1a;        /* Card/button/list hover */
  --surface: #181818;         /* Raised surface */
  --surface-dark: #0d0c0c;    /* Darker surface */
  --bg-deep: #0a0a0a;         /* Deepest background */
  --bg-mid: #222;             /* Mid-tone background */
  
  /* Text */
  --text-white: #fff;         /* Pure white text */
  --text-light: #e0e0e0;      /* Slightly off-white */
  
  /* Status (themeable portion) */
  --attention: #ffd166;       /* Unread, notifications, following */
  --success: #22c55e;         /* Current session, success states */
  --error-text: #ff6b6b;      /* Error message text */
  --danger-text: #ef4444;     /* Danger link text */
  
  /* DM bubbles */
  --dm-me-bg: #0f1419;
  --dm-them-bg: #141014;
  --dm-me-hover: #1a1f24;
  --dm-them-hover: #1f141f;
  
  /* Blocked/banned states */
  --blocked-bg: #3b1f1f;
  --blocked-text: #ffd6d6;
  
  /* Success box */
  --success-box-bg: #0f1c12;
  --success-box-border: #1f3b24;
  --success-box-text: #c6f7d4;
  
  /* Error box */
  --error-box-bg: #2a1010;
  --error-box-border: #5a2a2a;
  --error-box-text: #ffe0e0;
  
  /* Chip (badge) */
  --chip-bg: #1e2d44;
  --chip-text: #cfe2ff;
  
  /* Subtle highlight (for unread, header backgrounds, etc.) */
  --subtle-highlight: rgba(255, 255, 255, 0.03);
  --subtle-highlight-strong: rgba(255, 255, 255, 0.05);
  --btn-hover-overlay: rgba(255, 255, 255, 0.1);
  
  /* === CONSISTENT (same across all themes) === */
  
  /* Role badges - always these exact colors */
  --badge-admin: #7c3aed;
  --badge-mod: #14b8a6;
  --badge-super-admin: #d946ef;
  
  /* Semantic badges */
  --badge-warning: #f59e0b;
  --badge-danger: #dc2626;
  --badge-success: #16a34a;
  
  /* Danger actions */
  --danger: #dc2626;
  
  /* Mod UI */
  --mod-highlight: #f59e0b;   /* Hidden post border, mod toggle */
  
  /* Playlist chip */
  --playlist-chip-bg: #4a7baa;
  --playlist-chip-text: #f0f8ff;
}

/* ===== Reset ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}
html {
  scrollbar-gutter: stable;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  letter-spacing: .005em;
  font-size: 15.5px;
}

/* ===== Layout ===== */
.container {
  max-width: var(--container);
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ===== Typography ===== */
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem 0; }
h1 { font-weight: 700; font-size: 1.6rem; }
h2 { font-weight: 600; font-size: 1.25rem; }
h3 { font-weight: 600; font-size: 1.05rem; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: var(--error-text); }
.warning { color: var(--attention); }
.back { display: inline-block; margin-bottom: var(--space); }
.row-between > .back { margin-bottom: 0; }

/* ===== Utilities ===== */
.row-between { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.m-0 { margin: 0 !important; }
.text-sm { font-size: .9em; }
.hidden { display: none !important; }
.fade-out { opacity: 0; transition: opacity 0.3s ease-out; }
.inline { display: inline !important; }
.block { display: block !important; }
.mt-1 { margin-top: .25rem !important; }
.mt-2 { margin-top: .5rem !important; }
.mt-3 { margin-top: .75rem !important; }
.ml-1 { margin-left: .5rem !important; }
.mb-2 { margin-bottom: .5rem !important; }
.gap-8 { gap: 8px !important; }
.row { display: flex !important; align-items: center !important; }
.report-context-card { background: var(--border); padding: 1rem; }

/* ===== Navigation ===== */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 10px 16px;
  font-size: clamp(11px, 2.2vw, 16px);
}
.brand {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  height: 1.5em;
  width: auto;
  display: block;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.spacer { flex: 1; }
.nav-link { color: var(--text); opacity: .9; }
.nav-link:hover { opacity: 1; }
.nav .btn { width: auto; display: inline-block; white-space: nowrap; padding: .35rem .6rem; font-size: .9em; }
.nav-unread { color: var(--attention); }
.nav-dot { display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--attention);margin-left:6px;vertical-align:middle; }
.nav-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: .4rem;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}
.nav-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: all 0.2s;
}
.nav-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}
.nav-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}
.nav-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Nav role link colors */
.nav-admin-link { color: var(--badge-admin) !important; }
.nav-mod-link { color: var(--badge-mod) !important; }
.nav-super-admin-link { color: var(--badge-super-admin) !important; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.card.medium { max-width: 640px; margin-left: auto; margin-right: auto; }

/* ===== Buttons ===== */
button.btn,
.btn {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  padding: .6rem .7rem;
  border-radius: var(--radius);
  display: inline-block;
}
.btn-sm {
  padding: .35rem .6rem;
  font-size: .9em;
}
.btn.btn-ghost,
.btn-ghost {
  background: transparent !important;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--subtle-highlight-strong) !important;
}
.btn-ghost.btn-unread {
  background: rgba(245, 197, 66, 0.2) !important;
  border-color: rgba(245, 197, 66, 0.4);
  color: var(--attention);
}
.btn-ghost.btn-unread:hover {
  background: rgba(245, 197, 66, 0.3) !important;
  border-color: rgba(245, 197, 66, 0.6);
}
.btn-tiny { 
  padding: .25rem .5rem; 
  font-size: .85em; 
  line-height: 1.2;
  vertical-align: middle;
}
a.btn-tiny,
button.btn-tiny {
  display: inline-flex;
  align-items: center;
}
.btn-inline { width: auto; display: inline-block; }
.btn-link {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0;
  width: auto;
  display: inline;
  cursor: pointer;
  font-size: inherit;
  text-decoration: none;
}
.btn-link-sm { font-size: 0.9em; }
.btn-link:hover { color: var(--text); text-decoration: underline; }
.btn-link.btn-danger {
  color: var(--danger-text);
}
.btn-danger {
  color: var(--danger) !important;
}
.btn-danger:hover {
  background: rgba(220, 38, 38, 0.1);
}

/* ===== Forms ===== */
input, textarea, button {
  width: 100%;
  margin: .4rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea,
select {
  padding: .6rem .7rem;
}
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  opacity: 0.9;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
textarea { resize: vertical; }
.inline-form { display: inline; }
.inline-form .btn { width: auto; display: inline-block; }

/* File input styling */
.file-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: .4rem 0;
}
.file-label {
  display: inline-block;
  padding: .6rem 1rem;
  background: var(--accent);
  color: white;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  font-size: .9em;
  white-space: nowrap;
}
.file-label:hover {
  background: #1f5fa3;
}
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-name {
  color: var(--muted);
  font-size: .9em;
  flex: 0 0 auto;
  min-width: 0;
}
.file-name:empty {
  display: none;
}

/* ===== Lists ===== */
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: .4rem 0; }
.list.rows li + li { border-top: 1px solid var(--border); }

/* Reset article elements */
article {
  margin: 0;
  padding: 0;
}

/* ===== Chips ===== */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  line-height: 1.6;
  vertical-align: middle;
  margin-left: 6px;
}
.chip:first-child {
  margin-left: 0;
}
.chip:hover { text-decoration: none; }

/* Unread emphasis */
.unread { color: var(--attention); }
.unread a,
.unread .muted,
.unread strong { color: var(--attention) !important; }

/* ===== Banners ===== */
.success-banner {
  border: 1px solid var(--success-box-border);
  background: var(--success-box-bg);
  color: var(--success-box-text);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin: .75rem 0;
}
.success-banner .btn {
  width: auto;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1800;
  padding: 1rem;
}
.modal-overlay.hidden {
  display: none;
}
.modal {
  max-width: 420px;
  width: 100%;
}
.modal.modal-wide {
  max-width: min(88vw, 680px);
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}
.modal.modal-confirm {
  max-width: 360px;
  width: 100%;
  text-align: left;
}
.modal-confirm p {
  margin: 0 0 .75rem 0;
}
.modal-confirm .modal-actions {
  justify-content: flex-end;
}
.modal input { width: 100%; }
.modal-actions { margin-top: .5rem; display: flex; gap: 8px; }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 2rem;
}
.lightbox-inner {
  width: fit-content;
  height: fit-content;
  transform: scale(var(--lightbox-scale, 1));
  transform-origin: center center;
}
.lightbox-inner img {
  max-width: min(95vw, 1200px);
  max-height: 90vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.lightbox-img {
  transform: translate(var(--lightbox-tx, 0px), var(--lightbox-ty, 0px));
  transform-origin: center center;
}
.lightbox-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 2100;
}
.lightbox-controls .btn { padding: .3rem .5rem; font-size: .9em; }
/* Lightbox controls always on dark background, so use white text */
.lightbox-controls .btn-ghost {
  color: var(--text-white) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2200;
}
.toast {
  background: #1b1b1b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .7rem;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.hide { opacity: 0; transform: translateY(6px); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-admin { background: var(--badge-admin); color: var(--text-white); }
.badge-mod { background: var(--badge-mod); color: var(--text-white); }
.badge-super-admin { background: var(--badge-super-admin); color: var(--text-white); font-weight: 700; }
.badge-sm { font-size: 0.65rem; padding: 0.15rem 0.4rem; vertical-align: middle; }
.badge-default { background: var(--border); color: var(--text); }
.badge-warning { background: var(--badge-warning); color: #000; }
.badge-danger { background: var(--badge-danger); color: var(--text-white); }
.badge-success { background: var(--badge-success); color: var(--text-white); }
.badge-muted { background: var(--border); color: var(--muted); }

/* ===== Responsive Navigation ===== */
@media (max-width: 560px) {
  .container { margin: 1rem auto; }
  .nav { font-size: 12px; gap: 4px; padding: 8px 8px; width: 100%; max-width: 100%; }
  .brand { font-size: 16px; }
  .spacer { display: block; flex: 1 1 auto; }
  .nav .btn { padding: .25rem .5rem; font-size: .9em; }
  /* Hide regular Home link on mobile - it's in the hamburger menu now */
  .nav > a.nav-link-home {
    display: none !important;
  }
  .nav-menu-toggle {
    display: flex;
  }
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem;
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
  }
  .nav-menu.active {
    display: flex;
  }
  .nav-menu .nav-link,
  .nav-menu .btn {
    width: 100%;
    text-align: left;
  }
  .site-header {
    position: relative;
  }
}

@media (max-width: 768px) {
  .nav { font-size: 14px; gap: 8px; padding: 8px 12px; }
}

@media (max-width: 430px) {
  .nav { font-size: 11px; gap: 3px; padding: 6px 6px; }
  .brand { font-size: 15px; }
  .nav .btn { padding: .2rem .45rem; font-size: .85em; }
  .spacer { flex: 1 1 auto; }
}

/* ===== Additional Utilities ===== */
.nowrap { white-space: nowrap; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.url-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.url-input-group input[type="url"] {
  flex: 1;
  margin: 0;
}
.url-input-group .btn {
  flex-shrink: 0;
  white-space: nowrap;
  margin: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.url-input-group .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.follow-btn.following { color: var(--attention); }

/* ===== Thumbnail Crop Modal ===== */
.thumbnail-crop-container {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  margin: 1.5rem 0;
}
.thumbnail-crop-main {
  flex: 1;
}
.thumbnail-full-preview-wrapper {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.thumbnail-full-preview {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: grab;
  overflow: hidden;
}
.thumbnail-full-preview.dragging {
  cursor: grabbing;
}
.thumbnail-full-preview img {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  user-select: none;
  pointer-events: none;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
.thumbnail-crop-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 256px;
  height: 256px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(255, 255, 255, 0.3);
  pointer-events: none;
  z-index: 10;
}
.thumbnail-crop-controls {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.thumbnail-zoom-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: center;
  max-width: 100%;
}
.thumbnail-zoom-controls .btn {
  width: auto;
}
.thumbnail-zoom-value {
  min-width: 60px;
  text-align: center;
  font-size: .9em;
  color: var(--text);
}
.thumbnail-crop-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.thumbnail-crop-preview h5 {
  margin: 0 0 .75rem 0;
  font-size: .95em;
  font-weight: 600;
  color: var(--text);
}
.thumbnail-preview-wrapper {
  margin-bottom: .5rem;
}
.thumbnail-canvas {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-mid);
  display: block;
}
