/* Custom Dark Mode Overrides */
[data-theme="dark"] {
    /* Base Variables */
    --bg-page: #1a1a27;
    --bg-surface: #1e1e2d;
    --bg-drawer: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #33323e;
}

/* Base Elements */
html[data-theme="dark"],
html[data-theme="dark"] body, 
html[data-theme="dark"] main, 
html[data-theme="dark"] .page,
html[data-theme="dark"] .mud-layout {
    background: var(--bg-page) !important;
    background-image: none !important;
    color: var(--text-primary) !important;
}

/* Layout Elements */
[data-theme="dark"] .top-row {
    background-color: var(--bg-page) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .sidebar {
    background-color: var(--bg-drawer) !important;
    border-left: 1px solid var(--border-color) !important;
}

/* Cards & Containers */
[data-theme="dark"] .mud-card, 
[data-theme="dark"] .rounded-card,
[data-theme="dark"] .bg-white {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-50\/50,
[data-theme="dark"] .bg-gray-100 {
    background-color: rgba(255, 255, 255, 0.03) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .bg-gray-800 {
    background-color: #2a2833 !important;
}

/* Text Colors */
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-900 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400,
[data-theme="dark"] .text-gray-600 {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, 
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
    color: var(--text-primary) !important;
}

/* Borders */
[data-theme="dark"] .border-gray-100,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border {
    border-color: var(--border-color) !important;
}

/* Podium Cards */
[data-theme="dark"] .rounded-card.score-podium-1,
[data-theme="dark"] .rounded-card.score-podium-2,
[data-theme="dark"] .rounded-card.score-podium-3,
[data-theme="dark"] .rounded-card.score-podium-4,
[data-theme="dark"] .rounded-card.score-podium-5 {
    background-color: #1a2c30 !important;
}

[data-theme="dark"] .rounded-card.score-podium-2,
[data-theme="dark"] .rounded-card.score-podium-3,
[data-theme="dark"] .rounded-card.score-podium-4,
[data-theme="dark"] .rounded-card.score-podium-5 {
    color: var(--text-primary) !important;
}

/* Specific Teacher App Styles */
[data-theme="dark"] .teacher-panel-text {
    color: white !important;
}

/* Dashboard Cards Overrides */
[data-theme="dark"] .dashboard-card {
    background: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .dashboard-card .dashboard-title {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .dashboard-card:hover .dashboard-title {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .dashboard-card:hover {
    border-color: transparent !important;
}

[data-theme="dark"] .assigned-group-card {
    background: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .assigned-group-card h6 {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .assigned-group-card .mud-text-body2 {
    color: var(--text-secondary) !important;
}

/* Content Availability Page Overrides */
[data-theme="dark"] .ca-filter-card {
    background: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .ca-grid-wrapper {
    background: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .ca-stats-bar {
    background: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .student-name,
[data-theme="dark"] .ca-empty-title {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .ca-empty-subtitle {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .ca-grid-wrapper .mud-table-head .mud-table-row {
    background: var(--bg-surface) !important;
}
[data-theme="dark"] .ca-grid-wrapper .mud-table-body .mud-table-cell,
[data-theme="dark"] .ca-grid-wrapper .mud-table-head .mud-table-cell {
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .ca-stats-badge {
    background: rgba(19, 123, 117, 0.2) !important;
    color: #2ed3c6 !important;
}

/* Card Action Footers & Generic Adjustments */
[data-theme="dark"] .mud-card-actions,
[data-theme="dark"] .mud-card .mt-auto {
    background-color: rgba(0, 0, 0, 0.2) !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .mud-card button.bg-white,
[data-theme="dark"] .mud-card a.bg-white,
[data-theme="dark"] .mud-card .mud-icon-button.bg-white,
[data-theme="dark"] .mud-card .bg-gray-100.rounded-full {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-card button.bg-white:hover,
[data-theme="dark"] .mud-card a.bg-white:hover,
[data-theme="dark"] .mud-card .mud-icon-button.bg-white:hover,
[data-theme="dark"] .mud-card .bg-gray-100.rounded-full:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Colored Badges & Pills */
[data-theme="dark"] .bg-teal-50 {
    background-color: rgba(19, 123, 117, 0.15) !important;
    border-color: rgba(19, 123, 117, 0.3) !important;
}
[data-theme="dark"] .text-teal-700,
[data-theme="dark"] .text-teal-600,
[data-theme="dark"] .border-teal-100 {
    color: #2ed3c6 !important;
    border-color: rgba(19, 123, 117, 0.3) !important;
}
[data-theme="dark"] .bg-purple-50 {
    background-color: rgba(147, 51, 234, 0.15) !important;
    border-color: rgba(147, 51, 234, 0.3) !important;
}
[data-theme="dark"] .text-purple-700 {
    color: #c084fc !important;
}
[data-theme="dark"] .bg-orange-50 {
    background-color: rgba(234, 88, 12, 0.15) !important;
    border-color: rgba(234, 88, 12, 0.3) !important;
}
[data-theme="dark"] .text-orange-700 {
    color: #fb923c !important;
}
[data-theme="dark"] .border-gray-50,
[data-theme="dark"] .border-gray-200 {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Fix MudBlazor Inputs in Dark Mode */
[data-theme="dark"] .mud-input {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mud-input-label {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .mud-input.mud-disabled,
[data-theme="dark"] .mud-input-control.mud-disabled .mud-input {
    color: rgba(255, 255, 255, 0.7) !important;
    opacity: 1 !important;
}

[data-theme="dark"] .mud-input-label.mud-disabled {
    color: rgba(255, 255, 255, 0.5) !important;
}

[data-theme="dark"] .mud-input-outlined-border {
    border-color: var(--border-color) !important;
}

/* Overlays */
[data-theme="dark"] .mud-overlay .mud-overlay-scrim.mud-overlay-light {
    background-color: rgba(26, 26, 39, 0.85) !important; /* Maps to --bg-page with opacity */
}

/* Tabs */
[data-theme="dark"] .mud-tab {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .mud-tab.mud-tab-active {
    color: var(--Primary) !important;
}
