:root {
    --primary: #dc2626;
    --primary-hover: #b91c1c;
    --secondary: #64748b;
    --dark: #0f172a;
    --black: #020617;
    --light: #f1f5f9;
    --white: #ffffff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(226, 232, 240, 0.8);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #f1f5f9;
    color: var(--dark);
    line-height: 1.5;
    background-image: none;
    min-height: 100vh;
    padding-bottom: calc(70px + var(--safe-area-bottom));
    overflow-x: hidden;
    /* Prevent horizontal scroll globally */
}

@media (min-width: 769px) {
    body {
        padding-bottom: 0;
    }
}

/* Glassmorphism Classes - Updated for Red/Black Professionalism */
.glass-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    box-shadow: var(--shadow-md);
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
}

h1,
h2,
h3 {
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--black);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    /* Compact padding */
    border-radius: 0.6rem;
    border: 2px solid #f1f5f9;
    background: #f8fafc;
    transition: all 0.2s;
    font-size: 0.95rem;
    color: var(--black);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    /* Compact padding */
    border-radius: 0.6rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    font-size: 0.9rem;
    /* Slightly smaller */
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--black);
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-block {
    display: flex;
    width: 100%;
}

.alert {
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
    background: #f1f5f9;
    min-height: 100vh;
    overflow-x: hidden;
}

@media (min-width: 769px) {
    .main-content {
        margin-left: 280px;
        /* Offset for fixed sidebar */
        width: calc(100% - 280px);
    }
}

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

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

.sidebar {
    background: var(--black);
    color: white;
    padding: 1.5rem 1rem;
    height: 100vh;
    width: 280px;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
}

.sidebar-logo {
    font-size: 1.25rem;
    /* Smaller logo */
    font-weight: 800;
    margin-bottom: 2rem;
    /* Reduced margin */
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-link:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

/* Mobile Bottom Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 2px solid #f1f5f9;
    height: calc(65px + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }
}

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

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

.mobile-nav-item.active {
    color: var(--primary);
}

.main-content {
    background: #f1f5f9;
}

@media (max-width: 768px) {
    .main-content {
        padding: 0.75rem;
        /* Even more compact to prevent grid overflow */
    }
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Changed from center to flex-start for better wrap */
    margin-bottom: 1.25rem;
    gap: 15px;
    /* Increased gap */
    flex-wrap: wrap;
    /* Allow wrapping for large names */
}

.header-bar h2 {
    margin: 0;
    flex-shrink: 0;
    /* Don't shrink the title */
}

.user-profile {
    max-width: 100%;
    /* Ensure it doesn't overflow container */
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .header-bar {
        padding: 0.5rem 0;
        margin-bottom: 1rem;
        align-items: center;
    }

    .header-bar h2 {
        font-size: 1.15rem;
        /* Slightly smaller for more space */
        margin-bottom: 0;
    }

    .user-profile {
        display: none !important;
        /* Hide Institute Name on Mobile Header */
    }
}

/* Stats Grid & Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    /* Further reduced */
    gap: 0.75rem;
    /* Smaller gaps for mobile */
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.25rem;
    background: white;
    border-left: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--black);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background: white;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    vertical-align: middle;
}

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

tr:hover td {
    background: #f8fafc;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    width: 100%;
    max-width: 500px;
}

/* Canvas Signature */
.signature-pad {
    border: 2px dashed #e2e8f0;
    border-radius: 0.75rem;
    background: white;
    cursor: crosshair;
    margin-bottom: 0.5rem;
    max-width: 100%;
}

@media (max-width: 450px) {
    .signature-pad {
        width: 100% !important;
        height: 150px;
    }
}

/* Student Professional Directory Support */
.student-list-mobile {
    display: none;
}

/* Responsive Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    /* Reduced to 280px */
    gap: 1.5rem;
}

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

    .table-container.student-table {
        display: none;
        /* Hide table on mobile */
    }

    .student-list-mobile {
        display: grid;
        gap: 1rem;
        grid-template-columns: 1fr;
    }

    .student-card {
        background: white;
        padding: 1rem;
        border-radius: 1rem;
        border: 1px solid #e2e8f0;
        position: relative;
    }

    .student-card .actions {
        display: flex;
        gap: 8px;
        margin-top: 10px;
        border-top: 1px solid #f1f5f9;
        padding-top: 10px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-red {
    background: rgba(220, 38, 38, 0.1);
    color: var(--primary);
}