/* ========================================================
   RB_work - ระบบบริหารจัดการและส่งเอกสารครูออนไลน์
   Main Stylesheet: Modern School UI (White-Yellow Theme + Comprehensive Dark Mode)
   Enhanced Typography, Legibility, and Contrast System
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ========================================================
   Theme Tokens & Color System
   ======================================================== */
:root {
    /* School Brand Colors: White & Golden Yellow */
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --primary-light: #fef08a;
    --primary-subtle: rgba(245, 158, 11, 0.08);
    --primary-contrast: #0f172a;

    --secondary: #64748b;
    --success: #10b981;
    --success-subtle: #ecfdf5;
    --danger: #ef4444;
    --danger-subtle: #fef2f2;
    --warning: #f59e0b;
    --warning-subtle: #fffbeb;
    --info: #0284c7;
    --info-subtle: #f0f9ff;

    /* Light Theme Surfaces & Text */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-sidebar: #ffffff;
    --border-color: #e2e8f0;
    --border-color-subtle: #f1f5f9;

    --text-primary: #0f172a;      /* Sharp deep slate for headings and primary copy */
    --text-secondary: #475569;    /* Clean slate for body and descriptions */
    --text-muted: #64748b;        /* Legible muted tone for metadata and hints */

    --card-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04), 0 4px 10px -2px rgba(15, 23, 42, 0.03);
    --card-shadow-hover: 0 8px 20px -3px rgba(15, 23, 42, 0.06), 0 3px 6px -2px rgba(15, 23, 42, 0.03);

    --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========================================================
   Comprehensive Dark Mode System
   ======================================================== */
[data-theme="dark"],
[data-bs-theme="dark"] {
    /* Modern deep slate navy background for minimal eye strain */
    --bg-body: #0b1120;
    --bg-surface: #1e293b;
    --bg-surface-elevated: #283548;
    --bg-surface-hover: #334155;
    --bg-sidebar: #0f172a;
    --border-color: #334155;
    --border-color-subtle: #1e293b;

    /* High contrast, crisp text tokens */
    --text-primary: #f8fafc;      /* 98% brightness white-slate for optimal readability */
    --text-secondary: #cbd5e1;    /* 85% brightness for body and secondary information */
    --text-muted: #94a3b8;        /* 70% brightness for labels, dates, hints (never unreadable) */

    /* Vibrant accents with refined contrast against dark background */
    --primary: #facc15;
    --primary-hover: #eab308;
    --primary-light: #fef08a;
    --primary-subtle: rgba(234, 179, 8, 0.12);
    --primary-contrast: #0f172a;

    --success-subtle: rgba(16, 185, 129, 0.16);
    --danger-subtle: rgba(239, 68, 68, 0.16);
    --warning-subtle: rgba(245, 158, 11, 0.16);
    --info-subtle: rgba(14, 165, 233, 0.16);

    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.4);

    /* Bootstrap 5.3 internal variable sync */
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-muted);
    --bs-border-color: var(--border-color);
}

/* ========================================================
   Base Typography & Global Layout
   ======================================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    font-size: 0.9375rem;          /* 15px - optimal readability */
    line-height: 1.6;              /* Prevents Thai vowel/tone-mark overlap */
    letter-spacing: 0.01em;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Heading Scale */
h1, h2, h3, h4, h5, h6, .navbar-brand, .font-heading {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1, .h1 { font-size: 1.65rem; font-weight: 700; }
h2, .h2 { font-size: 1.4rem; font-weight: 700; }
h3, .h3 { font-size: 1.25rem; font-weight: 600; }
h4, .h4 { font-size: 1.15rem; font-weight: 600; }
h5, .h5 { font-size: 1.05rem; font-weight: 600; }
h6, .h6 { font-size: 0.95rem; font-weight: 600; }

p {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.small, small {
    font-size: 0.835rem;
    line-height: 1.5;
    color: var(--text-muted);
}

a {
    color: var(--primary-hover);
    text-decoration: none;
    transition: all 0.2s ease;
}
a:hover {
    color: var(--primary);
}

[data-theme="dark"] a:not(.btn):not(.dropdown-item):not(.sidebar-link):not(.badge) {
    color: #fde047;
}
[data-theme="dark"] a:not(.btn):not(.dropdown-item):not(.sidebar-link):not(.badge):hover {
    color: #fef08a;
}

/* ========================================================
   Sidebar & App Structure
   ======================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1030;
    transition: transform 0.3s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.school-logo-badge {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.3);
    flex-shrink: 0;
}

.sidebar-brand-text {
    line-height: 1.2;
}
.sidebar-brand-text .app-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.01em;
}
.sidebar-brand-text .app-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0;
    margin-top: 1px;
}

.sidebar-nav {
    padding: 12px 10px;
    overflow-y: auto;
    flex-grow: 1;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 12px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: 2px;
    transition: all 0.18s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    color: var(--text-muted);
    transition: color 0.18s ease;
}

.sidebar-link:hover {
    background-color: var(--primary-subtle);
    color: var(--primary-hover);
}
.sidebar-link:hover i {
    color: var(--primary-hover);
}

[data-theme="dark"] .sidebar-link:hover {
    background-color: rgba(234, 179, 8, 0.1);
    color: #facc15;
}
[data-theme="dark"] .sidebar-link:hover i {
    color: #facc15;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.28);
}
.sidebar-link.active i {
    color: #ffffff !important;
}

[data-theme="dark"] .sidebar-link.active {
    background: linear-gradient(135deg, #facc15, #eab308);
    color: #0f172a !important;
    box-shadow: 0 2px 8px rgba(234, 179, 8, 0.25);
}
[data-theme="dark"] .sidebar-link.active i {
    color: #0f172a !important;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ========================================================
   Top Navigation Bar
   ======================================================== */
.top-navbar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
    background: var(--primary-subtle);
    color: var(--primary-hover);
    border-color: var(--primary);
    transform: rotate(15deg);
}
[data-theme="dark"] .theme-toggle-btn {
    color: #facc15;
    background: #172033;
}
[data-theme="dark"] .theme-toggle-btn:hover {
    background: rgba(234, 179, 8, 0.2);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    border-radius: 40px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.user-profile-badge:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
}
[data-theme="dark"] .user-profile-badge {
    background: #172033;
}
[data-theme="dark"] .user-profile-badge:hover {
    background: rgba(234, 179, 8, 0.15);
}

.user-avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #eab308, #f59e0b);
    color: #0f172a;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

/* ========================================================
   Cards & Elevated Surfaces
   ======================================================== */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 13px 18px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-primary);
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

/* Stat Cards */
.stat-card {
    border-radius: 14px;
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon-bg {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.6rem;
    opacity: 0.08;
}
[data-theme="dark"] .stat-card .stat-icon-bg {
    opacity: 0.14;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 3px;
}

.border-accent-yellow {
    border-left: 3.5px solid var(--primary) !important;
}

/* ========================================================
   Buttons & Interactive Elements
   ======================================================== */
.btn-yellow, .btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 600;
    padding: 7px 15px;
    border-radius: 8px;
    font-size: 0.86rem;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.22);
    transition: all 0.2s ease;
}
.btn-yellow:hover, .btn-primary:hover {
    background: linear-gradient(135deg, #d97706, #b45309) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 7px 15px;
    font-size: 0.86rem;
}
.btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Outline Buttons with High Contrast in Dark Mode */
.btn-outline-warning {
    color: #d97706;
    border-color: rgba(217, 119, 6, 0.35);
    background: rgba(245, 158, 11, 0.04);
    font-weight: 500;
    border-radius: 8px;
    font-size: 0.84rem;
    padding: 5px 12px;
}
.btn-outline-warning:hover {
    background-color: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-outline-warning,
[data-bs-theme="dark"] .btn-outline-warning {
    color: #fde047 !important;
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.05);
}
[data-theme="dark"] .btn-outline-warning:hover,
[data-bs-theme="dark"] .btn-outline-warning:hover {
    background-color: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #0f172a !important;
}

[data-theme="dark"] .btn-outline-dark,
[data-bs-theme="dark"] .btn-outline-dark {
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}
[data-theme="dark"] .btn-outline-dark:hover,
[data-bs-theme="dark"] .btn-outline-dark:hover {
    background-color: #334155 !important;
    border-color: #64748b !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-outline-secondary,
[data-bs-theme="dark"] .btn-outline-secondary {
    color: #cbd5e1 !important;
    border-color: #475569 !important;
}
[data-theme="dark"] .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: #334155 !important;
    border-color: #64748b !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-outline-primary,
[data-bs-theme="dark"] .btn-outline-primary {
    color: #60a5fa !important;
    border-color: #3b82f6 !important;
}
[data-theme="dark"] .btn-outline-primary:hover,
[data-bs-theme="dark"] .btn-outline-primary:hover {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-outline-danger,
[data-bs-theme="dark"] .btn-outline-danger {
    color: #f87171 !important;
    border-color: #ef4444 !important;
}
[data-theme="dark"] .btn-outline-danger:hover,
[data-bs-theme="dark"] .btn-outline-danger:hover {
    background-color: #ef4444 !important;
    color: #ffffff !important;
}

/* ========================================================
   Form Inputs & Controls
   ======================================================== */
.form-control, .form-select {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.93rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(234, 179, 8, 0.25);
}
.form-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #172033;
    border-color: #334155;
    color: #f8fafc;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #1e293b;
    border-color: #facc15;
    color: #ffffff;
    box-shadow: 0 0 0 0.25rem rgba(250, 204, 21, 0.2);
}
[data-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b;
}
[data-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .input-group-text {
    background-color: #172033;
    border-color: #334155;
    color: #cbd5e1;
}

/* ========================================================
   Tables & Data Grid
   ======================================================== */
.table {
    color: var(--text-primary);
    border-color: var(--border-color);
    margin-bottom: 0;
}
.table thead th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.81rem;
    letter-spacing: 0.01em;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 12px;
    vertical-align: middle;
}
.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    font-size: 0.87rem;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.table tbody tr {
    transition: background-color 0.15s ease;
}

[data-theme="dark"] .table,
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
}
[data-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table thead th,
[data-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light th {
    background-color: #172033 !important;
    color: #cbd5e1 !important;
    border-bottom: 1px solid #334155 !important;
}
[data-theme="dark"] .table-hover tbody tr:hover td,
[data-bs-theme="dark"] .table-hover tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.035) !important;
}

/* ========================================================
   Badges, Pills & Indicators
   ======================================================== */
.badge {
    font-weight: 500;
    padding: 0.32em 0.65em;
    font-size: 0.74rem;
    letter-spacing: 0.01em;
    border-radius: 6px;
    vertical-align: middle;
}

/* Keep bright yellow badges crisp and legible with dark text */
.badge.bg-warning,
.badge.bg-warning *,
.badge.bg-warning.text-dark {
    background-color: rgba(245, 158, 11, 0.14) !important;
    color: #92400e !important;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge.bg-warning,
[data-theme="dark"] .badge.bg-warning *,
[data-theme="dark"] .badge.bg-warning.text-dark {
    background-color: rgba(245, 158, 11, 0.18) !important;
    color: #fde047 !important;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

/* Soft Modern Status Badges (Light Mode) */
.badge.bg-success:not(.text-white) {
    background-color: #ecfdf5 !important;
    color: #15803d !important;
    border: 1px solid #bbf7d0;
}
.badge.bg-danger:not(.text-white) {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca;
}
.badge.bg-info:not(.text-white) {
    background-color: #f0f9ff !important;
    color: #0369a1 !important;
    border: 1px solid #bae6fd;
}
.badge.bg-secondary:not(.text-white) {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0;
}

/* Red Background for Explicit Late Status */
.badge.bg-danger.text-white {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    border: none !important;
}

/* ========================================================
   Pinned Announcement Badge (ปักหมุดข่าวให้เห็นเด่นชัดเป็นพิเศษ)
   ======================================================== */
.badge-pinned {
    background: linear-gradient(135deg, #f59e0b, #ea580c) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 0.78rem !important;
    padding: 4px 11px !important;
    border-radius: 20px !important;
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.45) !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.02em;
    vertical-align: middle;
}
.badge-pinned i {
    font-size: 0.85rem !important;
    color: #ffffff !important;
}

.badge-pinned-sm {
    font-size: 0.7rem !important;
    padding: 2px 8px !important;
    border-radius: 12px !important;
}
.badge-pinned-sm i {
    font-size: 0.75rem !important;
}

/* Dark mode badge overrides */
[data-theme="dark"] .badge.bg-light.text-dark,
[data-bs-theme="dark"] .badge.bg-light.text-dark,
[data-theme="dark"] .badge.bg-light,
[data-bs-theme="dark"] .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

[data-theme="dark"] .badge.bg-secondary-subtle,
[data-bs-theme="dark"] .badge.bg-secondary-subtle {
    background-color: rgba(148, 163, 184, 0.15) !important;
    color: #cbd5e1 !important;
    border: 1px solid rgba(148, 163, 184, 0.25) !important;
}

[data-theme="dark"] .badge.bg-warning-subtle,
[data-bs-theme="dark"] .badge.bg-warning-subtle {
    background-color: rgba(234, 179, 8, 0.18) !important;
    color: #fde047 !important;
    border: 1px solid rgba(234, 179, 8, 0.35) !important;
}

[data-theme="dark"] .badge.bg-success-subtle,
[data-bs-theme="dark"] .badge.bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.18) !important;
    color: #86efac !important;
    border: 1px solid rgba(16, 185, 129, 0.35) !important;
}

[data-theme="dark"] .badge.bg-danger-subtle,
[data-bs-theme="dark"] .badge.bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.18) !important;
    color: #fca5a5 !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
}

[data-theme="dark"] .badge.bg-info-subtle,
[data-bs-theme="dark"] .badge.bg-info-subtle {
    background-color: rgba(14, 165, 233, 0.18) !important;
    color: #93c5fd !important;
    border: 1px solid rgba(14, 165, 233, 0.35) !important;
}

/* ========================================================
   CRITICAL: Dark Mode Universal Text Contrast Fixes
   Transforms any inadvertent .text-dark to crisp light text
   while strictly preserving dark text on yellow badges/buttons
   ======================================================== */
[data-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-dark {
    color: #f8fafc !important;
}

/* Explicitly restore dark text for buttons/badges on bright yellow backgrounds */
[data-theme="dark"] .btn-yellow,
[data-theme="dark"] .btn-yellow *,
[data-theme="dark"] .btn-warning,
[data-theme="dark"] .btn-warning *,
[data-theme="dark"] .badge.bg-warning,
[data-theme="dark"] .badge.bg-warning *,
[data-theme="dark"] .bg-warning,
[data-theme="dark"] .bg-warning *,
[data-theme="dark"] .alert-warning,
[data-theme="dark"] .alert-warning *,
[data-bs-theme="dark"] .btn-yellow,
[data-bs-theme="dark"] .btn-yellow *,
[data-bs-theme="dark"] .btn-warning,
[data-bs-theme="dark"] .btn-warning *,
[data-bs-theme="dark"] .badge.bg-warning,
[data-bs-theme="dark"] .badge.bg-warning *,
[data-bs-theme="dark"] .bg-warning,
[data-bs-theme="dark"] .bg-warning *,
[data-bs-theme="dark"] .alert-warning,
[data-bs-theme="dark"] .alert-warning * {
    color: #0f172a !important;
}

/* Outline warning buttons always use yellow text in dark mode */
[data-theme="dark"] .btn-outline-warning,
[data-theme="dark"] .btn-outline-warning.text-dark,
[data-bs-theme="dark"] .btn-outline-warning,
[data-bs-theme="dark"] .btn-outline-warning.text-dark {
    color: #facc15 !important;
    border-color: #facc15 !important;
}

[data-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}

[data-theme="dark"] .text-secondary,
[data-bs-theme="dark"] .text-secondary {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-white {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-light {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start,
[data-theme="dark"] .border-end,
[data-theme="dark"] .border {
    border-color: #334155 !important;
}

/* Table header in dark mode - high contrast elevated navy surface */
[data-theme="dark"] .table thead,
[data-theme="dark"] .table thead tr,
[data-theme="dark"] .table thead th,
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light tr,
[data-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table thead,
[data-bs-theme="dark"] .table thead tr,
[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light tr,
[data-bs-theme="dark"] .table-light th {
    --bs-table-bg: #172033 !important;
    --bs-table-color: #f8fafc !important;
    background-color: #172033 !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

/* ========================================================
   Modals & Dropdowns in Dark Mode
   ======================================================== */
[data-theme="dark"] .modal-content,
[data-bs-theme="dark"] .modal-content {
    background-color: #1e293b;
    color: var(--text-primary);
    border: 1px solid #334155;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-header {
    border-bottom: 1px solid #334155;
}

[data-theme="dark"] .modal-footer,
[data-bs-theme="dark"] .modal-footer {
    border-top: 1px solid #334155;
    background-color: #172033 !important;
}

[data-theme="dark"] .btn-close:not(.btn-close-white),
[data-bs-theme="dark"] .btn-close:not(.btn-close-white) {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: var(--text-primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .dropdown-item,
[data-bs-theme="dark"] .dropdown-item {
    color: #cbd5e1;
}
[data-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: #334155;
    color: #ffffff;
}
[data-theme="dark"] .dropdown-divider,
[data-bs-theme="dark"] .dropdown-divider {
    border-color: #334155;
}

/* Alerts in Dark Mode */
[data-theme="dark"] .alert,
[data-bs-theme="dark"] .alert {
    border-radius: 12px;
}
[data-theme="dark"] .alert-info,
[data-bs-theme="dark"] .alert-info,
[data-theme="dark"] .bg-info-subtle {
    background-color: rgba(14, 165, 233, 0.15) !important;
    color: #7dd3fc !important;
    border: 1px solid rgba(14, 165, 233, 0.3) !important;
}
[data-theme="dark"] .alert-warning,
[data-bs-theme="dark"] .alert-warning,
[data-theme="dark"] .bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #fde047 !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}
[data-theme="dark"] .alert-danger,
[data-bs-theme="dark"] .alert-danger,
[data-theme="dark"] .bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #fca5a5 !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}
[data-theme="dark"] .alert-success,
[data-bs-theme="dark"] .alert-success,
[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #86efac !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}

/* SweetAlert2 Popup Integration in Dark Mode */
[data-theme="dark"] .swal2-popup,
[data-bs-theme="dark"] .swal2-popup {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6) !important;
}
[data-theme="dark"] .swal2-title,
[data-bs-theme="dark"] .swal2-title {
    color: #f8fafc !important;
}
[data-theme="dark"] .swal2-html-container,
[data-bs-theme="dark"] .swal2-html-container {
    color: #cbd5e1 !important;
}

/* ========================================================
   Custom Component Fixes
   ======================================================== */
.upload-dropzone {
    border: 2px dashed var(--primary);
    border-radius: 14px;
    padding: 35px 20px;
    text-align: center;
    background-color: var(--primary-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary-hover);
    background-color: rgba(234, 179, 8, 0.18);
    transform: scale(1.01);
}
.upload-dropzone i {
    font-size: 3rem;
    color: var(--primary);
}

/* Timeline & Log */
.timeline {
    position: relative;
    padding-left: 28px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-color);
}
.timeline-item {
    position: relative;
    margin-bottom: 24px;
}
.timeline-dot {
    position: absolute;
    left: -28px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-surface);
    box-shadow: 0 0 0 2px var(--border-color);
}

/* Icon picker buttons in admin announcements */
.btn-icon-choice {
    width: 78px;
    height: 72px;
    padding: 6px 4px;
    font-size: 0.72rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}
.btn-icon-choice:hover, .btn-icon-choice.active {
    background-color: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary-hover);
}
[data-theme="dark"] .btn-icon-choice {
    background: #172033;
    border-color: #334155;
    color: #cbd5e1;
}
[data-theme="dark"] .btn-icon-choice:hover,
[data-theme="dark"] .btn-icon-choice.active {
    background-color: rgba(234, 179, 8, 0.2);
    border-color: #facc15;
    color: #fef08a;
}

/* List group in dark mode */
[data-theme="dark"] .list-group-item {
    background-color: transparent;
    border-color: #334155;
    color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 25px rgba(0,0,0,0.4);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.6);
        z-index: 1025;
    }
    .sidebar-overlay.show {
        display: block;
    }
}
