/* Modern CSS for TTU Attendance Portal */
:root {
    --primary: #2563eb; /* Blue 600 */
    --primary-dark: #1d4ed8; /* Blue 700 */
    --accent: #f59e0b; /* Amber 500 */
    --bg-main: #f8fafc; /* Slate 50 */
    --bg-card: #ffffff;
    --text-main: #1e293b; /* Slate 800 */
    --text-muted: #64748b; /* Slate 500 */
    --success: #22c55e; /* Green 500 */
    --warning: #facc15; /* Yellow 400 */
    --danger: #ef4444; /* Red 500 */
    --border: #e2e8f0; /* Slate 200 */
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Cairo', 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    direction: rtl; /* Right To Left Support */
    padding-bottom: 2rem;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Hero Section Styles */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.logo i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.logo h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.logo p {
    color: var(--text-muted);
}

/* Card Styles */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease;
}

/* Search Box Container */
.search-box {
    margin-top: 2rem;
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
}

.input-group label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.search-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#studentId {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s ease;
    text-align: center;
}

#studentId:focus {
    border-color: var(--primary);
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.helper-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Profile Section Styles */
.student-profile {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--bg-card) 0%, #f1f5f9 100%);
}

.profile-icon {
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.profile-details h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.profile-details p {
    color: var(--text-muted);
}

.profile-details span {
    font-weight: 600;
    color: var(--primary);
}

/* Attendance Display Grid/Cards */
.attendance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
}

.course-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border-right: 5px solid var(--primary);
    transition: transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

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

.course-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.course-code {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.course-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.section-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.absence-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.absence-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.count-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}

/* Status Badge for Withdrawn/etc */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    background-color: var(--danger);
    color: white;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Absence Colors Status */
.status-success .count-badge { background-color: var(--success); }
.status-warning .count-badge { background-color: var(--accent); }
.status-danger .count-badge { background-color: var(--danger); }

/* Details Section (Absence values list) */
.absence-details-list {
    margin-top: 1rem;
    font-size: 0.85rem;
    background-color: #f8fafc;
    border-radius: 8px;
    padding: 0.8rem;
}

.absence-details-list h4 {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #e2e8f0;
}

.absence-details-list ul {
    list-style: none;
    font-family: inherit;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.absence-details-list li {
    background-color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    color: var(--text-main);
    font-weight: 600;
}

/* Result Helper Footer */
.data-footer {
    width: 100%;
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Animations and Transitions */
.hidden { display: none !important; }

.loader-container {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border);
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Section Styles */
.error-container {
    text-align: center;
    padding: 3rem;
    color: var(--danger);
    background-color: #fef2f2;
    border-color: #fee2e2;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* General Footer */
.main-footer {
    text-align: center;
    margin-top: 4rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.muted-text { font-size: 0.8rem; margin-top: 0.5rem; }

/* Responsive Adjustments */
@media (max-width: 480px) {
    .app-container { padding: 1rem 0.8rem; }
    .hero { margin-bottom: 2rem; }
    .logo h1 { font-size: 1.8rem; }
    .search-input { flex-direction: column; }
    .primary-btn { width: 100%; }
    .student-profile { flex-direction: column; text-align: center; padding: 2rem; }
}

/* ========================================= */
/* admin Dashboard Styles                    */
/* ========================================= */

.admin-page .app-container {
    max-width: none;
    width: 100%;
    padding: 0;
}

.admin-header {
    background-color: var(--primary);
    color: white;
    padding: 1rem 0;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1400px;
    width: 95%;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.nav-link:hover {
    opacity: 1;
}

.admin-main {
    max-width: 1400px;
    width: 95%;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

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

.stat-icon.students { background-color: #dbeafe; color: #2563eb; }
.stat-icon.risk { background-color: #fee2e2; color: #ef4444; }
.stat-icon.course { background-color: #fef3c7; color: #d97706; }
.stat-icon.clock { background-color: #f1f5f9; color: #64748b; }

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.stat-value.small {
    font-size: 0.8rem;
    font-weight: 600;
}

/* Filter Controls */
.admin-controls {
    padding: 2rem;
    margin-bottom: 2rem;
}

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

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-item label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.filter-item select, 
.filter-item input {
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    width: 100%;
    padding-right: 2.5rem;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.success-btn {
    background-color: var(--success);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.success-btn:hover, .warning-btn:hover { opacity: 0.9; }

/* Data Table */
.results-table-container {
    padding: 0;
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

#attendanceTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

#attendanceTable th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

#attendanceTable th.sortable:hover {
    background-color: #e2e8f0;
}

#attendanceTable th i {
    margin-right: 0.5rem;
    font-size: 0.8rem;
    color: #cbd5e1;
}

#attendanceTable th.active-sort i {
    color: var(--primary);
}

#attendanceTable td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#attendanceTable tr:hover {
    background-color: #f1f5f9;
    cursor: pointer;
}

.row-warning { background-color: #fffbeb; }
.row-danger { background-color: #fff7ed; }
.row-critical { background-color: #fef2f2; }

.row-warning:hover { background-color: #fef3c7 !important; }
.row-danger:hover { background-color: #ffedd5 !important; }
.row-critical:hover { background-color: #fee2e2 !important; }

.active-filter-card {
    border: 2px solid var(--danger) !important;
    background-color: #fef2f2 !important;
    transform: translateY(-5px);
    box-shadow: 0 8px 15px -3px rgba(239, 68, 68, 0.2);
}

.badge-outline {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid currentColor;
}

.badge-success { color: var(--success); }
.badge-warning { color: var(--accent); }
.badge-danger { color: var(--danger); }

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #334155;
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: var(--shadow);
    z-index: 1000;
    font-weight: 600;
    transition: opacity 0.3s, transform 0.3s;
}

.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 1rem; padding: 1rem; }
    .action-buttons { flex-direction: column; }
    .action-buttons button { width: 100%; justify-content: center; }
}

/* Checkbox Custom Styles */
.status-checkbox {
    justify-content: flex-end;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    user-select: none;
    color: var(--text-main);
    padding: 0.5rem 0;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 22px;
    width: 22px;
    background-color: #eee;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.checkbox-container:hover input ~ .checkmark {
    background-color: #ccc;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

/* Login Modal Styles */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-icon {
    width: 64px;
    height: 64px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 1.5rem;
}

.auth-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.auth-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.auth-input-group {
    margin-bottom: 1.5rem;
    text-align: right;
}

.auth-input-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.auth-input-wrapper {
    position: relative;
}

.auth-input-wrapper i:not(.toggle-password) {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none; /* Decorative icons shouldn't block input */
}

.auth-input-wrapper input {
    width: 100%;
    padding: 0.8rem 2.5rem; /* Symmetry for icons on both sides */
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.auth-input-wrapper input:focus {
    border-color: var(--primary);
}

.toggle-password {
    position: absolute;
    left: 1rem;
    right: auto; /* Prevent stretching when generic 'i' style sets right */
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    pointer-events: auto; /* Ensure icon is clickable */
    z-index: 10;
}

.toggle-password:hover {
    color: var(--primary);
}

.auth-btn {
    width: 100%;
    padding: 0.8rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.auth-btn:hover {
    background-color: var(--primary-dark);
}

.auth-error {
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 1rem;
}

/* Action Buttons in Table */
.copy-btn {
    background-color: #f1f5f9;
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

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

.copy-btn i {
    font-size: 0.9rem;
    color: inherit !important; /* Override standard th/td icon coloring */
}

.actions-header {
    width: 130px;
    text-align: center !important;
}

.actions-cell {
    text-align: center !important;
}
