:root {
    /* Color Palette - Light Lilac Premium */
    --bg-base: #f8f7ff;
    /* Soft lavender white */
    --bg-surface: rgba(255, 255, 255, 0.8);
    --border-color: rgba(139, 92, 246, 0.15);

    --primary: #8b5cf6;
    /* Vibrant Lilac */
    --primary-hover: #7c3aed;
    --secondary: #d8b4fe;
    /* Light Lavender */
    --accent: #f5f3ff;
    /* Extremely light lilac */

    --text-primary: #1e1b4b;
    /* Deep Indigo for contrast */
    --text-secondary: #64748b;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Shadows & Effects */
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pagination-container button.btn-icon {
    padding: 0.5rem 1.2rem;
    width: auto;
    height: auto;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
}

.pagination-container button.btn-icon:hover:not(:disabled) {
    background: var(--accent);
    color: var(--primary);
    border-color: var(--primary);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    overflow: clip;
    /* Modern alternative to hidden to prevent scroll but allow child control */

    @media (max-width: 768px) {
        overflow: auto;
        /* Allow body scroll if layout breaks */
        height: auto;
        min-height: 100dvh;
    }

    background-image: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(167, 139, 250, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    padding: 1rem;
    gap: 1rem;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.logo-container {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: #475569;
    /* Darker slate for contrast */
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
    position: relative;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.mt-auto {
    margin-top: auto;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.user-profile .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-profile .role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
    min-height: 0;
    /* Add this to prevent growing beyond container */
}

/* Header */
.top-header {
    height: var(--header-height);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: relative;
    z-index: 100;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    width: 300px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.header-search:focus-within {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.header-search i {
    color: var(--text-secondary);
}

.header-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
    font-family: inherit;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Notifications */
.notification-wrapper {
    position: relative;
    z-index: 101;
}

.notifications-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: -10px;
    width: 320px;
    max-width: 90vw;
    border-radius: var(--border-radius);
    padding: 1rem;
    display: none;
    z-index: 1000;
    transition: var(--transition);
    transform-origin: top right;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.notifications-dropdown.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.notif-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.notif-list {
    max-height: 350px;
    overflow-y: auto;
}

/* Mobile Notifications Override */
@media (max-width: 768px) {
    .notifications-dropdown {
        position: fixed;
        top: 70px;
        /* Below the first row of top-header */
        left: 10px;
        right: 10px;
        width: calc(100% - 20px);
        max-width: none;
        transform-origin: top center;
        padding: 1.2rem;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    }
}

/* Buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: #475569;
    /* Darker for light mode */
    font-size: 1.25rem;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--primary);
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    height: 16px;
    min-width: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

/* View Container */
.view-container {
    flex: 1;
    overflow-y: auto;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Crucial for flex child to scroll */
}

/* Scrollbar styling */
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Botones de Icono y Alineación */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(139, 92, 246, 0.1);
    transform: translateY(-2px);
}

td:last-child {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 120px;
}

/* Dashboard Specific Styles */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.stats-compact {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item-mini {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}

.stat-item-mini i {
    font-size: 1.2rem;
    opacity: 0.7;
}

.stat-item-mini .stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.stat-item-mini .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.two-month-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .two-month-container {
        grid-template-columns: 1fr;
    }
}

.calendar-month-grid {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 320px;
}

.calendar-month-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    text-align: center;
    text-transform: capitalize;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    opacity: 0.6;
}

.calendar-grid-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: default;
    position: relative;
    border: 1px solid transparent;
}

.calendar-day.other-month {
    opacity: 0.2;
}

.calendar-day.today {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.calendar-day.has-appointments {
    background: white;
    border-color: var(--primary);
    cursor: pointer;
}

.calendar-day.has-appointments::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

.calendar-day.has-appointments:hover {
    background: var(--primary);
    color: white;
}

.grid-cards,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

.stat-icon.teal {
    background: rgba(167, 139, 250, 0.1);
    color: var(--secondary);
}

.stat-icon.violet {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.detail-grid {
    grid-template-columns: 1fr 2fr;
}

.content-panel {
    padding: 1.5rem;
    border-radius: var(--border-radius);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-prevision-section {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.two-month-container {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    align-items: center;
}

table th {
    color: var(--text-primary);
    font-weight: 600;
}

.apt-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 0.75rem;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.apt-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.apt-time {
    font-weight: 600;
    color: var(--primary);
    width: 60px;
}

.apt-info {
    flex: 1;
}

.apt-info h4 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.apt-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-confirmed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Calendario Semanal */
.weekly-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.day-column {
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    border: 1px solid rgba(139, 92, 246, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 220px;
}

.day-header {
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    margin-bottom: 0.3rem;
}

.day-header h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.day-header .date-num {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.1rem;
}

.day-header.today .date-num {
    color: var(--primary);
}

.day-header.today {
    border-bottom-color: var(--primary);
}

.cal-apt {
    background: rgba(139, 92, 246, 0.08);
    border-left: 3px solid var(--primary);
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: var(--transition);
    cursor: pointer;
}

.cal-apt:hover {
    transform: translateX(3px);
    background: rgba(139, 92, 246, 0.15);
}

.cal-apt .time {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.2rem;
    display: block;
}

.cal-apt .name {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    line-height: 1.2;
}

/* Status styles for appointments */
.cal-apt.pendiente {
    background: rgba(139, 92, 246, 0.12);
    border-left-color: var(--primary);
}

.cal-apt.completada {
    background: rgba(16, 185, 129, 0.12);
    border-left-color: var(--success);
}

.cal-apt.cancelada {
    background: rgba(239, 68, 68, 0.12);
    border-left-color: var(--danger);
}

/* Category: Mindfulness (Green/Teal) */
.cal-apt.mindfulness.pendiente {
    background: rgba(20, 184, 166, 0.12);
    border-left-color: #14b8a6;
}

.cal-apt.mindfulness.pendiente .time {
    color: #14b8a6;
}

/* Type: Grupal (Amber/Dashed) */
.cal-apt.grupal {
    border-left-style: dashed;
    border-left-width: 5px;
}

.cal-apt.grupal.pendiente {
    background: rgba(245, 158, 11, 0.12);
    border-left-color: #f59e0b;
}

.cal-apt.grupal.pendiente .time {
    color: #f59e0b;
}

/* Status: Completed/Cancelled take precedence in color for clarity */
.cal-apt.completada .time,
.cal-apt.completada .name {
    color: #065f46;
}

.cal-apt.cancelada .time,
.cal-apt.cancelada .name {
    color: #991b1b;
}

.cal-apt.pendiente .time {
    color: var(--primary);
}

/* default psychology */
.cal-apt.mindfulness.pendiente .time {
    color: #14b8a6;
}

/* override for mindfulness */
.cal-apt.grupal.pendiente .time {
    color: #f59e0b;
}

/* override for grupal */
.cal-apt.pendiente .name {
    color: var(--text-primary);
}

/* Responsive Mobile Layout */
.header-mobile-toggle {
    display: none;
}

#tabla-pacientes-container {
    overflow-x: auto;
    width: 100%;
}

/* Visibility Toggles */
.mobile-list {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 2rem;
}

.desktop-table {
    display: table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    /* More space between rows */
}

.facturas-table th,
.facturas-table td {
    padding: 1.2rem 1rem !important;
}

.facturas-table th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

@media (max-width: 768px) {
    .app-container {
        padding: 0;
        gap: 0;
    }

    .main-content {
        height: 100vh;
        height: 100dvh;
        width: 100vw;
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        /* Hide off-screen initially */
        top: 0;
        height: 100vh;
        height: 100dvh;
        width: 80%;
        max-width: 320px;
        overflow-y: auto;
        /* Allow sidebar itself to scroll if items don't fit */
        z-index: 1000;
        border-radius: 0;
        background: var(--bg-base);
        /* Solid for readability over content */
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid var(--border-color);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        left: 0;
        /* Slide in */
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        backdrop-filter: blur(4px);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .header-mobile-toggle {
        display: block;
        margin-right: 1rem;
    }

    .header-search {
        display: none;
        /* Hide heavy search bar on small mobile sizes to save space */
    }

    .top-header {
        height: auto;
        min-height: var(--header-height);
        border-radius: 0;
        padding: 0.75rem 1rem;
        border-left: none;
        border-right: none;
        border-top: none;
        flex-direction: column;
        /* Stack header items on mobile */
        gap: 0.75rem;
        align-items: stretch;
    }

    .top-header>div {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .header-actions {
        gap: 0.75rem;
    }

    .content-grid,
    .detail-grid,
    .dashboard-main-grid {
        grid-template-columns: 1fr !important;
        /* Stack columns */
    }

    .content-panel {
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
        /* Do not let the panel itself scroll x, only its children */
    }

    .weekly-calendar {
        display: flex;
        flex-direction: column;
        /* Vertical stacking on mobile as requested */
        gap: 1rem;
        width: 100%;
        margin: 0;
        padding: 0;
        overflow-x: visible;
    }

    .day-column {
        width: 100%;
        min-width: 100%;
        min-height: auto;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.05);
        scroll-snap-align: none;
    }

    .day-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        text-align: left;
    }

    .day-header h4 {
        margin-bottom: 0;
    }

    .day-header .date-num {
        font-size: 1.4rem;
        margin-top: 0;
        font-weight: 800;
    }

    .two-month-container {
        gap: 1.5rem;
    }

    .calendar-prevision-section {
        margin-top: 1rem;
    }

    .calendar-month-grid {
        max-width: 100%;
        width: 100%;
    }

    .view-container {
        padding: 1rem;
        padding-bottom: 80px;
        /* Space for mobile browser nav/keyboard space */
    }

    .grid-cards,
    .stats-grid {
        grid-template-columns: 1fr;
        /* Stack on mobile */
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .stat-card {
        padding: 0.5rem;
        /* Tiny padding */
        gap: 0.5rem;
        flex-direction: column;
        /* Icon over number */
        text-align: center;
    }

    .stat-icon {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
        margin: 0 auto;
    }

    .stat-info h3 {
        font-size: 1.1rem;
    }

    .stat-info p {
        font-size: 0.6rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .page-header {
        margin-bottom: 0.5rem;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .page-header p {
        display: none;
        /* Hide subtitle on mobile to save space */
    }

    /* Mobile Cards for Lists */
    .mobile-card {
        background: white;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 1.2rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        box-shadow: 0 2px 8px rgba(139, 92, 246, 0.05);
        transition: var(--transition);
    }

    .mobile-card:active {
        transform: scale(0.98);
        background: var(--accent);
    }

    .desktop-table {
        display: none !important;
    }

    .mobile-list {
        display: flex !important;
    }

    .header-search.mobile-search-active {
        display: flex !important;
        width: 100%;
        margin: 0;
        order: 2;
        /* Ensure it stays below toggle/actions if needed */
    }
}

/* Calendar Weekend Styling */
.day-column.weekend {
    background: rgba(139, 92, 246, 0.03);
    /* Soft lilac tint for weekends */
}

.day-column.weekend .day-header h4 {
    color: var(--primary);
    opacity: 0.7;
}

/* Glass panel light mode tweak */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.05);
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border-color);
}

.sidebar .logo {
    color: var(--primary);
}

.nav-item {
    color: var(--text-secondary);
}

.nav-item:hover {
    background: var(--accent);
    color: var(--primary);
}

.stat-card.glass-panel {
    background: white;
}


/* Helper Classes */
.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}

.btn-text:hover {
    text-decoration: underline;
}

/* ==========================================================================
   DIPLOMAS GENERATOR STYLES
   ========================================================================== */

.diplomas-layout {
    display: flex;
    gap: 1.5rem;
    height: 100%;
    min-height: 0;
}

@media (max-width: 1024px) {
    .diplomas-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    .diplomas-editor {
        width: 100% !important;
        max-height: none !important;
    }
}

.diplomas-editor {
    width: 380px;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height) - 3rem);
}

.diplomas-preview-pane {
    flex: 1;
    background: rgba(139, 92, 246, 0.02);
    border-radius: var(--border-radius);
    border: 1px dashed var(--border-color);
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    min-height: 350px;
}

/* Diploma Template Container */
.diploma-container {
    width: 100%;
    max-width: 800px;
    box-shadow: 0 15px 40px rgba(139, 92, 246, 0.12);
    border-radius: 12px;
    background: white;
    overflow: hidden;
    transition: var(--transition);
}

.diploma-card {
    width: 100%;
    aspect-ratio: 1.4142; /* A4 landscape aspect ratio */
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    border: none !important;
    padding: 0 !important;
    overflow: hidden;
    background: #faf8ff;
    container-type: inline-size; /* Enable responsive scaling container queries */
}

.diploma-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    z-index: 1;
    pointer-events: none;
}

.diploma-logo {
    position: absolute;
    top: 4.14cqw;
    left: 50%;
    transform: translateX(-50%);
    height: 15.19cqw;
    width: 15.19cqw;
    object-fit: contain;
    z-index: 10;
}

.diploma-content {
    position: absolute;
    top: 38%; /* Subido de 45% para evitar solapamientos */
    left: 8%;
    right: 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.4cqw;
    z-index: 10;
}

.diploma-recipient {
    font-family: 'Fredoka', sans-serif;
    font-size: 3.6cqw;
    color: #1e1b4b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2cqw;
    width: 100%;
}

.diploma-recipient-name {
    font-weight: 700;
    color: #7c3aed; /* Color violeta para que el nombre destaque de forma infantil/vibrante */
}

.diploma-description {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.8cqw;
    line-height: 1.7;
    color: #334155;
    max-width: 82%;
    margin: 0 auto;
    font-weight: 600;
    text-align: center;
}

.diploma-date {
    position: absolute;
    bottom: 13%; /* Bajado al hueco blanco inferior derecho */
    right: 12%; /* Posicionado abajo a la derecha de forma limpia */
    left: auto;
    font-family: 'Quicksand', sans-serif;
    font-size: 1.5cqw;
    font-style: italic;
    font-weight: 600;
    color: #475569;
    z-index: 10;
    text-align: right;
}

.diploma-signature-block {
    position: absolute;
    bottom: 28%; /* Subido para dar espacio a la firma manual abajo */
    left: 50%;
    transform: translateX(-50%);
    width: 45cqw; /* Centrado horizontalmente */
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.diploma-sig-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8cqw;
    font-weight: 600;
    color: #1e1b4b;
    margin-bottom: 0.6cqw; /* Pegado al cargo, dejando la firma abajo */
}

.diploma-sig-title {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.3cqw;
    color: #475569;
    font-weight: 600;
}

/* ==========================================================================
   CSS PRINTING STYLES (A4 Landscape)
   ========================================================================== */

@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }
    
    html, body {
        width: 297mm;
        height: 210mm;
        background: white !important;
        margin: 0;
        padding: 0;
        overflow: hidden;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body * {
        visibility: hidden !important;
    }

    #print-diploma-element, #print-diploma-element * {
        visibility: visible !important;
    }

    #print-diploma-element {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 297mm !important;
        height: 210mm !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        z-index: 9999999 !important;
        display: block !important;
    }

    #print-diploma-element .diploma-card {
        width: 297mm !important;
        height: 210mm !important;
        border: none !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        background: url('../img/diploma_background.png') no-repeat center center !important;
        background-size: 100% 100% !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #print-diploma-element .diploma-bg-image {
        display: block !important;
        width: 297mm !important;
        height: 210mm !important;
    }

    #print-diploma-element .diploma-logo {
        position: absolute !important;
        top: 12.3mm !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        height: 45.1mm !important;
        width: 45.1mm !important;
        object-fit: contain !important;
        display: block !important;
        z-index: 10 !important;
    }

    #print-diploma-element .diploma-content {
        top: 80mm !important;
        left: 24mm !important;
        right: 24mm !important;
        gap: 6mm !important;
    }

    #print-diploma-element .diploma-recipient {
        font-size: 9.5mm !important;
    }

    #print-diploma-element .diploma-description {
        font-size: 4.8mm !important;
        line-height: 1.8 !important;
        max-width: 85% !important;
    }

    #print-diploma-element .diploma-date {
        bottom: 27mm !important;
        right: 35mm !important;
        left: auto !important;
        font-size: 4.5mm !important;
        text-align: right !important;
    }

    #print-diploma-element .diploma-signature-block {
        bottom: 58mm !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 130mm !important;
    }

    #print-diploma-element .diploma-sig-name {
        font-size: 5mm !important;
        margin-bottom: 2mm !important;
    }

    #print-diploma-element .diploma-sig-title {
        font-size: 3.5mm !important;
    }
    .sidebar, .top-header, .diplomas-editor {
        display: none !important;
    }

    .app-container, .main-content, .view-container, .diplomas-layout, .diplomas-preview-pane {
        display: block !important;
        position: static !important;
        height: auto !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
}