/* =============================================================================
   Custom Theme & Components for Flask App Modernization
   -----------------------------------------------------------------------------
   This file defines CSS variables for light/dark mode, Bootstrap overrides,
   component polish, and utility classes. It is layered above Bootstrap and
   before style.css. DO NOT RENAME IDs, class hooks, or data-* attributes.
   ============================================================================ */

/*------------------------------------------------------------------------------
  1. Theme Tokens (Light & Dark)
------------------------------------------------------------------------------*/
:root {
  --brand-primary: #2563eb;
  --accent: #fbbf24;
  --bg: #f8fafc;
  --bg-main: #f8fafc; /* used by JS for theme-color sync */
  --text: #222b45;
  --muted: #64748b;
  --border: #e5e7eb;
  --card-bg: #fff;
  --shadow: 0 1px 8px 0 rgba(30,34,90,0.08);
  --shadow-sm: 0 1px 2px 0 rgba(30,34,90,0.08);

  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 1rem;
  --spacing-4: 1.5rem;
  --spacing-5: 2.5rem;

  --radius-sm: 0.375rem;
  --radius: 0.75rem;
  --radius-lg: 1.25rem;
  --focus-ring: 0 0 0 3px rgba(37,99,235,0.2);

  --navbar-height: 44px; /* smaller navbar */
  --logo-height: 22px;   /* much smaller logo for compact navbar */

  /* mobile ergonomics */
  --tap-size: 44px;
}

[data-theme="dark"],
html.dark-mode-preload {
  --brand-primary: #60a5fa;
  --accent: #facc15;
  --bg: #181f2a;
  --bg-main: #181f2a; /* used by JS for theme-color sync */
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #334155;
  --card-bg: #232d3b;
  --shadow: 0 1px 8px 0 rgba(20,25,40,0.18);
  --shadow-sm: 0 1px 2px 0 rgba(20,25,40,0.18);
}

/* Improve contrast for list groups and active items in dark mode */
[data-theme="dark"] .list-group-item,
html.dark-mode-preload .list-group-item {
  background-color: #1f2735 !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .list-group-item.active,
html.dark-mode-preload .list-group-item.active {
  background-color: #0f172a !important; /* darker highlight */
  color: #e6f0ff !important;
  border-color: #1e293b !important;
}
[data-theme="dark"] .bg-light,
html.dark-mode-preload .bg-light {
  background-color: #1f2735 !important;
  color: var(--text) !important;
}

/*------------------------------------------------------------------------------
  2. Bootstrap Variable Overrides & Body
------------------------------------------------------------------------------*/
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  min-height: 100vh;
}

a {
  color: var(--brand-primary);
}
a:hover {
  color: #1747b1;
  text-decoration: underline;
}

/*------------------------------------------------------------------------------
  3. Navbar Styles
------------------------------------------------------------------------------*/
.navbar {
  min-height: var(--navbar-height);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg) !important;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border);
  padding-top: .15rem;
  padding-bottom: .15rem;
}
.navbar .navbar-brand img.logo-img {
  max-height: var(--logo-height);
}
.navbar .nav-link {
  padding: .35rem .6rem;
  border-radius: .5rem;
}
.navbar .nav-link i {
  font-size: 1.05rem;
}

/* Icon-only navbar buttons */
.navbar .nav-link.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-right: .25rem;
  background: transparent;
}
.navbar .nav-link.icon-btn i {
  font-size: 1.05rem;
  line-height: 1;
}
.navbar .nav-link.icon-btn:hover {
  background: rgba(37,99,235,0.08);
}
[data-theme="dark"] .navbar .nav-link.icon-btn:hover,
html.dark-mode-preload .navbar .nav-link.icon-btn:hover {
  background: rgba(96,165,250,0.15);
}

/* Improve navbar usability on mobile */
@media (max-width: 576px) {
  .navbar .navbar-text {
    font-size: .85rem;
  }
  .navbar .nav-link {
    padding-top: .5rem;
    padding-bottom: .5rem;
    min-height: var(--tap-size);
  }
  .navbar .navbar-toggler {
    min-height: var(--tap-size);
    min-width: var(--tap-size);
  }
}

.main-page-logo {
    max-height: 225px; /* Increased from 150px */
    width: auto;
    margin-bottom: 1rem;
}
.unap-logo-text {
  font-weight: 600;
  font-size: 1.40rem;
  color: #263238;
  margin-left: 0.5rem;
  letter-spacing: 0.04em;
}

/* Style for the admin debug bar */
#admin-debug-bar {
  position: sticky;
  top: var(--navbar-height);
  z-index: 1050;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.97rem;
  padding: 0.35em 1.25em;
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin-bottom: 0.5em;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1.5em;
}
.navbar .nav-link.active,
.navbar .nav-link[aria-current="page"] {
  color: var(--brand-primary) !important;
  font-weight: 600;
  border-bottom: 2px solid var(--brand-primary);
  background: transparent;
}
.navbar .nav-link {
  color: var(--text);
  transition: color 0.18s;
  margin-right: 0.25rem;
}
.navbar .nav-link:hover {
  color: var(--brand-primary);
  background: rgba(37,99,235,0.08);
}
.navbar .navbar-toggler {
  border-radius: var(--radius-sm);
}

/*------------------------------------------------------------------------------
  4. Card Styles
------------------------------------------------------------------------------*/
.page-card, .card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: var(--spacing-4);
  transition: background 0.2s, box-shadow 0.2s;
}

.card-header {
  background: none;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1.1rem;
}
.card-body {
  padding: var(--spacing-3);
}
.page-card {
  padding: var(--spacing-4) var(--spacing-4) var(--spacing-3) var(--spacing-4);
}

/*------------------------------------------------------------------------------
  5. Table Styles
------------------------------------------------------------------------------*/
.table {
  background: var(--card-bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0;
}
.table thead th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.97rem;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table-striped > tbody > tr:nth-of-type(odd) {
  background: #f6f8fa;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd),
html.dark-mode-preload .table-striped > tbody > tr:nth-of-type(odd) {
  background: #20293b;
}
.table-hover > tbody > tr:hover {
  background: #e6f0ff;
}
[data-theme="dark"] .table-hover > tbody > tr:hover,
html.dark-mode-preload .table-hover > tbody > tr:hover {
  background: #24304a;
}
.table-sm td, .table-sm th {
  padding: 0.45rem 0.55rem;
}
.sticky-header thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

/* Responsive table container */
.table-responsive {
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-3);
  box-shadow: none;
  background: none;
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
  scroll-snap-type: x proximity; /* hint for horizontal scroll */
}
.table-responsive::-webkit-scrollbar {
  height: 8px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.15);
  border-radius: 8px;
}

/*------------------------------------------------------------------------------
  6. Form Styles
------------------------------------------------------------------------------*/
.form-label {
  font-weight: 500;
  color: var(--muted);
  font-size: 1rem;
}
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  transition: box-shadow 0.2s, border-color 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--focus-ring);
  outline: none;
}
.form-control::placeholder {
  color: var(--muted);
  opacity: 1;
}
.form-check-input:focus {
  box-shadow: var(--focus-ring);
}
.form-check-label {
  margin-left: 0.3em;
}
.input-group-text {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 1rem;
}

/*------------------------------------------------------------------------------
  7. Button Styles
------------------------------------------------------------------------------*/
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background 0.16s, color 0.16s, border 0.14s;
  box-shadow: none;
}
.btn-primary, .btn-primary:focus {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-primary:hover, .btn-primary:active {
  background: #1747b1;
  border-color: #1747b1;
}
.btn-outline-secondary, .btn-outline-secondary:focus {
  border-color: var(--muted);
  color: var(--muted);
}
.btn-outline-secondary:hover, .btn-outline-secondary:active {
  background: var(--muted);
  color: #fff;
}
.btn-success { background: #22c55e; border-color: #22c55e; }
.btn-success:hover { background: #16a34a; border-color: #16a34a; }
.btn-warning { background: #fbbf24; border-color: #fbbf24; color: #222b45; }
.btn-warning:hover { background: #f59e42; border-color: #f59e42; }
.btn-danger { background: #ef4444; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-group > .btn {
  margin-right: 0.33em;
}
.btn-group > .btn:last-child {
  margin-right: 0;
}
.btn:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Full-width on mobile */
@media (max-width: 576px) {
  .btn.w-100, .btn-group .btn {
    width: 100%;
    margin-bottom: var(--spacing-2);
  }
}

/*------------------------------------------------------------------------------
  8. Loading Overlay & Spinner (moved from inline)
------------------------------------------------------------------------------*/
#loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(245, 247, 255, 0.70);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
}
#loading-overlay.show { display: flex; }
[data-theme="dark"] #loading-overlay,
html.dark-mode-preload #loading-overlay {
  background: rgba(24, 31, 42, 0.88);
}
.spinner-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  border: 4px solid var(--border);
  border-top: 4px solid var(--brand-primary);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% { transform: rotate(360deg);}
}
.heartbeat {
  animation: heartbeat 1.1s infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1);}
  15% { transform: scale(1.16);}
  30% { transform: scale(0.92);}
  45% { transform: scale(1.12);}
  60% { transform: scale(0.95);}
  75% { transform: scale(1.06);}
}

/*------------------------------------------------------------------------------
  9. Utilities
------------------------------------------------------------------------------*/
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--spacing-2);
  color: var(--brand-primary);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-3) 0;
  color: var(--muted);
  text-align: center;
}
.empty-state .fa, .empty-state .fas, .empty-state .fa-solid {
  font-size: 2.2rem;
  margin-bottom: 0.4em;
  color: var(--brand-primary);
}
.content-wrapper-animated {
  animation: fadeInUp 0.5s cubic-bezier(.4,0,.2,1);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px);}
  to { opacity: 1; transform: none;}
}



/* Responsive adjustments */
@media (max-width: 992px) {
  .navbar {
    min-height: 44px;
  }
  .section-title {
    font-size: 1.1rem;
  }
  .page-card, .card {
    padding: var(--spacing-2);
  }
}

/* Sticky table tools on mobile */
@media (max-width: 576px) {
  .table-tools {
    position: static;
    top: var(--navbar-height);
    z-index: 1020;
    background: var(--bg);
    padding: .5rem .25rem;
    border-bottom: 1px solid var(--border);
  }
  #admin-debug-bar + .container .table-tools {
    top: calc(var(--navbar-height) + 36px);
  }
  .table-tools .btn,
  .table-tools .form-control {
    min-height: var(--tap-size);
  }
}

/* === Genie Modern Table Copy & Context Menu Enhancements === */

/* Table sticky headers */
.table-sticky-header thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--bs-body-bg, #fff);
    transition: background .15s;
}

/* Copy bubble */
.copy-bubble {
    position: absolute;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
    background: var(--bs-emphasis-color, #222);
    color: var(--bs-body-bg, #fff);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -100%);
    transition: opacity .15s ease, transform .15s ease;
    z-index: 2001;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.copy-bubble.show {
    opacity: 1;
    transform: translate(-50%, -120%);
}

/* Context menu styles */
.context-menu {
    position: fixed;
    z-index: 2000;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #222);
    border: 1px solid rgba(0,0,0,.1);
    border-radius: .375rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    min-width: 180px;
    overflow: hidden;
    font-size: .97rem;
}
.context-menu .item {
    padding: .4rem .75rem;
    cursor: pointer;
    transition: background .12s;
}
.context-menu .item:hover,
.context-menu .item:focus {
    background: rgba(0,0,0,.06);
    outline: none;
}

/* Table compact density */
.table-compact td, .table-compact th {
    padding-top: .25rem;
    padding-bottom: .25rem;
}

/* Coachmark for copy */
.coachmark-copy {
    position: sticky;
    top: 0;
    z-index: 3;
    margin-bottom: .5rem;
    background: var(--bs-info-bg-subtle, #e7f3ff);
    color: var(--bs-info-text, #0c5460);
    border: 1px solid var(--bs-info-border-subtle, #b8daff);
    border-radius: .375rem;
    padding: .35rem .5rem;
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    box-shadow: 0 2px 8px rgba(7,77,139,.05);
}
.coachmark-copy .close {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 1.2em;
    opacity: .7;
    cursor: pointer;
}
.coachmark-copy .close:hover { opacity: 1; }

/* Table row hover for modern look */
.table tbody tr:hover {
    background: var(--bs-table-hover-bg, #f8f9fa);
    transition: background .14s;
}



/* Modern cards/containers spacing */
.mt-4, .container.mt-4, .content-wrapper-animated {
    margin-top: 1.5rem !important;
}

/* Dark mode contrast fixes for badges/alerts with light backgrounds */
body.dark-mode .badge.bg-success,
[data-theme="dark"] .badge.bg-success,
html.dark-mode-preload .badge.bg-success {
    background-color: #166534 !important; /* darker emerald */
    color: #e6ffed !important;
}
body.dark-mode .badge.bg-warning,
[data-theme="dark"] .badge.bg-warning,
html.dark-mode-preload .badge.bg-warning {
    background-color: #a16207 !important; /* darker amber */
    color: #111827 !important; /* force dark text for contrast */
}
body.dark-mode .badge.bg-info,
[data-theme="dark"] .badge.bg-info,
html.dark-mode-preload .badge.bg-info {
    background-color: #075985 !important; /* darker cyan-blue */
    color: #e0f2fe !important;
}
body.dark-mode .badge.bg-light,
[data-theme="dark"] .badge.bg-light,
html.dark-mode-preload .badge.bg-light {
    background-color: #cbd5e1 !important; /* slate-300 */
    color: #0f172a !important; /* slate-900 */
    border: 1px solid #94a3b8 !important;
}
/* Extend badge contrast to all contextual variants */
body.dark-mode .badge.bg-primary,
[data-theme="dark"] .badge.bg-primary,
html.dark-mode-preload .badge.bg-primary {
    background-color: #1d4ed8 !important; /* blue-700 */
    color: #e6f0ff !important;
}
body.dark-mode .badge.bg-secondary,
[data-theme="dark"] .badge.bg-secondary,
html.dark-mode-preload .badge.bg-secondary {
    background-color: #475569 !important; /* slate-600 */
    color: #e2e8f0 !important;
}
body.dark-mode .badge.bg-danger,
[data-theme="dark"] .badge.bg-danger,
html.dark-mode-preload .badge.bg-danger {
    background-color: #991b1b !important; /* red-800 */
    color: #ffe5e9 !important;
}
body.dark-mode .badge.bg-dark,
[data-theme="dark"] .badge.bg-dark,
html.dark-mode-preload .badge.bg-dark {
    background-color: #1f2937 !important; /* gray-800 */
    color: #f1f5f9 !important;
}

body.dark-mode .alert-success,
[data-theme="dark"] .alert-success,
html.dark-mode-preload .alert-success {
    background-color: #0f3b26 !important;
    color: #d1fae5 !important;
    border-color: #14532d !important;
}
body.dark-mode .alert-danger,
[data-theme="dark"] .alert-danger,
html.dark-mode-preload .alert-danger {
    background-color: #3f1014 !important;
    color: #ffe5e9 !important;
    border-color: #7f1d1d !important;
}
body.dark-mode .alert-warning,
[data-theme="dark"] .alert-warning,
html.dark-mode-preload .alert-warning {
    background-color: #3b2a03 !important;
    color: #fff4c2 !important;
    border-color: #a16207 !important;
}
body.dark-mode .alert-info,
[data-theme="dark"] .alert-info,
html.dark-mode-preload .alert-info {
    background-color: #0a2a3a !important;
    color: #dff7ff !important;
    border-color: #075985 !important;
}
body.dark-mode .alert-primary,
[data-theme="dark"] .alert-primary,
html.dark-mode-preload .alert-primary {
    background-color: #12213f !important;
    color: #e6f0ff !important;
    border-color: #1d4ed8 !important;
}
body.dark-mode .alert-secondary,
[data-theme="dark"] .alert-secondary,
html.dark-mode-preload .alert-secondary {
    background-color: #1f2732 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
body.dark-mode .alert-dark,
[data-theme="dark"] .alert-dark,
html.dark-mode-preload .alert-dark {
    background-color: #0b1220 !important;
    color: #f1f5f9 !important;
    border-color: #111827 !important;
}

/* List-group contextual items */
body.dark-mode .list-group-item-success,
[data-theme="dark"] .list-group-item-success,
html.dark-mode-preload .list-group-item-success {
    background-color: #0f3b26 !important;
    color: #d1fae5 !important;
}
body.dark-mode .list-group-item-danger,
[data-theme="dark"] .list-group-item-danger,
html.dark-mode-preload .list-group-item-danger {
    background-color: #3f1014 !important;
    color: #ffe5e9 !important;
}
body.dark-mode .list-group-item-warning,
[data-theme="dark"] .list-group-item-warning,
html.dark-mode-preload .list-group-item-warning {
    background-color: #3b2a03 !important;
    color: #fff4c2 !important;
}
body.dark-mode .list-group-item-info,
[data-theme="dark"] .list-group-item-info,
html.dark-mode-preload .list-group-item-info {
    background-color: #0a2a3a !important;
    color: #dff7ff !important;
}
body.dark-mode .list-group-item-primary,
[data-theme="dark"] .list-group-item-primary,
html.dark-mode-preload .list-group-item-primary {
    background-color: #12213f !important;
    color: #e6f0ff !important;
}
body.dark-mode .list-group-item-secondary,
[data-theme="dark"] .list-group-item-secondary,
html.dark-mode-preload .list-group-item-secondary {
    background-color: #1f2732 !important;
    color: #e2e8f0 !important;
}
body.dark-mode .list-group-item-light,
[data-theme="dark"] .list-group-item-light,
html.dark-mode-preload .list-group-item-light {
    background-color: #cbd5e1 !important;
    color: #0f172a !important;
}
body.dark-mode .list-group-item-dark,
[data-theme="dark"] .list-group-item-dark,
html.dark-mode-preload .list-group-item-dark {
    background-color: #0b1220 !important;
    color: #f1f5f9 !important;
}

/* Dark theme: force dark backgrounds for contextual table rows (text stays light) */
[data-theme="dark"] .table-success,
[data-theme="dark"] .table-success > td,
[data-theme="dark"] .table-success > th,
html.dark-mode-preload .table-success,
html.dark-mode-preload .table-success > td,
html.dark-mode-preload .table-success > th { background-color: #0f3b26 !important; }

[data-theme="dark"] .table-danger,
[data-theme="dark"] .table-danger > td,
[data-theme="dark"] .table-danger > th,
html.dark-mode-preload .table-danger,
html.dark-mode-preload .table-danger > td,
html.dark-mode-preload .table-danger > th { background-color: #3f1014 !important; }

[data-theme="dark"] .table-warning,
[data-theme="dark"] .table-warning > td,
[data-theme="dark"] .table-warning > th,
html.dark-mode-preload .table-warning,
html.dark-mode-preload .table-warning > td,
html.dark-mode-preload .table-warning > th { background-color: #3b2a03 !important; }

[data-theme="dark"] .table-info,
[data-theme="dark"] .table-info > td,
[data-theme="dark"] .table-info > th,
html.dark-mode-preload .table-info,
html.dark-mode-preload .table-info > td,
html.dark-mode-preload .table-info > th { background-color: #0a2a3a !important; }

[data-theme="dark"] .table-primary,
[data-theme="dark"] .table-primary > td,
[data-theme="dark"] .table-primary > th,
html.dark-mode-preload .table-primary,
html.dark-mode-preload .table-primary > td,
html.dark-mode-preload .table-primary > th { background-color: #12213f !important; }

[data-theme="dark"] .table-secondary,
[data-theme="dark"] .table-secondary > td,
[data-theme="dark"] .table-secondary > th,
html.dark-mode-preload .table-secondary,
html.dark-mode-preload .table-secondary > td,
html.dark-mode-preload .table-secondary > th { background-color: #1f2732 !important; }

[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light > td,
[data-theme="dark"] .table-light > th,
html.dark-mode-preload .table-light,
html.dark-mode-preload .table-light > td,
html.dark-mode-preload .table-light > th { background-color: #cbd5e1 !important; }

[data-theme="dark"] .table-dark,
[data-theme="dark"] .table-dark > td,
[data-theme="dark"] .table-dark > th,
html.dark-mode-preload .table-dark,
html.dark-mode-preload .table-dark > td,
html.dark-mode-preload .table-dark > th { background-color: #0b1220 !important; }

/* Improve contrast for contextual table rows across all variants */
[data-theme="dark"] tr.table-success > *,
html.dark-mode-preload tr.table-success > *,
body.dark-mode tr.table-success > * {
    color: #e6ffed !important;
}
[data-theme="dark"] tr.table-danger > *,
html.dark-mode-preload tr.table-danger > *,
body.dark-mode tr.table-danger > * {
    color: #ffe5e9 !important;
}
[data-theme="dark"] tr.table-warning > *,
html.dark-mode-preload tr.table-warning > *,
body.dark-mode tr.table-warning > * {
    color: #fff4c2 !important;
}
[data-theme="dark"] tr.table-info > *,
html.dark-mode-preload tr.table-info > *,
body.dark-mode tr.table-info > * {
    color: #dff7ff !important;
}
[data-theme="dark"] tr.table-primary > *,
html.dark-mode-preload tr.table-primary > *,
body.dark-mode tr.table-primary > * {
    color: #e6f0ff !important;
}
[data-theme="dark"] tr.table-secondary > *,
html.dark-mode-preload tr.table-secondary > *,
body.dark-mode tr.table-secondary > * {
    color: #e3e8ee !important;
}
[data-theme="dark"] tr.table-light > *,
html.dark-mode-preload tr.table-light > *,
body.dark-mode tr.table-light > * {
    color: #0f172a !important; /* dark text on light row */
}
[data-theme="dark"] tr.table-dark > *,
html.dark-mode-preload tr.table-dark > *,
body.dark-mode tr.table-dark > * {
    color: #f1f5f9 !important;
}

/* Links and muted text inside contextual rows */
[data-theme="dark"] .table-success a,
[data-theme="dark"] tr.table-success a,
[data-theme="dark"] .table-success .text-muted { color: #f0fff4 !important; }

[data-theme="dark"] .table-danger a,
[data-theme="dark"] tr.table-danger a,
[data-theme="dark"] .table-danger .text-muted { color: #ffd9df !important; }

[data-theme="dark"] .table-warning a,
[data-theme="dark"] tr.table-warning a,
[data-theme="dark"] .table-warning .text-muted { color: #ffeaa0 !important; }

[data-theme="dark"] .table-info a,
[data-theme="dark"] tr.table-info a,
[data-theme="dark"] .table-info .text-muted { color: #c9f1ff !important; }

[data-theme="dark"] .table-primary a,
[data-theme="dark"] tr.table-primary a,
[data-theme="dark"] .table-primary .text-muted { color: #cfe2ff !important; }

[data-theme="dark"] .table-secondary a,
[data-theme="dark"] tr.table-secondary a,
[data-theme="dark"] .table-secondary .text-muted { color: #d0d6dd !important; }

[data-theme="dark"] .table-light a,
[data-theme="dark"] tr.table-light a,
[data-theme="dark"] .table-light .text-muted { color: #1f2937 !important; }

[data-theme="dark"] .table-dark a,
[data-theme="dark"] tr.table-dark a,
[data-theme="dark"] .table-dark .text-muted { color: #e2e8f0 !important; }

/* Generic bg-* utilities: ensure text has sufficient contrast in dark mode */
[data-theme="dark"] .bg-success { color: #e6ffed !important; }
[data-theme="dark"] .bg-danger { color: #ffe5e9 !important; }
[data-theme="dark"] .bg-warning { color: #111827 !important; } /* keep dark text on yellow */
[data-theme="dark"] .bg-info    { color: #dff7ff !important; }
[data-theme="dark"] .bg-primary { color: #e6f0ff !important; }
[data-theme="dark"] .bg-secondary { color: #e2e8f0 !important; }
[data-theme="dark"] .bg-light   { color: #0f172a !important; }
[data-theme="dark"] .bg-dark    { color: #f1f5f9 !important; }

/* Ensure .text-dark remains readable in dark mode when used with bg-* */
body.dark-mode .text-dark,
[data-theme="dark"] .text-dark,
html.dark-mode-preload .text-dark {
    color: #0f172a;
}

/*------------------------------------------------------------------------------
  10. Mobile Sticky Action Bar & FAB tweaks
------------------------------------------------------------------------------*/
/* Ensure FABs do not collide with sticky actions */
.fab-container {
  bottom: 1rem;
}

/* Raise z-index for Bootstrap modal to ensure it is clickable above any custom overlays */
.modal { z-index: 3000 !important; }
.modal-backdrop { z-index: 2950 !important; }

/* --- Mobile ergonomics & overflow fixes for navbar/menu/dropdowns --- */
@media (max-width: 576px) {
  /* 1) Navbar should not be sticky on phones */
  .navbar.sticky-top {
    position: static !important;
  }

  /* 2) Make collapsed menu scrollable when expanded so long lists are reachable */
  .navbar .collapse.show {
    max-height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 3) Allow long dropdowns (e.g., Navigare Rapidă) to scroll on phones */
  .navbar .dropdown-menu {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 4) Admin debug bar should not stick on phones to avoid covering content */
  #admin-debug-bar {
    position: static;
    top: auto;
  }
}

/* 11. Neutralize colored row backgrounds in list tables (light mode too) */
.table tr.table-success,
.table tr.table-warning,
.table tr.table-secondary,
.table tr.table-danger,
.table tr.table-info,
.table tr.table-primary,
.table tr.table-light,
.table tr.table-dark {
  background-color: transparent !important;
}
.table tr.table-success > td,
.table tr.table-warning > td,
.table tr.table-secondary > td,
.table tr.table-danger > td,
.table tr.table-info > td,
.table tr.table-primary > td,
.table tr.table-light > td,
.table tr.table-dark > td {
  background-color: transparent !important;
  color: inherit !important;
}

/* 12. FullCalendar readability: wrap text and auto-resize */
.fc .fc-event-title,
.fc .fc-event-time,
.fc .fc-event-main {
  white-space: normal;
  line-height: 1.2;
  font-size: clamp(11px, 1.4vw, 14px);
}