/* assets/css/main.css - Core Design System & Responsive Heritage Styling */

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

:root {
  /* Heritage Dark Theme (Default) */
  --bg-primary: #0a0e17;
  --bg-secondary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #243247;
  --bg-glass: rgba(15, 23, 42, 0.78);
  --bg-glass-card: rgba(30, 41, 59, 0.7);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-gold: rgba(217, 119, 6, 0.45);
  --border-gold-bright: #d97706;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-gold: #fbbf24;

  --accent-gold: #d97706;
  --accent-gold-hover: #b45309;
  --accent-gold-light: #fef3c7;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  --font-serif: 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-editorial: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.65);
  --shadow-gold: 0 0 20px rgba(217, 119, 6, 0.25);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  /* Luminous Architectural Slate & Bronze Palette */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-glass-card: #ffffff;

  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-gold: rgba(217, 119, 6, 0.35);
  --border-gold-bright: #d97706;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-gold: #b45309;

  --accent-gold: #d97706;
  --accent-gold-hover: #b45309;
  --accent-gold-light: #fef3c7;
  --accent-blue: #2563eb;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-purple: #7c3aed;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 36px -4px rgba(15, 23, 42, 0.12), 0 6px 14px -3px rgba(15, 23, 42, 0.06);
  --shadow-gold: 0 6px 20px -2px rgba(217, 119, 6, 0.2);
}

[data-theme="light"] .brand-title {
  background: linear-gradient(135deg, #78350f 0%, #b45309 45%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

[data-theme="light"] .brand-subtitle {
  color: #64748b;
  font-weight: 500;
}

[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .nav-link {
  color: #475569;
}

[data-theme="light"] .nav-link:hover {
  color: #0f172a;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .nav-link.active {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
  font-weight: 600;
}

[data-theme="light"] .btn-secondary {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .btn-secondary:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

[data-theme="light"] .btn-outline {
  border-color: #cbd5e1;
  color: #334155;
}

[data-theme="light"] .btn-outline:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Reset & Base Elements */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  letter-spacing: 0.5px;
  line-height: 1.25;
}

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

a:hover {
  color: var(--text-gold);
}

/* Modern App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-gold);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #d97706, #78350f);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: var(--shadow-gold);
  border: 1px solid rgba(254, 240, 138, 0.4);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #fef3c7 40%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Navigation Links */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: rgba(217, 119, 6, 0.15);
  border: 1px solid var(--border-gold);
}

/* Header Utilities & Role Bar */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.role-switcher-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
}

.role-tag {
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.role-tag.admin {
  background: rgba(217, 119, 6, 0.25);
  color: #fbbf24;
  border: 1px solid #d97706;
}

.role-tag.contributor {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border: 1px solid #3b82f6;
}

.role-tag.viewer {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  border: 1px solid #10b981;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-gold);
  color: var(--text-gold);
}

/* Common Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
  border: 1px solid rgba(254, 240, 138, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-gold);
  color: var(--text-gold);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Privacy Alert Banner */
.privacy-banner {
  background: rgba(16, 185, 129, 0.12);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #6ee7b7;
}

.privacy-banner.masked {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.3);
  color: #fde68a;
}

/* Modal Windows */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-gold);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-gold-bright);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
}

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

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success { border-color: var(--accent-emerald); }
.toast.error { border-color: var(--accent-rose); }

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =====================================================
   RESPONSIVE — Mobile-first breakpoints
   ===================================================== */

/* ── 768px: Tablet & smaller phones ── */
@media (max-width: 768px) {

  /* Header */
  .app-header {
    padding: 0.55rem 0.9rem;
    gap: 0.5rem;
  }

  .brand-subtitle {
    display: none;
  }

  /* Hide desktop nav, show hamburger */
  .header-nav {
    display: none;
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  /* Role switcher — hide in header, shown in drawer */
  .role-switcher-badge {
    display: none;
  }

  /* Header actions: tighten up */
  .header-actions {
    gap: 0.5rem;
  }

  /* Privacy banner — stack vertically */
  .privacy-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
  }

  /* Modals — full-width, near full-height */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
  }

  .modal-header {
    padding: 1rem 1.1rem;
  }

  .modal-body {
    padding: 1rem 1.1rem;
  }

  .modal-footer {
    padding: 0.85rem 1.1rem;
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* Forms — single column */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Buttons — ensure min touch target */
  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
  }

  /* Toast — top-center on mobile */
  #toast-container {
    bottom: auto;
    top: 1rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }

  .toast {
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
  }
}

/* ── 480px: Small phones ── */
@media (max-width: 480px) {

  .brand-title {
    font-size: 1rem;
    letter-spacing: 0.5px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
  }
}

/* ── Mobile Navigation Drawer ── */
.mobile-nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 0;
  transform: translateX(-100%);
  transition: transform var(--transition-normal);
  overflow-y: auto;
}

.mobile-nav-drawer.active {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-gold);
  flex-shrink: 0;
}

.mobile-drawer-close {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.mobile-drawer-close:hover {
  border-color: var(--border-gold);
  color: var(--text-gold);
}

.mobile-drawer-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 0.25rem;
  flex: 1;
}

.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.mobile-drawer-link:hover,
.mobile-drawer-link.active {
  color: var(--text-primary);
  background: rgba(217, 119, 6, 0.15);
  border-color: var(--border-gold);
}

.mobile-drawer-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.5rem 0;
}

.mobile-drawer-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.mobile-drawer-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

/* Role switcher inside drawer */
.mobile-drawer-role {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
