:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --dark: #0f172a;
    --darker: #020617;
    --light: #f8fafc;
    --white: #FFFFFF;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-100: #f1f5f9;
    --gray-400: #94a3b8;
    --gray-800: #1e293b;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    background-color: var(--light);
    color: var(--gray-800);
    line-height: 1.6;
}

/* Authentication Page */
.auth-content {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at top left, var(--primary) 0%, var(--darker) 100%);
    position: relative;
    overflow: hidden;
}

.auth-content::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 150%;
    background: url('https://www.transparenttextures.com/patterns/cubes.png');
    opacity: 0.05;
    animation: rotate 100s linear infinite;
}

@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 3.5rem;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 460px;
    text-align: center;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255,255,255,0.3);
}

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

.login-card h1 {
    margin-bottom: 2rem;
    color: var(--dark);
    font-weight: 700;
}

.login-card h1 span {
    color: var(--primary);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-800);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #D1D5DB;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.btn {
    display: inline-block;
    font-family: inherit;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    transition: all 0.3s;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success { background-color: var(--secondary); color: var(--white); }
.btn-danger { background-color: var(--danger); color: var(--white); }

/* Layout App */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: 260px;
    background-color: var(--darker);
    color: var(--white);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease-in-out;
    z-index: 1000;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    padding: 1.5rem 0;
    flex: 1;
}

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--gray-400);
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-links li a i {
    margin-right: 10px;
    font-size: 1.25rem;
}

.nav-links li a:hover, .nav-links li a.active {
    background-color: rgba(255,255,255,0.05);
    color: var(--white);
    border-left: 4px solid var(--primary);
}

.logout {
    color: var(--danger) !important;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--light);
    min-width: 0; /* Prevent overflow */
}

.top-header {
    background-color: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--dark);
    padding: 0.5rem;
    border-radius: 8px;
    background: var(--light);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--primary);
    color: var(--white);
}

.content {
    padding: 1.5rem;
    flex: 1;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
    }

    .sidebar.active {
        left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .content {
        padding: 1rem;
    }

    .top-header {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    /* Ultra-compact mobile row view */
    .mobile-card-view .table-responsive table,
    .mobile-card-view .table-responsive thead,
    .mobile-card-view .table-responsive tbody,
    .mobile-card-view .table-responsive th,
    .mobile-card-view .table-responsive td,
    .mobile-card-view .table-responsive tr {
        display: block;
    }

    .mobile-card-view .table-responsive thead {
        display: none;
    }

    .mobile-card-view .table-responsive tr {
        margin-bottom: 0.6rem;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: white;
        padding: 0.6rem;
        position: relative;
        min-height: 70px;
    }

    .mobile-card-view .table-responsive td {
        border: none;
        padding: 0.15rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        font-size: 0.75rem;
    }

    /* Prioritize Photo and Name at the top */
    .mobile-card-view .table-responsive td[data-label="Photo"] {
        position: absolute;
        top: 0.6rem;
        left: 0.6rem;
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
        z-index: 2;
    }

    .mobile-card-view .table-responsive td[data-label="Student Name"],
    .mobile-card-view .table-responsive td[data-label="Name"] {
        padding-left: 50px;
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--primary);
        text-align: left;
        display: block;
        margin-bottom: 0.3rem;
        min-height: 20px;
    }

    .mobile-card-view .table-responsive td[data-label="Photo"]::before,
    .mobile-card-view .table-responsive td[data-label="Student Name"]::before,
    .mobile-card-view .table-responsive td[data-label="Name"]::before {
        display: none;
    }

    .mobile-card-view .table-responsive td:not([data-label="Photo"]):not([data-label="Student Name"]):not([data-label="Name"]):not([data-label="SL"]):not([data-label="Actions"])::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        margin-right: 1rem;
        color: var(--gray-400);
        font-size: 0.7rem;
    }

    .mobile-card-view .table-responsive td[data-label="SL"] {
        position: absolute;
        top: 0.4rem;
        right: 0.6rem;
        font-size: 0.65rem;
        color: var(--gray-400);
        width: auto;
    }
    .mobile-card-view .table-responsive td[data-label="SL"]::before { display: none; }

    .mobile-card-view .table-responsive td[data-label="Actions"] {
        border-top: 1px solid #f1f5f9;
        margin-top: 0.4rem;
        padding-top: 0.4rem;
    }
}

/* Cards & Dashboards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--gray-100);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-glow);
}

.stat-info h3 {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
}

.stat-info .num {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background-color: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.25rem;
}

.card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--gray-100);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 1.25rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

th {
    font-weight: 700;
    color: var(--gray-400);
    background-color: #fcfdfe;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: 0;
}

tr:hover {
    background-color: #fcfdfe;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 0.5rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-btn {
    float: right;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
}

.close-btn:hover {
    color: var(--dark);
}

.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}
.alert-danger {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #F87171;
}
.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #34D399;
}
