/* ==============================================
   ANDREWS BASE — Shared Design System
   Applied to ALL pages. Template switching works
   by overriding these CSS variables.
   ============================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&display=swap');

/* ---- LIGHT MODE (DEFAULT) ---- */
:root {
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --bg-card: #ffffff;
  --bg-hover: #f5f5f5;
  --text: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e5e5e5;
  --border-light: #f0f0f0;
  --primary: #111111;
  --primary-hover: #333333;
  --primary-text: #ffffff;
  --accent: #111111;
  --success: var(--text);
  --warning: var(--text);
  --danger: var(--text);
  --info: var(--text);

  /* Compatibility aliases for pages using alternate var names */
  --card: var(--bg-card);
  --card-border: var(--border-light);
  --bg-3: var(--bg-alt);
  --text-3: var(--text-muted);
  --accent-soft: var(--bg-hover);
  --radius: 0px;
  --duration: 0.2s;
  --ease: ease;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 48px;
  --space-2xl: 64px;

  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;

  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;

  --transition: 0.2s ease;
}

/* ---- DARK MODE ---- */
[data-theme="dark"] {
  --bg: #000000;
  --bg-alt: #0a0a0a;
  --bg-card: #111111;
  --bg-hover: #1a1a1a;
  --text: #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted: #777777;
  --border: #333333;
  --border-light: #1a1a1a;
  --primary: #ffffff;
  --primary-hover: #cccccc;
  --primary-text: #111111;
  --accent: #ffffff;
  --card: var(--bg-card);
  --card-border: var(--border);
  --bg-3: var(--bg-alt);
  --text-3: var(--text-muted);
  --accent-soft: var(--bg-hover);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=""]) {
    --bg: #000000;
    --bg-alt: #0a0a0a;
    --bg-card: #111111;
    --bg-hover: #1a1a1a;
    --text: #ffffff;
    --text-secondary: #aaaaaa;
    --text-muted: #777777;
    --border: #333333;
    --border-light: #1a1a1a;
    --primary: #ffffff;
    --primary-hover: #cccccc;
    --primary-text: #111111;
    --accent: #ffffff;
  }
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.7; }

img { max-width: 100%; display: block; }

/* ---- TYPOGRAPHY ---- */
.t-display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.02em; }
.t-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px;
}
.t-section-title {
  font-family: var(--font-display); font-size: 28px; font-weight: 400;
  font-style: italic; margin-bottom: var(--space-lg); letter-spacing: -0.02em;
}

h1 { font-family: var(--font-display); font-size: 36px; font-weight: 400; letter-spacing: -0.02em; }
h2 { font-family: var(--font-display); font-size: 28px; font-weight: 400; font-style: italic; letter-spacing: -0.02em; }
h3 { font-family: var(--font-display); font-size: 22px; font-weight: 400; }
h4 { font-family: var(--font-body); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }

/* ---- LAYOUT ---- */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

.page-header {
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: var(--space-lg);
}

.page-grid { display: grid; gap: var(--space-lg); }
.page-grid-2 { grid-template-columns: 1fr 1fr; }
.page-grid-3 { grid-template-columns: repeat(3, 1fr); }
.page-grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .page-grid-2, .page-grid-3, .page-grid-4 { grid-template-columns: 1fr; }
  .page-container { padding: var(--space-lg) var(--space-md); }
}

/* ---- NAVIGATION ---- */
.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1000;
  transition: background 0.3s, border-color 0.3s;
}

.site-nav-logo {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  line-height: 1.4;
  margin-right: var(--space-lg);
}

.site-nav-links {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-evenly;
}

.site-nav-link {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text);
  transition: opacity var(--transition);
  display: inline-flex;
  align-items: center;
}
.site-nav-link:hover { opacity: 0.5; }
.site-nav-link.active {
  font-weight: 700;
  border-bottom: 2px solid var(--text);
  padding-bottom: 2px;
}

/* More dropdown trigger — arrow inline to the right */
.nav-more-trigger { display: inline-flex; align-items: center; gap: 4px; }
.more-arrow { font-size: 8px; line-height: 1; margin-top: 1px; }

.nav-dropdown { position: relative; display: inline-flex; align-items: center; align-self: center; }
.nav-more-trigger { display: inline-flex; align-items: center; }
.nav-more-trigger .more-arrow { font-size: 8px; margin-left: 2px; line-height: 1; }
.nav-dropdown-menu {
  z-index: 1001;
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: var(--space-sm) 0;
  min-width: 220px;
  z-index: 200;
  max-height: 70vh;
  overflow-y: auto;
  transition: background 0.3s;
}
/* Dropdown controlled by JS — stays open while mouse is in nav area */
.nav-dropdown-menu.nav-dropdown-open { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 2px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all var(--transition);
  min-height: 0 !important;
}
.nav-dropdown-menu a:hover { color: var(--text); background: var(--bg-hover); opacity: 1; }
.nav-edit-btn {
  font-size: 9px;
  padding: 1px 6px;
  min-height: 0 !important;
  min-width: 0 !important;
  line-height: 1.2;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
}
.nav-dropdown-menu a.active { color: var(--text); font-weight: 600; }
.nav-dropdown-header {
  padding: 6px 16px 1px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  pointer-events: none;
}
.nav-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 16px;
}

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: var(--space-lg);
  transition: border-color var(--transition), background var(--transition);
}
.card:hover { border-color: var(--border); }
.card-title { font-family: var(--font-body); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-xs); }
.card-value { font-family: var(--font-display); font-size: 32px; font-weight: 400; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- STAT CARDS (row) ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
@media (max-width: 768px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-row { grid-template-columns: 1fr; } }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { opacity: 0.85; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--text); }
.btn-outline:hover { background: var(--text); color: var(--bg); }
.btn-sm { padding: 6px 16px; font-size: 10px; }
.btn-lg { padding: 14px 36px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---- TABLES ---- */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th {
  font-size: 9px; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-muted); text-align: left; padding: 12px 8px;
  border-bottom: 2px solid var(--border);
}
.table-clean td {
  font-size: 13px; padding: 12px 8px; border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.table-clean tr:hover td { background: var(--bg-hover); }

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--space-lg);
}
.tab {
  padding: var(--space-sm) 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab:hover, .tab.active { color: var(--text); border-bottom-color: var(--text); }

/* ---- FORMS ---- */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: var(--space-xs);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--text);
}
.form-textarea { min-height: 100px; resize: vertical; }

/* ---- BADGES / TAGS ---- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-success { background: var(--success); color: white; }
.badge-warning { background: var(--warning); color: white; }
.badge-danger { background: var(--danger); color: white; }
.badge-info { background: var(--info); color: white; }
.badge-neutral { background: var(--border); color: var(--text); }

/* ---- TOGGLE / SWITCH ---- */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle.active { background: var(--text); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle.active::after { transform: translateX(20px); }

/* ---- PHOTO GRID ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
}
.photo-grid-item {
  aspect-ratio: 1;
  background: var(--bg-alt);
  overflow: hidden;
  position: relative;
}
.photo-grid-item img { width: 100%; height: 100%; object-fit: cover; }

/* ---- EARNINGS ROW ---- */
.earnings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.earnings-label { font-size: 14px; color: var(--text-secondary); }
.earnings-value { font-family: var(--font-display); font-size: 18px; font-weight: 400; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: var(--space-md); opacity: 0.3; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: var(--space-sm); }
.empty-state-text { font-size: 13px; }

/* ---- THEME TOGGLE BUTTON ---- */
/* Light mode: black moon crescent */
/* FAB Bar — 5 floating action buttons */
/* FAB trigger button */
.indulgon-fab-bar {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 9998;
}
.indulgon-fab-btn,
.indulgon-fab-trigger {
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
  padding: 0;
  position: relative;
  flex-shrink: 0;
}
.indulgon-fab-trigger:hover { opacity: 0.7; }
.indulgon-fab-trigger.active { background: var(--text); color: var(--bg); }

/* FAB popup grid */
.indulgon-fab-grid {
  position: fixed;
  bottom: 74px; right: 20px;
  z-index: 9998;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.indulgon-fab-grid-btn {
  width: 64px; height: 64px;
  border: 1px solid var(--border);
  background: var(--bg-alt, var(--bg));
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  transition: opacity 0.2s, background 0.2s;
}
.indulgon-fab-grid-btn:hover { background: var(--text); color: var(--bg); }
.indulgon-fab-grid-btn:hover svg { stroke: var(--bg); }
.indulgon-fab-grid-btn svg { width: 20px; height: 20px; stroke: var(--text); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.indulgon-fab-grid-btn span { font-size: 9px; letter-spacing: 0.05em; text-transform: uppercase; line-height: 1; }
.indulgon-fab-grid-btn.active { background: var(--text); color: var(--bg); }
.indulgon-fab-grid-btn.active svg { stroke: var(--bg); }

@media(max-width:480px){
  .indulgon-fab-bar { bottom: 12px; right: 12px; }
  .indulgon-fab-trigger { width: 40px; height: 40px; }
  .indulgon-fab-grid { bottom: 62px; right: 12px; gap: 4px; padding: 8px; }
  .indulgon-fab-grid-btn { width: 56px; height: 56px; }
}
/* Legacy fab-btn kept for any remaining references */
.indulgon-fab-btn:hover { opacity: 0.7; }

/* Panic popup */
.panic-popup {
  display: none;
  position: fixed;
  bottom: 72px; right: 56px;
  z-index: 9999;
  width: 280px;
  background: var(--bg);
  border: 2px solid var(--text);
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.panic-popup.open { display: block; }
.panic-popup h3 { font-size: 14px; font-weight: 700; margin: 0 0 8px; color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; }
.panic-popup p { font-size: 11px; color: var(--text-secondary); line-height: 1.5; margin: 0 0 12px; }
.panic-hold-btn {
  width: 100%; padding: 16px; background: var(--text); color: var(--bg); border: none; cursor: pointer;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  position: relative; overflow: hidden;
}
.panic-hold-btn .hold-progress {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: rgba(255,255,255,0.3); transition: none;
}
.panic-hold-btn.holding .hold-progress { width: 100%; transition: width 3s linear; }
.panic-close { position: absolute; top: 8px; right: 10px; background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 16px; }

/* Hide old standalone buttons - FAB bar replaces them */
.theme-toggle { display: none !important; }
.color-toggle { display: none !important; }

/* ---- FOOTER ---- */
.site-footer {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-2xl);
  color: var(--text-muted);
  font-size: 12px;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- RESPONSIVE ---- */
/* Intermediate narrow desktop / split view */
@media (max-width: 1024px) {
  .site-nav { padding: 10px 16px; }
  .site-nav-logo { margin-right: 12px; }
  .site-nav-links { gap: 4px; }
  .site-nav-link { font-size: 10px; padding: 4px 8px; letter-spacing: 0.04em; }
  .nav-search-wrap { display: none; } /* hide search on narrow */
}

@media (max-width: 768px) {
  .site-nav { padding: var(--space-md); flex-wrap: wrap; gap: var(--space-sm); }
  .site-nav-links { gap: var(--space-md); flex-wrap: wrap; }
  h1 { font-size: 28px; }
  h2 { font-size: 22px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .tabs { overflow-x: auto; gap: var(--space-md); }
}

/* ---- MOBILE TABLE SCROLL ---- */
@media (max-width: 768px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .config-row { flex-direction: column; gap: 8px; align-items: flex-start; }
  .config-row input { width: 100% !important; }
  .view-toggle { flex-wrap: wrap; }
  .profile-nav { gap: 16px; flex-wrap: wrap; padding: 16px 12px; }
  .profile-hero-name { font-size: 32px; }
  .profile-hero-tagline { font-size: 12px; }
  .ja-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .ja-grid { grid-template-columns: repeat(2, 1fr); }
  .ja-section-title { font-size: 28px; }
  .config-panel { width: 100%; }
  .profile-main { padding: 32px 16px; }
  .more-dropdown { max-height: 60vh; overflow-y: auto; }
}

/* ---- MONOCHROME MODE ---- */
/* When the theme is monochrome (primary = text color, no accent color),
   apply grayscale to emoji characters so they match the B&W aesthetic.
   Users with colorful themes won't hit this because their --accent differs from --text. */

/* Grayscale emoji in post content, feed, messages, and activity */
.post-content, .msg-bubble, .activity .a-text, .conv-preview,
.feed-post, .card-text, .caption-text {
  font-variant-emoji: text;
}

/* Global grayscale for emoji — applies to monochrome themes.
   The [data-monochrome] attribute is set by the theme system when
   the user's palette is monochrome (no distinct accent color). */
[data-monochrome="true"] .post-content,
[data-monochrome="true"] .msg-bubble,
[data-monochrome="true"] .activity .a-text,
[data-monochrome="true"] .conv-preview,
[data-monochrome="true"] .conv-avatar,
[data-monochrome="true"] .feed-post .post-body,
[data-monochrome="true"] .a-icon {
  filter: grayscale(1);
}

/* Universal Photo Style: match-theme applies the user's theme tint to photos.
   Works for ANY theme color, not just monochrome.
   data-photo-style: 'themed' = tint photos to match theme, 'normal' = original colors */
[data-photo-style="themed"] img:not(.no-filter),
[data-photo-style="themed"] video:not(.no-filter),
[data-photo-style="themed"] .conv-avatar {
  filter: var(--photo-filter, grayscale(1));
}
/* Override: if user explicitly wants normal photos */
[data-photo-style="normal"] img,
[data-photo-style="normal"] video,
[data-photo-style="normal"] .conv-avatar {
  filter: none;
}

/* ---- GLOBAL BUTTON OVERRIDES (Editorial = sharp corners, B&W) ---- */
button, .btn, [type="submit"], [type="button"] {
  border-radius: 0 !important;
}
/* Action buttons that use --primary should use --text for B&W themes */
button[style*="background:var(--text)"],
button[style*="background: var(--text)"] {
  background: var(--text) !important;
  color: var(--bg) !important;
}
