/* Global dark-mode baseline layer.
   Source of truth for shared dark tokens + core surfaces.
   Loaded before dark-fixes.css (which contains the final hotfix overrides). */

body.dark-mode {
  --rv-surface: #101728;
  --rv-surface-alt: #151f36;
  --rv-text: #f5f7ff;
  --rv-text-muted: #9fa7c7;
  --rv-border-subtle: #2a3248;
}

body.dark-mode .text-muted,
body.dark-mode .small.text-muted,
body.dark-mode .form-text,
body.dark-mode .form-help {
  color: var(--rv-text-muted) !important;
}

/* Common surfaces */
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .offcanvas,
body.dark-mode .dropdown-menu,
body.dark-mode .list-group-item,
body.dark-mode .accordion-item,
body.dark-mode .toast,
body.dark-mode .popover {
  background: var(--rv-surface) !important;
  color: var(--rv-text) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode .card-header,
body.dark-mode .card-footer,
body.dark-mode .modal-header,
body.dark-mode .modal-footer,
body.dark-mode .offcanvas-header,
body.dark-mode .offcanvas-body {
  background: var(--rv-surface-alt) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode .bg-white,
body.dark-mode .bg-light,
body.dark-mode .bg-light-subtle {
  background: var(--rv-surface-alt) !important;
}

/* Form controls */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode .input-group-text {
  background: #0f1627 !important;
  color: var(--rv-text) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode .form-control::placeholder {
  color: var(--rv-text-muted) !important;
  opacity: 1;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background: #0f1627 !important;
  color: var(--rv-text) !important;
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 0.18rem rgba(243, 145, 80, 0.22) !important;
}

/* Tables and separators */
body.dark-mode .table,
body.dark-mode .table > :not(caption) > * > * {
  color: var(--rv-text) !important;
  border-color: var(--rv-border-subtle) !important;
  background: transparent !important;
}

body.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(255, 255, 255, 0.025) !important;
}

body.dark-mode hr,
body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom,
body.dark-mode .border-start,
body.dark-mode .border-end {
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode .btn-close {
  filter: invert(1) grayscale(1);
}

/* Calendar */
body.dark-mode .calendar-shell {
  background: var(--rv-surface) !important;
  border-color: var(--rv-border-subtle) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34) !important;
}

body.dark-mode .calendar-shell-head {
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode #calendar .fc {
  --fc-border-color: #2a3248;
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: #151f36;
  --fc-list-event-hover-bg-color: #17223d;
  --fc-today-bg-color: rgba(243, 145, 80, 0.12);
  --fc-button-bg-color: #151f36;
  --fc-button-border-color: #2a3248;
  --fc-button-text-color: #e6ecff;
  --fc-button-hover-bg-color: #1c2a48;
  --fc-button-hover-border-color: #38507a;
  --fc-button-active-bg-color: #f39150;
  --fc-button-active-border-color: #f39150;
  --fc-button-active-text-color: #101728;
  --fc-event-bg-color: #f39150;
  --fc-event-border-color: #f39150;
}

body.dark-mode #calendar .fc .fc-toolbar-title,
body.dark-mode #calendar .fc .fc-col-header-cell-cushion,
body.dark-mode #calendar .fc .fc-daygrid-day-number {
  color: var(--rv-text) !important;
}

body.dark-mode #calendar .fc .fc-daygrid-day:hover {
  background: #18233d !important;
}

body.dark-mode #calendar .fc .fc-timegrid-slot-label,
body.dark-mode #calendar .fc .fc-timegrid-axis,
body.dark-mode #calendar .fc .fc-list-day-text,
body.dark-mode #calendar .fc .fc-list-day-side-text {
  color: var(--rv-text-muted) !important;
}

body.dark-mode #calendar .fc-theme-standard td,
body.dark-mode #calendar .fc-theme-standard th,
body.dark-mode #calendar .fc-theme-standard .fc-scrollgrid {
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode #eventModal .modal-content {
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode #eventModal .modal-header,
body.dark-mode #eventModal .modal-footer {
  background: var(--rv-surface-alt) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode #eventModal .modal-body {
  background: var(--rv-surface) !important;
}

body.dark-mode #eventModal #rem-list .badge {
  background: #151f36 !important;
  color: var(--rv-text) !important;
  border-color: var(--rv-border-subtle) !important;
}

/* Settings modal */
body.dark-mode #settingsModal .modal-content {
  background: var(--rv-surface) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode #settingsModal .modal-header,
body.dark-mode #settingsModal .modal-footer {
  background: var(--rv-surface-alt) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode #settingsModal .modal-body {
  background: var(--rv-surface) !important;
}

body.dark-mode #settingsModal .settings-tabs .nav-link:hover {
  color: var(--rv-text) !important;
  background: #1b2744 !important;
  border-color: #2f3f66 !important;
}

body.dark-mode #settingsModal .form-check-label,
body.dark-mode #settingsModal .form-label,
body.dark-mode #settingsModal .tab-pane p,
body.dark-mode #settingsModal .tab-pane strong {
  color: var(--rv-text) !important;
}

/* Landing page (lava.css) */
body.dark-mode .welcome-area {
  position: relative;
  isolation: isolate;
}

body.dark-mode .welcome-area::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,16,29,0.72) 0%, rgba(10,16,29,0.58) 100%);
  z-index: 0;
}

body.dark-mode .welcome-area .header-text {
  position: relative;
  z-index: 1;
}

body.dark-mode .welcome-area .header-text h1 {
  color: var(--rv-text) !important;
}

body.dark-mode .welcome-area .header-text p {
  color: var(--rv-text-muted) !important;
}

body.dark-mode #features,
body.dark-mode #membership-highlights,
body.dark-mode #testimonials,
body.dark-mode #memory,
body.dark-mode #journey-companion,
body.dark-mode #shared-journal,
body.dark-mode #shared-links,
body.dark-mode #memories-emotions {
  background: transparent !important;
}

body.dark-mode .mh-card {
  background: var(--rv-surface) !important;
  border: 1px solid var(--rv-border-subtle) !important;
  box-shadow: none !important;
}

body.dark-mode .mh-title,
body.dark-mode .mh-card h3,
body.dark-mode .mh-card h5,
body.dark-mode .tab-copy h3,
body.dark-mode .section-heading h2 {
  color: var(--rv-text) !important;
}

body.dark-mode .mh-text,
body.dark-mode .tab-copy p,
body.dark-mode .section-heading span {
  color: var(--rv-text-muted) !important;
}

body.dark-mode .lp-url {
  color: #8db7ff !important;
}

body.dark-mode .rv-home-navbar,
body.dark-mode .rv-home-mobile-menu {
  background: #121b31 !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode .rv-home-navbar .nav-link {
  color: var(--rv-text) !important;
}

body.dark-mode .rv-home-navbar .nav-link:hover {
  color: #ffffff !important;
}

body.dark-mode .rv-footer {
  background-color: #0f1627 !important;
  background-image: none !important;
}

body.dark-mode .rv-footer p,
body.dark-mode .rv-footer .small,
body.dark-mode .rv-footer .copyright,
body.dark-mode .rv-footer a {
  color: var(--rv-text-muted) !important;
}

body.dark-mode .rv-compliance-block {
  background: #0f1627 !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode .rv-compliance-card {
  background: var(--rv-surface) !important;
  border-color: var(--rv-border-subtle) !important;
  color: var(--rv-text) !important;
}

body.dark-mode .rv-compliance-card p {
  color: var(--rv-text-muted) !important;
}

body.dark-mode #glance {
  background: #0f1627 !important;
  box-shadow: none !important;
}

body.dark-mode #glance .nav-pills .nav-link {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--rv-text) !important;
}

body.dark-mode #glance .nav-pills .nav-link:hover,
body.dark-mode #glance .nav-pills .nav-link.active {
  background: var(--rv-surface) !important;
}

body.dark-mode #glance .glance-card,
body.dark-mode .duo-card {
  background: var(--rv-surface) !important;
  border: 1px solid var(--rv-border-subtle) !important;
  box-shadow: none !important;
}

body.dark-mode .duo-media,
body.dark-mode .duo-media--accent,
body.dark-mode .duo-media--avatars,
body.dark-mode .duo-media--map,
body.dark-mode .duo-media--links {
  background: var(--rv-surface-alt) !important;
}

body.dark-mode .chip,
body.dark-mode .mini-kpi,
body.dark-mode .pin {
  background: #0f1627 !important;
  border-color: var(--rv-border-subtle) !important;
  color: var(--rv-text) !important;
}

body.dark-mode .map-canvas::before {
  opacity: 0.16;
}

/* Auth pages (form-pack.css) */
body.dark-mode.auth-page .custom-form.auth-card {
  background: rgba(16, 23, 40, 0.92) !important;
  border-color: var(--rv-border-subtle) !important;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45) !important;
}

body.dark-mode.auth-page .auth-field .form-label,
body.dark-mode.auth-page .hero-title {
  color: var(--rv-text) !important;
}

body.dark-mode.auth-page .custom-form .form-control {
  background: #0f1627 !important;
  border-color: var(--rv-border-subtle) !important;
  color: var(--rv-text) !important;
}

body.dark-mode.auth-page .custom-form .form-control::placeholder {
  color: var(--rv-text-muted) !important;
}

body.dark-mode.auth-page .auth-divider {
  color: var(--rv-text-muted) !important;
}

body.dark-mode.auth-page .auth-divider::before,
body.dark-mode.auth-page .auth-divider::after {
  border-bottom-color: var(--rv-border-subtle) !important;
}

body.dark-mode.auth-page .auth-google-btn {
  background: #0f1627 !important;
  color: var(--rv-text) !important;
  border-color: var(--rv-border-subtle) !important;
}

body.dark-mode.auth-page .auth-google-btn:hover,
body.dark-mode.auth-page .auth-google-btn:focus {
  background: #18233d !important;
}
