/* ==========================================================
   Mundtrold — Main Style v68 (Dark Espresso Theme)
   ========================================================== */

/* --- DESIGN TOKENS --- */
:root {
  /* Color palette — warm light with espresso accents */
  --bg:             #FAF7F5;
  --surface:        #FFFFFF;
  --surface-2:      #F5F0EA;
  --surface-3:      #EDE6DD;
  --border:         #DDD5CC;
  --border-subtle:  #E8E1D9;

  --text:           #1A1210;
  --text-muted:     #6B5E54;
  --text-faint:     #9C8E82;

  --accent:         #FF5A5F;
  --accent-hover:   #E8484D;
  --accent-glow:    #D94045;
  --accent-surface:  rgba(255, 90, 95, 0.08);
  --accent-surface-hover: rgba(255, 90, 95, 0.14);

  /* Status colors */
  --success-bg:     #ECFDF5;
  --success-border: #A7F3D0;
  --success-text:   #166534;
  --warning-bg:     #FFF7ED;
  --warning-border: #FED7AA;
  --warning-text:   #78350F;
  --error-bg:       #FEF2F2;
  --error-border:   #FECACA;
  --error-text:     #B91C1C;

  /* Typography */
  --font-heading:   'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body:      'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Shadows */
  --shadow-sm:      0 2px 8px rgba(26, 18, 16, 0.06);
  --shadow-md:      0 6px 20px rgba(26, 18, 16, 0.08);
  --shadow-lg:      0 16px 40px rgba(26, 18, 16, 0.12);
  --shadow-glow:    0 0 20px rgba(255, 90, 95, 0.10);

  /* Radii */
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
}

/* --- GLOBAL RESETS --- */
* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-glow);
  text-decoration: underline;
}
img {
  max-width: 100%;
  height: auto;
}

/* --- TYPOGRAPHY --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1.3;
}

/* --- LAYOUT --- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: calc(100vh - 70px);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 14px 18px;
  margin-bottom: 16px;
}

/* --- HEADER / TOPBAR --- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  max-width: 1200px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand:hover {
  color: var(--accent-glow);
  text-decoration: none;
}
.brand-logo {
  height: 30px;
  width: auto;
  border-radius: 6px;
}
.nav-main {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}
.topnav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* --- SEARCH FIELD --- */
.nav-search {
  flex: 1;
  max-width: 320px;
}
.nav-search-form {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 4px 8px;
  transition: border-color 0.2s ease;
}
.nav-search-form:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.nav-search-form input {
  border: none;
  background: transparent;
  color: var(--text);
  flex: 1;
  padding: 6px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  outline: none;
}
.nav-search-form input::placeholder {
  color: var(--text-faint);
}
.nav-search-form .icon-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
}
.nav-search-form .icon-btn:hover {
  color: var(--text);
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 12px rgba(255, 90, 95, 0.2);
  text-decoration: none;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-muted);
}
.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

/* --- LANGUAGE SWITCHER --- */
.lang-switcher-compact {
  display: flex;
  gap: 2px;
  align-items: center;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.04em;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-faint);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  line-height: 1;
}
.lang-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.lang-btn.active {
  background: var(--text);
  color: var(--surface);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-faint);
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  transform: translateY(-1px);
}

/* --- HERO --- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr);
  gap: 20px;
  align-items: center;
  padding: 20px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}
.hero-content h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  font-family: var(--font-heading);
}
.hero-content p {
  margin: 0 0 12px;
  color: var(--text-muted);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hero-image {
  text-align: center;
}
.hero-image img {
  max-width: 180px;
  height: auto;
}
@media (max-width: 768px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .hero-image {
    order: -1;
  }
}

/* --- CATEGORY GRID --- */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.category-card {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .06s ease, border-color .15s ease;
}
.category-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.category-name {
  font-weight: 600;
  margin-bottom: 4px;
}
.category-meta {
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* --- DASHBOARD GRID (Admin / Member) --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.dashboard-card h3 {
  margin-top: 0;
  margin-bottom: 4px;
  font-family: var(--font-heading);
}
.stat {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-glow);
  font-family: var(--font-heading);
}
.stat-sub {
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* --- ANALYTICS CHARTS --- */
.analytics-chart-card {
  position: relative;
  height: 320px;
  padding: 16px;
}
.analytics-chart-card canvas {
  position: absolute;
  inset: 48px 16px 16px 16px;
  width: calc(100% - 32px) !important;
  height: calc(100% - 64px) !important;
}
.analytics-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  margin-bottom: 20px;
}
.analytics-map-card {
  padding: 16px;
}
.analytics-map {
  height: 260px;
  margin-bottom: 12px;
}
.mini-map-svg {
  width: 100%;
  height: 100%;
}
.analytics-side-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.analytics-side-col .card {
  flex: 1;
  padding: 14px;
  position: relative;
  min-height: 200px;
}
.analytics-side-col canvas {
  max-height: 180px;
}
.analytics-country-list {
  max-height: 200px;
  overflow-y: auto;
}
.country-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.85rem;
}
.country-flag {
  font-size: 1.1rem;
}
.country-name {
  min-width: 80px;
}
.country-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
}
.country-bar {
  height: 100%;
  background: var(--accent-glow, #3b82f6);
  border-radius: 3px;
}
.country-count {
  min-width: 40px;
  text-align: right;
  color: var(--text-muted);
}
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.analytics-table th,
.analytics-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.analytics-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.page-url {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analytics-heatmap {
  font-size: 0.75rem;
}
.heatmap-header,
.heatmap-row {
  display: flex;
  gap: 2px;
}
.heatmap-label {
  width: 32px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 4px;
  color: var(--text-muted);
}
.heatmap-hour {
  flex: 1;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.65rem;
}
.heatmap-cell {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 2px;
  min-height: 14px;
}
.analytics-period-select {
  margin-left: auto;
}

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

/* --- ITEM LISTS --- */
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 0;
}
.item-main {
  flex: 1;
  min-width: 0;
}
.item-title {
  font-weight: 600;
  color: var(--text);
}
.item-preview {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
.item-meta {
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-top: 2px;
}
.item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.reactions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
}

.emoji-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  transition: background 0.15s ease, transform 0.1s ease;
}
.emoji-btn i {
  font-size: 1.05rem;
}
.emoji-btn .count {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 14px;
  text-align: right;
}
.emoji-btn:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}

/* --- FOOTER --- */
footer, .site-footer {
  text-align: center;
  font-size: 0.8rem;
  padding: 16px 20px;
  max-width: 1200px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
}
.footer-toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.footer-toast.show {
  opacity: 1;
}

/* --- MODAL --- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 18, 16, 0.45);
  z-index: 100;
}
.modal[hidden] {
  display: none !important;
}
.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal h2 {
  margin-top: 0;
  font-family: var(--font-heading);
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.2rem;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text);
}

/* --- FORMS --- */
.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}
.form-group label {
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-glow);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-faint);
}
.form-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --- USER MENU DROPDOWN --- */
.user-menu {
  position: relative;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}
.avatar-pill {
  background: var(--accent);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
}
.user-name-short {
  color: var(--text-muted);
}
.user-menu-panel {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 180px;
}
.user-menu-panel a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  color: var(--text-muted);
  border-radius: 6px;
}
.user-menu-panel a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

/* --- LANGUAGE SELECTOR --- */
.lang-selector {
  position: relative;
}
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.lang-dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 140px;
  z-index: 1000;
}
.lang-option {
  display: block;
  padding: 6px 10px;
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 0.85rem;
  text-decoration: none;
}
.lang-option:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.lang-option.active {
  color: var(--accent);
  font-weight: 600;
}

/* --- AI MODERATION STRIKE --- */
.strike {
  text-decoration: line-through wavy var(--accent);
  opacity: 0.75;
}

/* --- FLASH MESSAGES --- */
.flash-container { margin-bottom: 12px; }
.alert {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}
.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

/* --- RESPONSIVE --- */
@media (max-width: 700px) {
  .topbar-inner {
    flex-wrap: wrap;
  }
  .nav-main {
    display: none;
  }
  .nav-search {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
  }
  .topnav-right {
    order: 2;
    margin-left: auto;
  }
  .user-name-short {
    display: none;
  }
  .lang-switcher-compact {
    display: none;
  }
}

/* --- PAGE HEADER --- */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.page-header-row h1 {
  margin: 0;
  font-family: var(--font-heading);
}

/* --- PILLS / BADGES --- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 6px;
}
.pill-status {
  margin-left: 6px;
  text-transform: lowercase;
}
.pill-status.pill-pending {
  background: var(--warning-bg);
  color: var(--warning-text);
}
.pill-status.pill-approved {
  background: var(--success-bg);
  color: var(--success-text);
}
.pill-status.pill-rejected {
  background: var(--error-bg);
  color: var(--error-text);
}

/* --- UTILITY --- */
.text-danger {
  color: var(--accent) !important;
}
.text-danger:hover {
  color: var(--accent-hover) !important;
}

/* --- WYSIWYG EDITOR --- */
.wysi-wrapper {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  margin-top: 4px;
}
.wysi-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 6px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.wysi-toolbar button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-faint);
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.wysi-toolbar button:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: translateY(-1px);
}
.wysi-toolbar button:active {
  transform: translateY(0);
}
.wysi-toolbar button i {
  font-size: 0.9rem;
}
.wysi-editor {
  min-height: 180px;
  padding: 10px 12px;
  background: var(--surface);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  outline: none;
}
.wysi-editor[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}
textarea.wysi {
  display: none;
}

/* --- NAV BUTTONS --- */
.btn-nav {
  background: transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.btn-nav:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}


/* --- PROFILE --- */
.profile-header {
  display: flex;
  gap: 12px;
  align-items: center;
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent-glow);
  font-family: var(--font-heading);
}
.profile-header-text h1 {
  margin: 0;
  font-size: 1.3rem;
  font-family: var(--font-heading);
}
.profile-email {
  font-size: 0.9rem;
  color: var(--text-faint);
}
.profile-role .pill {
  margin-left: 4px;
}
.profile-meta {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* --- STACKED FORMS --- */
.stack-form .form-group + .form-group {
  margin-top: 8px;
}
.stack-form .form-footer {
  margin-top: 10px;
}

.help-text {
  display: block;
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-top: 2px;
}

/* --- TABLES (generic dark treatment) --- */
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  font-size: 0.85rem;
}
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}
tr:hover td {
  background: var(--surface-2);
}

/* --- SELECTION / SCROLLBAR --- */
::selection {
  background: rgba(255, 90, 95, 0.2);
  color: var(--text);
}
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
