/* ============ RESET ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { font-family: 'Segoe UI', -apple-system, Roboto, sans-serif; background: #f0f2f5; color: #222; min-height: 100vh; }

/* ============ HOME PAGE ============ */
.home-page { display: flex; flex-direction: column; min-height: 100vh; }

.home-bg {
    position: fixed; inset: 0; z-index: -1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.home-header {
    text-align: center; padding: 40px 20px 20px; color: #fff;
}
.home-logo {
    width: 90px; height: 90px; border-radius: 50%;
    background: #fff; padding: 8px; object-fit: contain;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.home-header h1 { font-size: 1.5rem; margin: 15px 0 5px; font-weight: 700; }
.home-header p { font-size: 0.9rem; opacity: 0.85; }

.home-boxes {
    flex: 1; display: flex; flex-direction: column; gap: 20px;
    padding: 30px 20px; max-width: 600px; width: 100%; margin: 0 auto;
}

.home-box {
    position: relative; display: block; text-decoration: none;
    background: #fff; border-radius: 20px; padding: 30px 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transition: transform 0.25s, box-shadow 0.25s;
    color: #222; overflow: hidden;
}
.home-box::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 6px; height: 100%;
}
.box-attendance::before { background: linear-gradient(180deg, #28a745, #20c997); }
.box-manager::before    { background: linear-gradient(180deg, #007bff, #6610f2); }
.home-box:active { transform: scale(0.97); }
.home-box:hover  { box-shadow: 0 15px 40px rgba(0,0,0,0.22); }

.box-icon {
    width: 60px; height: 60px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #fff; margin-bottom: 15px;
}
.box-attendance .box-icon { background: linear-gradient(135deg, #28a745, #20c997); }
.box-manager .box-icon    { background: linear-gradient(135deg, #007bff, #6610f2); }

.home-box h2 { font-size: 1.3rem; margin-bottom: 5px; }
.home-box p  { color: #777; font-size: 0.9rem; }
.box-arrow {
    position: absolute; right: 25px; top: 50%; transform: translateY(-50%);
    font-size: 1.5rem; color: #ccc; transition: 0.25s;
}
.home-box:hover .box-arrow { color: #333; right: 20px; }

.home-footer { text-align: center; padding: 20px; color: #fff; font-size: 0.85rem; opacity: 0.8; }

/* ============ ATTENDANCE PAGE ============ */
.att-page { padding-bottom: 80px; }
.att-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff; padding: 20px; position: sticky; top: 0; z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.att-header-inner { display: flex; align-items: center; gap: 15px; max-width: 1200px; margin: 0 auto; }
.att-back {
    width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center; color: #fff;
    text-decoration: none; font-size: 1.1rem;
}
.att-title h1 { font-size: 1.2rem; }
.att-title p  { font-size: 0.85rem; opacity: 0.85; }

.att-summary {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    padding: 15px; max-width: 1200px; margin: 0 auto;
}
.summary-card {
    background: #fff; border-radius: 15px; padding: 15px 10px; text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.summary-card .num  { font-size: 1.6rem; font-weight: 700; }
.summary-card .lbl  { font-size: 0.75rem; color: #888; text-transform: uppercase; margin-top: 3px; }
.summary-card.total .num   { color: #007bff; }
.summary-card.present .num { color: #28a745; }
.summary-card.absent .num  { color: #dc3545; }

.att-search { padding: 0 15px 15px; max-width: 1200px; margin: 0 auto; }
.att-search input {
    width: 100%; padding: 12px 18px; border-radius: 12px; border: 1px solid #ddd;
    font-size: 1rem; outline: none; background: #fff;
}
.att-search input:focus { border-color: #007bff; }

.att-grid {
    display: grid; grid-template-columns: 1fr; gap: 12px;
    padding: 0 15px; max-width: 1200px; margin: 0 auto;
}
@media (min-width: 600px) { .att-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .att-grid { grid-template-columns: repeat(3, 1fr); } }

.emp-card {
    background: #fff; border-radius: 18px; padding: 18px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); display: flex; gap: 15px; align-items: center;
    transition: 0.25s; border-left: 5px solid #ddd;
}
.emp-card.present { border-left-color: #28a745; }
.emp-card.absent  { border-left-color: #dc3545; }

.emp-photo {
    width: 65px; height: 65px; border-radius: 50%; object-fit: cover;
    border: 3px solid #f0f2f5; flex-shrink: 0;
}
.emp-info { flex: 1; min-width: 0; }
.emp-info h3 { font-size: 1rem; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-info p  { font-size: 0.8rem; color: #888; }
.emp-badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600; margin-top: 5px;
}
.badge-present { background: #d4edda; color: #155724; }
.badge-absent  { background: #f8d7da; color: #721c24; }

.btn-present {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff; border: none; padding: 12px 20px; border-radius: 12px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: 0.25s;
    white-space: nowrap; box-shadow: 0 4px 12px rgba(40,167,69,0.3);
}
.btn-present:active { transform: scale(0.95); }
.btn-present:disabled { background: #ccc; box-shadow: none; cursor: not-allowed; }

.att-thumb {
    width: 50px; height: 50px; border-radius: 10px; object-fit: cover;
    border: 2px solid #28a745;
}

/* ============ MODAL CAMERA ============ */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92);
    z-index: 9999; align-items: center; justify-content: center; padding: 15px;
}
.modal-overlay.active { display: flex; }

.camera-modal {
    background: #fff; border-radius: 20px; width: 100%; max-width: 480px;
    overflow: hidden; max-height: 95vh; display: flex; flex-direction: column;
}
.camera-head {
    padding: 15px 20px; background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff; display: flex; justify-content: space-between; align-items: center;
}
.camera-head h3 { font-size: 1rem; }
.camera-close {
    background: rgba(255,255,255,0.2); border: none; color: #fff;
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1rem;
}

.camera-body { padding: 15px; flex: 1; overflow-y: auto; }
.camera-video-wrap {
    position: relative; background: #000; border-radius: 15px; overflow: hidden;
    aspect-ratio: 3/4;
}
#video, #preview { width: 100%; height: 100%; object-fit: cover; display: block; }
#preview { display: none; }

.camera-overlay {
    position: absolute; inset: 0; pointer-events: none;
    display: flex; align-items: center; justify-content: center;
}
.face-guide {
    width: 65%; height: 75%; border: 3px dashed rgba(255,255,255,0.7);
    border-radius: 50% 50% 45% 45%; animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { border-color: rgba(255,255,255,0.7); }
    50% { border-color: rgba(40,167,69,0.9); }
}

.camera-actions {
    display: flex; gap: 10px; margin-top: 15px;
}
.btn-capture {
    flex: 1; padding: 14px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff; font-weight: 600; font-size: 1rem; cursor: pointer;
}
.btn-save {
    flex: 1; padding: 14px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff; font-weight: 600; font-size: 1rem; cursor: pointer;
    display: none;
}
.btn-retake {
    flex: 1; padding: 14px; border: none; border-radius: 12px;
    background: #6c757d; color: #fff; font-weight: 600; font-size: 1rem;
    cursor: pointer; display: none;
}

/* ============ LOADING ============ */
.spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ TOAST ============ */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
    background: #28a745; color: #fff; padding: 14px 24px; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 99999;
    font-weight: 600; transition: transform 0.4s; max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #dc3545; }

/* ============ LOGIN ============ */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
}
.login-card {
    background: #fff; border-radius: 20px; padding: 35px 25px;
    width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 { text-align: center; font-size: 1.4rem; margin-bottom: 5px; }
.login-card p  { text-align: center; color: #888; margin-bottom: 25px; font-size: 0.9rem; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 0.85rem; margin-bottom: 6px; color: #555; font-weight: 600; }
.form-group input {
    width: 100%; padding: 12px 15px; border: 1px solid #ddd;
    border-radius: 10px; font-size: 1rem; outline: none; transition: 0.2s;
}
.form-group input:focus { border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }
.btn-login {
    width: 100%; padding: 14px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 10px;
}
.btn-login:active { transform: scale(0.98); }
.login-error {
    background: #f8d7da; color: #721c24; padding: 12px; border-radius: 10px;
    margin-bottom: 15px; font-size: 0.9rem; text-align: center;
}