:root[data-theme="light"] {
    --bg-primary: var(--bg-primary);
    --bg-secondary: var(--card-bg);
    --text-primary: var(--text-primary);
    --text-secondary: var(--text-secondary);
    --border-color: var(--border-color);
    --shadow: rgba(0, 0, 0, 0.08);
    --overlay: rgba(0, 0, 0, 0.5);
}

:root[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: var(--card-bg);
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --overlay: rgba(0, 0, 0, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
    padding-top: 60px;
}

body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.mobile-header {
    background: var(--nav-bg, #ffffff) !important;
    background-color: var(--nav-bg, #ffffff) !important;
    opacity: 1 !important;
    padding: 12px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1000 !important;
}

.menu-icon {
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.menu-icon span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--accent-color, #333);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-icon.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-icon.active span:nth-child(2) {
    opacity: 0;
}

.menu-icon.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-logo-img {
    height: 30px;
    width: auto;
}

.profile-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-weight: 700;
    font-size: 14px;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100vh;
    background: var(--sidebar-bg, #ffffff);    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
    transition: left 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.sidebar-header {
    padding: 20px;
    color: var(--text-inverse);
    position: relative;
    /* Default gradient background using theme variables with fallback */
    background: linear-gradient(135deg, var(--theme-primary, #4F46E5) 0%, var(--theme-secondary, #6366f1) 100%);
}

.sidebar-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-inverse);
    font-size: 24px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: none;
}

.logo-img {
    height: 40px;
    width: auto;
    filter: brightness(0) invert(1);
}

/* When org has its own logo: show it naturally, without white filter */
.logo-img.org-logo {
    filter: none;
    max-height: 44px;
    max-width: 120px;
    object-fit: contain;
}

/* "Powered by BINTACURA" badge shown below org logo in sidebar */
.sidebar-powered-by {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    opacity: 0.65;
}
.bintacura-badge-img {
    height: 16px;
    width: auto;
    filter: brightness(0) invert(1);
}
.bintacura-badge-text {
    font-size: 10px;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-inverse);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.sidebar-user-avatar {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    max-width: 50px;
    max-height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.sidebar-user-avatar img,
.sidebar-user-avatar .user-avatar-img {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    object-fit: cover;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
}

.sidebar-user-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
    color: inherit;
}

.sidebar-user-info p {
    font-size: 12px;
    opacity: 0.9;
    color: inherit;
}

.sidebar-nav {
    padding: 16px 0;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section-title {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
    cursor: pointer;
}

.sidebar-menu-item:hover {
    background: var(--bg-primary);
}

.sidebar-menu-item-icon {
    width: 24px;
    margin-right: 12px;
    font-size: 20px;
}

.sidebar-menu-item-text {
    flex: 1;
    font-size: 14px;
}

.sidebar-menu-item-badge {
    background: var(--brand-primary, var(--brand-primary));
    color: var(--text-inverse);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

.setting-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
}

.setting-toggle:hover {
    background: var(--bg-primary);
}

.setting-info {
    display: flex;
    align-items: center;
}

.setting-icon {
    width: 24px;
    margin-right: 12px;
    font-size: 20px;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: var(--accent-color);
}

.toggle-switch-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--card-bg);
    border-radius: 50%;
    transition: left 0.3s;
}

.toggle-switch.active .toggle-switch-slider {
    left: 25px;
}

.setting-select {
    padding: 12px 20px;
}

.setting-select-label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.setting-select select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.red {
    background: rgba(220, 53, 69, 0.1);
    color: var(--brand-primary);
}

.stat-icon.blue {
    background: rgba(0, 123, 255, 0.1);
    color: var(--brand-primary);
}

.stat-icon.green {
    background: rgba(40, 167, 69, 0.1);
    color: var(--brand-primary);
}

.stat-icon.orange {
    background: rgba(255, 193, 7, 0.1);
    color: var(--status-warning);
}

.stat-icon.purple {
    background: rgba(102, 126, 234, 0.1);
    color: var(--brand-primary);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-color);
    padding: 0 16px;
    margin: 24px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.view-all-btn {
    background: transparent;
    color: var(--accent-color);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.help-badge {
    background: var(--accent-color);
    color: var(--text-inverse);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.carousel-container {
    position: relative;
    overflow: hidden;
    margin: 16px;
    border-radius: 12px;
    height: 180px;
}

.carousel {
    display: flex;
    transition: transform 0.3s ease;
}

.carousel-slide {
    min-width: 100%;
    height: 180px;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.9), rgba(108, 117, 125, 0.9));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-inverse);
    padding: 20px;
    text-align: center;
}

.carousel-slide h3 {
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

.carousel-btn {
    background: var(--brand-primary);
    color: var(--text-inverse);
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-primary);
}

.carousel-nav.prev {
    left: 10px;
}

.carousel-nav.next {
    right: 10px;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 24px;
}

.service-card {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-color);
    border-radius: 16px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
}

.service-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.service-title {
    color: var(--accent-color);
    font-size: 14px;
    font-weight: 700;
    margin: 0;
}

.appointment-btn {
    background: var(--accent-color);
    color: var(--text-inverse);
    border: none;
    padding: 16px;
    margin: 0 16px 24px;
    border-radius: 28px;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.3s ease;
}

.appointment-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow);
}

.appointments-list {
    padding: 0 16px;
    margin-bottom: 24px;
}

.appointment-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    gap: 12px;
}

.appointment-time {
    background: var(--accent-color);
    color: var(--text-inverse);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    min-width: 60px;
}

.appointment-time-hour {
    font-size: 18px;
    font-weight: 700;
}

.appointment-time-period {
    font-size: 11px;
}

.appointment-details {
    flex: 1;
}

.appointment-patient {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.appointment-type {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.appointment-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.appointment-status.confirmed {
    background: rgba(40, 167, 69, 0.1);
    color: var(--brand-primary);
}

.appointment-status.pending {
    background: rgba(255, 193, 7, 0.1);
    color: var(--status-warning);
}

.department-list {
    padding: 0 16px;
    margin-bottom: 24px;
}

.department-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.department-info {
    flex: 1;
}

.department-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.department-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

.department-capacity {
    text-align: right;
}

.capacity-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-color);
}

.capacity-label {
    font-size: 11px;
    color: var(--text-secondary);
}

@media (min-width: 768px) {
    .mobile-header {
        padding: 16px 32px;
    }

    .logo {
        font-size: 24px;
    }

    .sidebar {
        width: 360px;
        left: -360px;
    }

    .carousel-container {
        margin: 24px 32px;
        height: 240px;
    }

    .carousel-slide {
        height: 240px;
    }

    .carousel-slide h3 {
        font-size: 20px;
    }

    .stats-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 24px 32px;
        max-width: 900px;
        margin: 0 auto 24px;
    }

    .section-title {
        padding: 0 24px;
        margin: 32px auto 20px;
        font-size: 24px;
        max-width: 900px;
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 0 24px;
        max-width: 900px;
        margin: 0 auto 32px;
    }

    .service-card {
        padding: 24px 20px;
    }

    .service-icon {
        width: 70px;
        height: 70px;
        font-size: 40px;
    }

    .service-title {
        font-size: 16px;
    }

    .appointment-btn {
        max-width: 500px;
        margin: 0 auto 32px;
        display: block;
    }

    .appointments-list {
        padding: 0 32px;
        max-width: 1200px;
        margin: 0 auto 32px;
    }

    .department-list {
        padding: 0 32px;
        max-width: 1200px;
        margin: 0 auto 32px;
    }
}

@media (min-width: 1024px) {
    .section-title,
    .services-grid {
        max-width: 1000px;
        padding: 0 32px;
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .stats-container {
        max-width: 1000px;
    }

    .carousel-container {
        max-width: 1000px;
        margin: 24px auto;
        height: 300px;
    }

    .carousel-slide {
        height: 300px;
    }

    .carousel-slide h3 {
        font-size: 24px;
    }

    .appointment-btn {
        max-width: 600px;
    }
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.empty-state {
    text-align: center;
    padding: 40px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 16px;
}

.empty-state .btn {
    margin-top: 20px;
}