:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg-base: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-w: 280px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

body.dark-mode {
    --bg-base: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Login Page */
#login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    padding: 20px;
}

.login-card {
    background-color: var(--bg-card);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header h1 {
    font-size: 1.5rem;
    margin: 15px 0 5px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 3rem;
    color: var(--primary);
}

.form-group {
    text-align: left;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-with-icon input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background-color: var(--bg-base);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.3s;
}

.input-with-icon input:focus {
    border-color: var(--primary);
}

#login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#login-btn:hover {
    background-color: var(--primary-hover);
}

.login-footer {
    margin-top: 30px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Portal App Layout */
#portal-app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
#student-sidebar {
    width: var(--sidebar-w);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.student-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.student-avatar {
    width: 48px;
    height: 48px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.student-meta h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.student-meta p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius);
    margin-bottom: 5px;
    font-weight: 500;
    transition: all 0.2s;
}

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

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

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: none;
    border: none;
    color: var(--error);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color 0.2s;
}

.logout-btn:hover {
    background-color: #fee2e2;
}

/* Main Content Area */
#portal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#portal-topbar {
    padding: 16px 32px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#page-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

#current-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-main);
}

#portal-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Dashboard Cards */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.dash-card {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

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

.dash-card-header i {
    font-size: 1.5rem;
    color: var(--primary);
}

.dash-card-header span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.dash-card-val {
    font-size: 1.8rem;
    font-weight: 800;
}

.dash-card-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Webcam Attendance */
.webcam-container {
    width: 640px;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background-color: #000;
    box-shadow: var(--shadow-lg);
}

#webcam-video {
    width: 100%;
    display: block;
}

.webcam-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.face-guide {
    width: 250px;
    height: 300px;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 50%;
}

.webcam-controls {
    text-align: center;
    margin-top: 24px;
}

/* Table Design */
.data-table-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

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

.data-table th {
    background-color: var(--bg-base);
    text-align: left;
    padding: 16px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

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

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
}

.toast {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-top: 10px;
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* Modal */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#modal-box {
    background-color: var(--bg-card);
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

#modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}