/* Admin Portal Styles - Dark Mode App Redesign */

:root {
    --admin-bg: #151517;
    /* iOS Dark Background */
    --card-bg: #212124;
    /* Slightly lighter for cards */
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    /* iOS Gray */
    --accent-color: #0a84ff;
    /* iOS Blue */
    --sidebar-width: 260px;
    --sidebar-bg: #000000;
    --success: #30d158;
    /* iOS Green */
    --danger: #ff453a;
    /* iOS Red */
    --warning: #ffd60a;
}

body {
    background-color: var(--admin-bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    margin: 0;
    padding-bottom: 80px;
    /* Space for Bottom Nav */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow-y: auto;
    /* Allow body scroll */
    width: 100%;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

/* Bottom Navigation (Mobile Only) */
.bottom-nav {
    display: none;
    /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(30, 30, 30, 0.95);
    /* Blur effect base */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 9999;
    /* Max Z-Index for Navigation */
    justify-content: space-around;
    padding: 10px 0 20px 0;
    /* Extra padding for iOS Home Indicator */
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 4px;
}

.bottom-nav-item.active {
    color: var(--accent-color);
}

.bottom-nav-icon {
    font-size: 1.5rem;
}

/* Authentication State */
body.not-authenticated #app-layout,
body.not-authenticated .bottom-nav,
body.not-authenticated #app-greeting {
    display: none !important;
}

body:not(.not-authenticated) #login-overlay {
    display: none !important;
}

/* Login Overlay - Dark Mode */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--admin-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.login-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 400px;
    text-align: center;
    color: white;
}

.login-card input {
    background: #2c2c2e;
    border: none;
    color: white;
}

/* Layout */

#sidebar {
    width: 250px;
    background: var(--card-bg);
    /* Use card-bg for contrast */
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    padding: 2rem 1.5rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: none;
    /* Shadow handles separation */
}

/* Sidebar Branding */
.brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Nav Links */
.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.nav-item {
    display: block;
    padding: 12px 16px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
    cursor: pointer;
}

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

.nav-item.active {
    background: var(--color-blue-deep);
    color: white;
}

/* Sidebar Footer (Logout) */
.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
}

#logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: rgba(255, 69, 58, 0.1);
    /* Subtle red bg */
    color: var(--danger);
    border: 1px solid rgba(255, 69, 58, 0.3);
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
}

#logout-btn:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 69, 58, 0.3);
}

#main-content {
    margin-left: 250px;
    flex: 1;
    padding: 2rem;
    width: calc(100% - 250px);
    box-sizing: border-box;
}

/* Hide Mobile Toggle on Desktop */
#sidebar-toggle {
    display: none;
}

/* Stats Cards (Dark Mode) */
.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border */
    border-left: none;
    /* Removed the colored left border for a cleaner look */
}

.stat-value {
    color: #ffffff !important;
    /* Force white text */
    font-weight: 700;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

/* Forms (Dark Mode) */
.form-group label {
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    background: #2c2c2e;
    border: none;
    color: white;
    border-radius: 12px;
}

.form-group input:focus,
.form-group select:focus {
    background: #3a3a3c;
    box-shadow: 0 0 0 2px var(--accent-color);
}

/* Table / List Items (Dark Mode) */
.data-table tbody tr {
    background: var(--card-bg);
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table tbody tr:hover {
    background: #2c2c2e;
}

.data-table td {
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table th,
.data-table td {
    padding: 1rem 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
    /* Keep rows single line */
}



/* Modal (Dark Mode) */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--card-bg);
    color: white;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    opacity: 0;
    animation: modalPop 0.3s ease-out forwards;
}

@keyframes modalPop {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile Toggle - High Visibility */
/* Mobile Toggle - Defined in Media Query for Mobile Only */
/* (This block removed to avoid desktop conflict) */

/* Mobile Optimization */
@media (max-width: 768px) {

    /* Sidebar Behavior on Mobile */
    #sidebar {
        transform: translateX(-100%);
        /* Hidden by default */
        width: 80%;
        /* Takes most of the screen when open */
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        will-change: transform;
        padding-top: 2rem;
        /* Standard padding */
    }

    #sidebar.active {
        transform: translateX(0);
    }

    /* Show Sidebar Toggle */
    #sidebar-toggle {
        display: flex !important;
        /* Force show */
        position: fixed;
        bottom: 90px;
        /* Above bottom nav */
        right: 20px;
        /* Accessible from right thumb */
        top: auto;
        /* Unlock top */
        left: auto;
        /* Unlock left */
        z-index: 10001;
        /* Above almost everything */
        background: var(--color-blue-deep);
        color: white;
        border: none;
        border-radius: 50%;
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    /* Show Bottom Nav */
    .bottom-nav {
        display: flex;
    }

    /* Main Content Adjustments */
    #main-content {
        margin-left: 0;
        padding: 5rem 1rem 6rem 1rem;
        width: 100%;
    }

    /* Greeting Header Styles */
    .greeting-header {
        margin-bottom: 2rem;
    }

    .greeting-date {
        font-size: 0.9rem;
        color: var(--text-secondary);
        text-transform: capitalize;
        margin-bottom: 0.3rem;
    }

    .greeting-title {
        font-size: 1.8rem;
        font-weight: 800;
        color: white;
    }

    /* Dark Mode Table List Style */
    .data-table-container {
        width: 100vw;
        margin-left: -1rem;
        background: transparent;
    }

    .data-table td {
        border-bottom: 1px solid #2c2c2e;
        padding: 12px 1rem;
    }


    /* RESTORE TABLE (User Req: Edge-to-Edge 9:16) */
    .data-table-container {
        display: block;
        overflow-x: hidden;
        width: 100vw;
        /* Force Viewport Width */
        margin-left: -0.2rem;
        /* Negate parent padding */
        padding: 0;
        margin-top: 5px;
    }

    /* Style the table for vertical feel */
    .data-table {
        width: 100% !important;
        margin: 0;
        border-collapse: separate;
        border-spacing: 0 4px;
        table-layout: fixed;
    }

    .data-table th,
    .data-table td {
        padding: 8px 2px;
        /* Super tight padding */
        font-size: 0.8rem;
        white-space: normal;
        word-break: break-word;
        border: none;
    }

    /* Column Sizing (Mobile) */
    .data-table th:nth-child(1),
    .data-table td:nth-child(1) {
        width: 45%;
    }

    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        width: 35%;
    }

    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        width: 20%;
        text-align: right;
    }

    /* Hide Scrollbar for Chrome/Safari */
    .data-table-container::-webkit-scrollbar {
        display: none;
    }
}

/* END OF MOBILE QUERY */

/* Responsive Utilities (Outside Media Query) */
.desktop-only {
    display: table-cell;
    /* Default for desktop */
}

.mobile-only {
    display: none;
    /* Hidden on desktop */
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }
}






/* CRM Features - Base Styles */
.crm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.crm-controls {
    display: flex;
    gap: 1rem;
    flex: 1;
    align-items: center;
    flex-wrap: wrap;
}

.search-bar {
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #2c2c2e;
    color: white;
    border-radius: 12px;
    width: 280px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.search-bar:focus {
    border-color: var(--accent-color);
    background: #3a3a3c;
}

.filter-scroll {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #2c2c2e;
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Mobile Controls Optimization */
@media (max-width: 768px) {
    .crm-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 1.5rem;
    }

    .search-bar {
        width: 100%;
        /* Full width search */
        box-sizing: border-box;
        font-size: 1rem;
        /* Better for touch */
    }

    .filter-scroll {
        overflow-x: auto;
        padding-bottom: 4px;
        /* Space for scrollbar if any */
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar but keep functionality */
        scrollbar-width: none;
    }

    .filter-scroll::-webkit-scrollbar {
        display: none;
    }

    .filter-btn {
        flex: 0 0 auto;
        /* Don't shrink */
        padding: 8px 20px;
        /* Larger tap area */
        font-size: 0.9rem;
    }
}

/* Toast Notifications (User Feedback) */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    animation: slideUpFade 0.3s forwards;
    border-left: 4px solid var(--color-blue-deep);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-msg {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

@keyframes slideUpFade {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Cards (Hidden on Desktop) */
.student-cards-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.student-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-left: 5px solid #ddd;
}

.student-card.status-Activo {
    border-left-color: var(--success);
}

.student-card.status-Vencido {
    border-left-color: var(--danger);
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-name {
    font-size: 1.2rem;
    font-weight: bold;
}

.card-details {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
}

/* Status Badges */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.badge-success {
    background-color: rgba(48, 209, 88, 0.2);
    color: var(--success);
    border: 1px solid rgba(48, 209, 88, 0.3);
}

.badge-danger {
    background-color: rgba(255, 69, 58, 0.2);
    color: var(--danger);
    border: 1px solid rgba(255, 69, 58, 0.3);
}

.badge-warning {
    background-color: rgba(255, 214, 10, 0.2);
    color: var(--warning);
    border: 1px solid rgba(255, 214, 10, 0.3);
}