@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* Default Theme: Dark (Matches original premium aesthetic) */
:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --secondary: #00cec9;
    --accent: #fd79a8;
    
    /* Dark Theme Variables */
    --bg-gradient: linear-gradient(135deg, #0f0c1b 0%, #1a1735 50%, #25123e 100%);
    --text: #f5f6fa;
    --text-muted: rgba(245, 246, 250, 0.6);
    --card-bg: rgba(20, 15, 38, 0.75);
    --border: rgba(162, 155, 254, 0.15);
    --sidebar-bg: rgba(15, 12, 27, 0.85);
    --panel-bg: rgba(255, 255, 255, 0.05);
    --input-bg: rgba(255, 255, 255, 0.05);
    --table-hover: rgba(255, 255, 255, 0.02);
    
    --shadow: none;
    --glass-blur: blur(16px);
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f0f3f8 0%, #e0e5ec 50%, #f6f8fb 100%);
    --text: #2d3436;
    --text-muted: rgba(45, 52, 54, 0.7);
    --card-bg: rgba(255, 255, 255, 0.8);
    --border: rgba(108, 92, 231, 0.12);
    --sidebar-bg: rgba(245, 246, 250, 0.95);
    --panel-bg: rgba(108, 92, 231, 0.05);
    --input-bg: rgba(0, 0, 0, 0.03);
    --table-hover: rgba(108, 92, 231, 0.02);
    --shadow: none;

    /* Override colors for high contrast in light mode */
    --primary-light: #4834d4; /* Darker Purple */
    --secondary: #008080;     /* Darker Teal */
    --accent: #d63031;        /* Darker Red/Pink */
}

/* Automatically trigger Light theme if system defaults to it and user hasn't overridden it */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-gradient: linear-gradient(135deg, #f0f3f8 0%, #e0e5ec 50%, #f6f8fb 100%);
        --text: #2d3436;
        --text-muted: rgba(45, 52, 54, 0.7);
        --card-bg: rgba(255, 255, 255, 0.8);
        --border: rgba(108, 92, 231, 0.12);
        --sidebar-bg: rgba(245, 246, 250, 0.95);
        --panel-bg: rgba(108, 92, 231, 0.05);
        --input-bg: rgba(0, 0, 0, 0.03);
        --table-hover: rgba(108, 92, 231, 0.02);
        --shadow: none;

        --primary-light: #4834d4;
        --secondary: #008080;
        --accent: #d63031;
    }
}

/* Force Dark properties if overridden manually */
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f0c1b 0%, #1a1735 50%, #25123e 100%);
    --text: #f5f6fa;
    --text-muted: rgba(245, 246, 250, 0.6);
    --card-bg: rgba(20, 15, 38, 0.75);
    --border: rgba(162, 155, 254, 0.15);
    --sidebar-bg: rgba(15, 12, 27, 0.85);
    --panel-bg: rgba(255, 255, 255, 0.05);
    --input-bg: rgba(255, 255, 255, 0.05);
    --table-hover: rgba(255, 255, 255, 0.02);
    --shadow: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background-attachment: fixed;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Glassmorphism Containers (Shadowless) */
.glass-container {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: none;
    transition: all 0.3s ease;
}

.glass-container:hover {
    border-color: rgba(108, 92, 231, 0.3);
    box-shadow: none;
}

/* Sidebar & Navigation Layout */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border);
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: background 0.3s ease, border-color 0.3s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.brand-section {
    text-align: center;
    margin-bottom: 30px;
}

.brand-logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(to right, #a29bfe, #fd79a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    letter-spacing: 1px;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 5px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 18px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.25s ease;
}

.nav-item a:hover, .nav-item.active a {
    background: rgba(108, 92, 231, 0.12);
    color: var(--text);
    border-left: 4px solid var(--primary);
    padding-left: 14px;
}

.main-content {
    padding: 30px 40px;
    overflow-y: auto;
}

/* Header Dashboard Details */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white !important;
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 14px;
    background: rgba(108, 92, 231, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
    font-size: 24px;
}

.stat-details h3 {
    font-size: 28px;
    font-weight: 700;
}

.stat-details p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Theme Switcher buttons styles */
.theme-switcher {
    margin-bottom: 20px;
    display: flex;
    gap: 4px;
    background: var(--panel-bg);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.theme-btn {
    flex: 1;
    padding: 6px 4px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.theme-btn:hover {
    color: var(--text);
}

.theme-btn.active {
    background: var(--primary);
    color: #ffffff !important;
    box-shadow: none;
}

/* Standard Buttons (Shadowless) */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #574b90 100%);
    color: #ffffff !important;
    box-shadow: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-secondary {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(108, 92, 231, 0.12);
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #c44569 100%);
    color: #ffffff !important;
    box-shadow: none;
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--primary-light);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    outline: none;
    transition: all 0.25s ease;
}

.form-control:focus {
    background: var(--input-bg);
    border-color: var(--primary-light);
    box-shadow: none;
}

/* Custom Dropdown Select & Option Styles for Dark & Light Themes */
select, select.form-control {
    background-color: var(--card-bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a29bfe' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    padding-right: 38px !important;
    cursor: pointer;
}

select:focus, select.form-control:focus {
    border-color: var(--primary-light) !important;
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.25) !important;
}

select option {
    background-color: #1a1735 !important;
    color: #f5f6fa !important;
    padding: 12px !important;
    font-size: 14px;
}

[data-theme="light"] select option {
    background-color: #ffffff !important;
    color: #2d3436 !important;
}

[data-theme="light"] select, [data-theme="light"] select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234834d4' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) select option {
        background-color: #ffffff !important;
        color: #2d3436 !important;
    }
    :root:not([data-theme="dark"]) select, :root:not([data-theme="dark"]) select.form-control {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234834d4' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
    }
}

/* Wizard Layout */
.wizard-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
    overflow-x: auto;
}

.wizard-step {
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.wizard-step.active {
    background: rgba(108, 92, 231, 0.2);
    color: var(--text);
    border-bottom: 3px solid var(--primary);
}

.wizard-tab {
    display: none;
}

.wizard-tab.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modern Glass Data Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: 15px;
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background: rgba(108, 92, 231, 0.15);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--primary-light);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--table-hover);
}

/* IPD Register Calendar Specific styling */
.calendar-grid {
    display: grid;
    grid-template-columns: 200px repeat(31, minmax(45px, 1fr));
    border: 1px solid var(--border);
    border-radius: 15px;
    overflow-x: auto;
}

.calendar-header-cell {
    background: rgba(108, 92, 231, 0.2);
    padding: 12px 6px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
}

.calendar-row {
    display: contents;
}

.calendar-cell {
    padding: 10px 4px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.calendar-patient-name {
    padding: 15px;
    font-weight: 500;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--panel-bg);
    display: flex;
    align-items: center;
}

.shift-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 4px;
    cursor: pointer;
    width: 25px;
    text-align: center;
    transition: all 0.2s ease;
}

.shift-badge.M {
    background: rgba(0, 206, 201, 0.15);
    color: var(--secondary);
    border: 1px solid rgba(0, 206, 201, 0.3);
}

.shift-badge.A {
    background: rgba(253, 121, 168, 0.15);
    color: var(--accent);
    border: 1px solid rgba(253, 121, 168, 0.3);
}

.shift-badge.present {
    background: #00b894 !important;
    color: white !important;
    border: none !important;
}

.shift-badge.absent {
    background: #d63031 !important;
    color: white !important;
    border: none !important;
}

.shift-badge.excused {
    background: #fdcb6e !important;
    color: black !important;
    border: none !important;
}

/* ==========================================
   THEME COMPATIBILITY WILDCARDS
   Remaps hardcoded dark-aesthetic inline text
   colors to the current theme's text-muted
   ========================================== */
.dashboard-header p,
.brand-subtitle,
[style*="color: rgba(245, 246, 250"],
[style*="color:rgba(245, 246, 250"],
[style*="color: rgba(255, 255, 255"],
[style*="color:rgba(255, 255, 255"],
[style*="color: rgba(255,255,255"],
[style*="color:rgba(255,255,255"] {
    color: var(--text-muted) !important;
}

/* Print Layout Optimization */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    .sidebar, .btn, .wizard-nav, .dashboard-header, .theme-switcher {
        display: none !important;
    }
    .main-content {
        padding: 0 !important;
    }
    .glass-container {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    .print-only {
        display: block !important;
    }
}
