/* SnapSides shared theme definitions.
   Pilot scope: Survey Maker pages only. Keep all colors in semantic tokens. */
:root {
  color-scheme: dark;
  --color-utility-button-border: #3b3f5a;
  --color-utility-button-background: #111827;
  --color-utility-button-background-alt: #374151;
  --color-utility-button-text: #ffffff;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-utility-button-border: #3b3f5a;
  --color-utility-button-background: #111827;
  --color-utility-button-background-alt: #374151;
  --color-utility-button-text: #ffffff;
  --color-background-glow-header-1: #161e3a;
  --color-background-glow-header-2: #080c16;
}

html[data-theme="light"] {
  color-scheme: light;

  /* Backgrounds and surfaces */
  --color-page-background: #f4f7fc;
  --color-page-background-alt: #eaf0f9;
  /*--color-page-background-deep: #e8eef8;*/
  /*--color-page-background-deep: linear-gradient(135deg, #eef3fb, #f2f7fe);*/
  /*--color-page-background-deep: linear-gradient(135deg, #f2f7fe, #eef3fb);*/
  /*--color-page-background-deep: #eef3fb;*/

  /*--color-page-background-deep: linear-gradient(135deg, #fbfcff, #f6f9fb);*/
  /*--color-page-background-deep: linear-gradient(135deg, #fbfcff, #f6f9fb);*/ 
  --color-page-background-deep: #f7f9fd;
  --color-surface: #ffffff;
  --color-surface-raised: #f7f9fd;
  --color-surface-elevated: #eef3fb;
  --color-surface-inset: rgba(255, 255, 255, 0.92);
  /*--color-background-glow-1: #e6edff;
  --color-background-glow-2: #f0eaff;*/
  --color-background-glow-1: #f3f5fb;
  --color-background-glow-2: #f6f5f8;
  /*--color-background-glow-header-1: #dde5f6;
  --color-background-glow-header-2: #e6e1f6;*/
  --color-background-glow-header-1: #eef2f9;
  --color-background-glow-header-2: #ffffff;
  /*--color-surface-overlay: rgba(255, 255, 255, 0.88);*/
  /*--color-surface-overlay: rgba(240, 244, 250, 0.75);*/
  --color-modal-surface: rgba(255, 255, 255, 0.98);

  /* Text */
  --color-text-primary: #172033;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-text-subtle: #64748b;
  --color-text-inverse: #ffffff;

  /* Brand and interaction */
  --color-primary: #2459d3;
  --color-primary-hover: #1d4ed8;
  --color-primary-active: #1e40af;
  --color-accent-purple: #6d28d9;
  --color-gradient-start: var(--color-accent-purple);
  --color-gradient-end: var(--color-primary);
  /*--color-primary-tint-soft: rgba(36, 89, 211, 0.08);*/
  --color-primary-tint-soft: rgba(213, 215, 220, 0.1);
  --color-primary-tint: rgba(36, 89, 211, 0.14);
  --color-primary-tint-border: rgba(36, 89, 211, 0.32);
  --color-focus-ring: rgba(36, 89, 211, 0.42);

  /* Borders and translucent surfaces */
  --color-border: #d5deeb;
  --color-border-strong: #aab8cc;
  --color-border-tint: rgba(15, 23, 42, 0.12);
  --color-surface-tint-soft: rgba(15, 23, 42, 0.03);
  --color-surface-tint: rgba(15, 23, 42, 0.055);
  --color-surface-tint-strong: rgba(15, 23, 42, 0.10);

  /* Status colors */
  --color-success: #047857;
  --color-success-background: rgba(4, 120, 87, 0.10);
  --color-success-text: #065f46;
  --color-warning: #b45309;
  --color-warning-background: rgba(180, 83, 9, 0.10);
  --color-warning-text: #92400e;
  --color-error: #b91c1c;
  --color-error-background: rgba(185, 28, 28, 0.09);
  --color-error-text: #991b1b;
  --color-info: #1d4ed8;
  --color-status-purple: #6d28d9;
  --color-status-purple-background: rgba(109, 40, 217, 0.10);
  --color-info-background: rgba(29, 78, 216, 0.10);

  /* Shadows and overlays */
  --color-overlay: rgba(15, 23, 42, 0.48);
  --color-overlay-strong: rgba(15, 23, 42, 0.64);
  --color-shadow: rgba(15, 23, 42, 0.12);
  --color-shadow-strong: rgba(15, 23, 42, 0.20);
  --color-neutral-dark: #111827;
  --color-neutral-dark-alt: #374151;
  --color-utility-button-border: transparent;
  --color-utility-button-background: var(--color-gradient-start);
  --color-utility-button-background-alt: var(--color-gradient-end);
  --color-utility-button-text: #ffffff;
}

/* These utility navigation buttons intentionally retain their own subtle outline. */
.btn-back,
.btn-sm[href="/index.html"],
a.btn[href*="logout.php"] {
  border-color: var(--color-utility-button-border);
  box-shadow: none;
}

/* Controls use readable foreground text on their theme-aware surfaces. */
html[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="light"] .survey-input,
html[data-theme="light"] .survey-textarea {
  color: var(--color-text-primary);
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}
html[data-theme="light"] .user-icon {
  fill: none;
}

html[data-theme="light"] #site-nav a:not(.active):not([aria-current="page"]),
html[data-theme="light"] .nav-link {
  color: var(--color-text-primary);
}
/* Light theme */
:root,
[data-theme="light"] {
    --color-notice-bg: #fff1f2;
}

/* Dark theme */
[data-theme="dark"] {
    --color-notice-bg: rgba(239, 68, 68, 0.1);
}
/* Accessible, fixed-position toggle; does not alter existing page markup. */
/* Theme toggle: compact header-style circular control */
.snapsides-theme-toggle {
  position: fixed;
  top: 15px;
  right: max(18px, calc((100vw - 1080px) / 2));
  bottom: auto;
  z-index: 2000;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  gap: 0;

  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-primary);

  box-shadow: 0 3px 12px var(--color-shadow-strong);

  font: inherit;
  font-size: 20px;
  line-height: 1;

  cursor: pointer;
  transition: background-color 0.18s ease,
              border-color 0.18s ease,
              transform 0.18s ease;
}

.snapsides-theme-toggle:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.snapsides-theme-toggle:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

@media (max-width: 480px) {
  .snapsides-theme-toggle {
    top: 12px;
    right: 12px;
    bottom: auto;
    width: 38px;
    height: 38px;
    min-height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .snapsides-theme-toggle {
    transition: none;
  }
}

html[data-theme="light"] #site-nav a:not(.active):not([aria-current="page"]):hover,
html[data-theme="light"] nav a:hover {
  color: var(--color-primary) !important;
}


/* Light-theme navigation and utility-control contrast fixes.
   Keep existing IDs/classes and preserve the dark theme appearance. */
html[data-theme="light"] #site-nav .dropdown-toggle,
html[data-theme="light"] #site-nav .nav-link,
html[data-theme="light"] #nav-auth-container .nav-link {
  color: var(--color-text-primary);
}

html[data-theme="light"] #site-nav .dropdown-toggle:hover,
html[data-theme="light"] #site-nav .dropdown-toggle:focus-visible {
  color: var(--color-primary);
}

html[data-theme="light"] #site-nav .dropdown-toggle.active {
  color: var(--color-text-inverse) !important;
}

html[data-theme="light"] .dropdown-menu {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: 0 8px 32px var(--color-shadow-strong);
}

html[data-theme="light"] .dropdown-menu a:not(.active) {
  color: var(--color-text-primary);
}

html[data-theme="light"] .dropdown-menu a:not(.active):hover {
  color: var(--color-primary) !important;
  background: var(--color-primary-tint-soft);
}

html[data-theme="light"] .dropdown-nested-header,
html[data-theme="light"] .dropdown-title {
  color: var(--color-text-primary);
}

html[data-theme="light"] .dropdown-title,
html[data-theme="light"] .nested-arrow {
  color: var(--color-primary);
}

html[data-theme="light"] a.btn[href*="logout.php"] {
  background: linear-gradient(135deg,
      var(--color-utility-button-background),
      var(--color-utility-button-background-alt));
  color: var(--color-utility-button-text) !important;
  border-color: var(--color-utility-button-border);
  box-shadow: none;
}

html[data-theme="light"] a.btn[href*="logout.php"]:hover {
  color: var(--color-utility-button-text) !important;
  border-color: var(--color-utility-button-border);
  box-shadow: none;
}

/* Back and Home: minimal text-style navigation */

html[data-theme="dark"] .btn-back,
html[data-theme="dark"] .btn-sm[href="/index.html"],
html[data-theme="light"] .btn-back,
html[data-theme="light"] .btn-sm[href="/index.html"] {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: var(--color-text-primary) !important;
    text-decoration: none !important;
    padding: 4px 6px;
    transition: color 0.18s ease;
}

/* Dark mode: soft, readable grey */
html[data-theme="dark"] .btn-back,
html[data-theme="dark"] .btn-sm[href="/index.html"] {
    color: #aab3c5 !important;
}

/* Light mode: dark slate */
html[data-theme="light"] .btn-back,
html[data-theme="light"] .btn-sm[href="/index.html"] {
    color: #273449 !important;
}

/* Subtle hover: color change only, no underline */
html[data-theme="dark"] .btn-back:hover,
html[data-theme="dark"] .btn-sm[href="/index.html"]:hover,
html[data-theme="light"] .btn-back:hover,
html[data-theme="light"] .btn-sm[href="/index.html"]:hover {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: var(--color-primary) !important;
    text-decoration: none !important;
}

/* Preserve keyboard accessibility */
html[data-theme="dark"] .btn-back:focus-visible,
html[data-theme="dark"] .btn-sm[href="/index.html"]:focus-visible,
html[data-theme="light"] .btn-back:focus-visible,
html[data-theme="light"] .btn-sm[href="/index.html"]:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 3px;
}


/* ============================================================
   Survey Maker pilot: final light/dark control refinements
   Keep these overrides centralized in theme.css.
   ============================================================ */

/* Use the same light native checkbox/radio appearance in both themes.
   The accent remains tied to the shared brand color. */
html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"],
html[data-theme="light"] input[type="checkbox"],
html[data-theme="light"] input[type="radio"] {
  color-scheme: light;
  accent-color: var(--color-primary);
}

/* Create / Take / My Surveys tabs: avoid the white hover flash. */
.mode-selector .mode-btn {
  color: var(--color-text-muted);
}

html[data-theme="light"] .mode-selector .mode-btn:hover:not(.active) {
  color: var(--color-text-primary) !important;
  background: var(--color-surface-elevated);
}

.mode-selector .mode-btn.active,
.mode-selector .mode-btn.active:hover {
  color: #ffffff !important;
  background: linear-gradient(
    135deg,
    var(--color-gradient-start),
    var(--color-gradient-end)
  );
  border-bottom-color: transparent;
}

/* My Surveys horizontal scroll arrows: use a soft theme-aware surface. */
html[data-theme="light"] .scroll-arrow-horizontal {
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
}

/* Selected status filters: maintain white text on the brand gradient. */
.status-filter a.active,
.status-filter a.active:hover {
  color: #ffffff !important;
}

/* Fix embedded Survey Maker tab hover in light mode */
html[data-theme="light"] .mode-tabs .mode-tab:not(.active):hover {
    color: #273449 !important;
    -webkit-text-fill-color: #273449 !important;
    background: #ffffff !important;
    border-color: var(--color-primary) !important;
}

/* Login button text */
html[data-theme="light"] .btn-login {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* Match Search and Refresh buttons to inactive status filters */
.btn-search,
.btn-refresh {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text-primary) !important;
}

/* Matching hover effect */
.btn-search:hover,
.btn-refresh:hover {
    background: var(--color-surface) !important;
    border-color: var(--color-primary) !important;
}

/* ============================================================
   MOBILE NAVIGATION — MENU LEFT, LOGO NEXT, THEME RIGHT
   ============================================================ */

@media (max-width: 768px) {

    header .navbar {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }

    /* Hamburger comes first */
    header .navbar .nav-toggle {
        order: 0;
        flex: 0 0 auto;
        margin: 0;
        position: relative;
        z-index: 10001;
    }

    /* Logo comes immediately after hamburger */
    header .navbar .brand {
        order: 1;
        flex: 0 1 auto;
        min-width: 0;
        margin: 0;
    }

    /* Navigation container should not occupy header space */
    header .navbar #nav-container {
        order: 2;
        flex: 0 0 0;
        width: 0;
        min-width: 0;
    }

    /* Theme toggle stays at the far right */
    .snapsides-theme-toggle {
        position: fixed;
        top: 15px;
        right: 12px;
        bottom: auto;
        z-index: 10002;
    }
}

/* ============================================================
   Quiz Maker: light-mode content panels
   ============================================================ */

html[data-theme="light"] .content-block,
html[data-theme="light"] .other-sections,
html[data-theme="light"] .differentiators {
    background: var(--color-page-background-deep) !important;
    color: var(--color-text-primary);
    border-color: var(--color-border) !important;
}

html[data-theme="light"] .content-block h2,
html[data-theme="light"] .content-block h3,
html[data-theme="light"] .content-block p,
html[data-theme="light"] .content-block li,
html[data-theme="light"] .other-sections h2,
html[data-theme="light"] .other-sections h3,
html[data-theme="light"] .other-sections p,
html[data-theme="light"] .features-section h2,
html[data-theme="light"] .features-section h3,
html[data-theme="light"] .features-section p,
html[data-theme="light"] .features-section li,
html[data-theme="light"] .differentiators h2,
html[data-theme="light"] .differentiators h3,
html[data-theme="light"] .differentiators p,
html[data-theme="light"] .differentiators li {
    color: var(--color-text-primary);
}

/* Standalone My Quizzes / My Surveys pages.
   Keep embedded tool views untouched; their parent page already supplies layout. */
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .survey-card {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-title,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-header,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .survey-card h3,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .survey-card strong {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-details,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-details a,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .survey-card p,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .survey-card .survey-meta {
  color: var(--color-text-secondary);
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-actions button:disabled,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-actions a[aria-disabled="true"],
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .survey-action-btn:disabled {
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  opacity: 0.75;
}

html[data-theme="dark"] .standalone-tools-list .pill-nav a,
html[data-theme="dark"] .standalone-tools-list .search-section,
html[data-theme="dark"] .standalone-tools-list .search-section input {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .standalone-tools-list .pill-nav a {
  border-color: var(--color-border);
  background: var(--color-surface);
}

html[data-theme="dark"] .standalone-tools-list .pill-nav a:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}


/* Standalone dashboards: enforce dark-theme contrast against legacy card rules.
   These selectors are intentionally scoped so embedded dashboards are unaffected. */
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card {
  background-color: #111827 !important;
  color: #e5e7eb !important;
  border-color: #374151 !important;
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .quiz-title,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .quiz-header,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card h3,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card h4 {
  color: #f3f4f6 !important;
  -webkit-text-fill-color: #f3f4f6 !important;
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .quiz-details,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .quiz-details *,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .quiz-id,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .quiz-meta,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .survey-access-info {
  color: #cbd5e1 !important;
  -webkit-text-fill-color: #cbd5e1 !important;
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card button:disabled,
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card a[aria-disabled="true"],
html[data-theme="dark"] .standalone-tools-list .my-quizzes-container .quiz-card .survey-action-btn:disabled {
  background: #1f2937 !important;
  color: #9ca3af !important;
  -webkit-text-fill-color: #9ca3af !important;
  border-color: #374151 !important;
  opacity: 1 !important;
}

html[data-theme="dark"] .standalone-tools-list .pill-nav a,
html[data-theme="dark"] .standalone-tools-list .pill-nav a:visited {
  color: #e5e7eb !important;
  -webkit-text-fill-color: #e5e7eb !important;
}

html[data-theme="dark"] .standalone-tools-list .hero .search-input {
  color: #e5e7eb !important;
  -webkit-text-fill-color: #e5e7eb !important;
}

html[data-theme="dark"] .standalone-tools-list .my-quizzes-container{
  color: #e5e7eb !important;
  -webkit-text-fill-color: #e5e7eb !important;
}
/* Toast notifications — consistent in light and dark themes */
.toast-notification {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6) !important;
  color: #ffffff !important;
}

.loading-overlay *,
.toast-notification * {
  color: #ffffff !important;
}

/* ============================================================
   Quiz / Survey toast and loading feedback: fixed brand colors
   Keep the loading overlay itself translucent; style its capsule.
   ============================================================ */
html[data-theme="light"] .toast-notification,
html[data-theme="dark"] .toast-notification {
  background: linear-gradient(135deg, #6a11cb, #2575fc) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

html[data-theme="light"] .toast-notification.error,
html[data-theme="dark"] .toast-notification.error,
html[data-theme="light"] .toast-notification.warning,
html[data-theme="dark"] .toast-notification.warning {
  background: linear-gradient(135deg, #6a11cb, #2575fc) !important;
}

html[data-theme="light"] .toast-notification *,
html[data-theme="dark"] .toast-notification * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

html[data-theme="light"] .loading-overlay,
html[data-theme="dark"] .loading-overlay {
  /* Preserve translucent full-screen scrim and blur from core CSS. */
  color: #ffffff !important;
}

html[data-theme="light"] .loading-capsule,
html[data-theme="dark"] .loading-capsule {
  background: linear-gradient(135deg, #6a11cb, #2575fc) !important;
  color: #ffffff !important;
}

html[data-theme="light"] .loading-text,
html[data-theme="dark"] .loading-text,
html[data-theme="light"] .loading-text *,
html[data-theme="dark"] .loading-text * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background: none !important;
  background-image: none !important;
}
