/* ============================================
   SISTEM ABSENSI SISWA - STYLESHEET
   ============================================ */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --success-dark: #16a34a;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.school-icon {
    font-size: 64px;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-700);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 16px;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

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

.btn-warning:hover:not(:disabled) {
    background: var(--warning-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-logout {
    background: var(--danger);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-logout:hover {
    background: var(--danger-dark);
}

.btn-block {
    width: 100%;
}

.btn-camera {
    background: var(--primary);
    color: white;
    font-size: 18px;
    padding: 16px 32px;
}

.btn-capture {
    background: var(--danger);
    color: white;
    font-size: 18px;
    padding: 16px 32px;
    animation: pulse 2s infinite;
}

.btn-retake {
    background: var(--gray-500);
    color: white;
    font-size: 16px;
    padding: 12px 24px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    margin-top: 10px;
}

.btn-back {
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 8px 16px;
    font-size: 14px;
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: white;
    border-radius: var(--radius);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    font-size: 24px;
    color: var(--gray-900);
}

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

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-info strong {
    color: var(--gray-900);
}

.user-info small {
    color: var(--gray-500);
    font-size: 12px;
}

/* ============================================
   STATUS SECTION
   ============================================ */
.status-section {
    margin-bottom: 24px;
}

.status-card {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow);
}

.status-card h2 {
    font-size: 18px;
    color: var(--gray-500);
    margin-bottom: 15px;
}

.time-display {
    margin-bottom: 20px;
}

.current-time {
    display: block;
    font-size: 48px;
    font-weight: bold;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.current-date {
    display: block;
    font-size: 16px;
    color: var(--gray-500);
    margin-top: 5px;
}

.status-info {
    margin-top: 15px;
}

.status-badge {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
}

.status-badge.loading {
    background: var(--gray-200);
    color: var(--gray-500);
}

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

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

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

.status-badge.checkin-done {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge.checkout-done {
    background: #e0e7ff;
    color: #3730a3;
}

/* ============================================
   CAMERA SECTION
   ============================================ */
.camera-section {
    margin-bottom: 24px;
}

.camera-container {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.camera-preview {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto 24px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-900);
    aspect-ratio: 4/3;
}

.camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.face-guide {
    width: 200px;
    height: 200px;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

.camera-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   PHOTO RESULT
   ============================================ */
.photo-result {
    margin-top: 24px;
    text-align: center;
}

.photo-result img {
    max-width: 320px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.photo-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ============================================
   HISTORY SECTION
   ============================================ */
.history-section {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.history-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--gray-900);
}

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

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

.mini-table th,
.mini-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.mini-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 14px;
}

.mini-table td {
    font-size: 14px;
}

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

.status-mini {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-mini.hadir {
    background: #dcfce7;
    color: #166534;
}

.status-mini.terlambat {
    background: #fef3c7;
    color: #92400e;
}

.status-mini.alpha {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================
   FILTER & STATS
   ============================================ */
.filter-section {
    margin-bottom: 24px;
}

.filter-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px 30px;
    display: flex;
    gap: 20px;
    align-items: center;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.filter-card label {
    font-weight: 600;
    color: var(--gray-700);
}

.filter-card select {
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
}

.stats-section {
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    display: block;
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-500);
}

.stat-hadir .stat-number { color: var(--success); }
.stat-terlambat .stat-number { color: var(--warning); }
.stat-alpha .stat-number { color: var(--danger); }
.stat-total .stat-number { color: var(--primary); }

/* ============================================
   TABLE
   ============================================ */
.table-section {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

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

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

.history-table-full th,
.history-table-full td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.history-table-full th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

.history-table-full img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-table-full img:hover {
    transform: scale(1.5);
}

.loading-cell {
    text-align: center;
    padding: 40px !important;
    color: var(--gray-500);
}

/* ============================================
   UTILITY
   ============================================ */
.text-center { text-align: center; }
.loading-text { color: var(--gray-500); text-align: center; padding: 20px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }
    
    .header-right {
        flex-direction: column;
    }
    
    .user-info {
        text-align: center;
    }
    
    .current-time {
        font-size: 36px;
    }
    
    .camera-preview {
        max-width: 100%;
    }
    
    .btn-camera,
    .btn-capture {
        width: 100%;
    }
    
    .filter-card {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============================================
   PHOTO MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    background: none;
    border: none;
}
