@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

:root {
    --primary-brown: #7f5539;
    --light-brown: #b08968;
    --tan: #ddb892;
    --very-light: #ede0d4;
    --white: #ffffff;
    --error: #ae2012;
    --success: #008000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--very-light), var(--white));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
    color: #432818;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(127, 85, 57, 0.15);
    backdrop-filter: blur(10px);
    margin-top: 10px;
}

/* Typography */
h1 { font-size: 1.4rem; text-align: center; margin-bottom: 20px; color: var(--primary-brown); }
h2 { font-size: 1.1rem; margin-bottom: 15px; color: var(--light-brown); }
p { font-size: 0.9rem; line-height: 1.5; margin-bottom: 15px; }
.app-logo {
    width: 82px;
    height: 82px;
    display: block;
    margin: 0 auto 12px;
    object-fit: contain;
}

/* Forms */
.form-group { margin-bottom: 15px; width: 100%; }
label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 5px; color: var(--primary-brown); }
input, select {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--tan);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--white);
    outline: none;
}
input:focus, select:focus { border-color: var(--primary-brown); }

/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    margin-bottom: 10px;
}
.btn-primary { background: var(--primary-brown); color: var(--white); }
.btn-secondary { background: var(--tan); color: var(--primary-brown); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary-brown); color: var(--primary-brown); }
.btn:disabled { background: #ccc !important; color: #888 !important; cursor: not-allowed; border-color: #ccc !important; }

.hidden { display: none !important; }

/* Camera */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
}
video, canvas { width: 100%; height: 100%; object-fit: cover; }
.challenge-overlay {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    border: 1px solid var(--tan);
}

/* Status Messages */
.status-msg { font-size: 0.85rem; padding: 12px; border-radius: 10px; margin-bottom: 15px; text-align: center; }
.status-info { background: var(--very-light); color: var(--primary-brown); }
.status-error { background: #ffe3e0; color: var(--error); }
.status-success { background: #e7f5e7; color: var(--success); }

.attendance-status {
    background: var(--very-light);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-brown);
}
.attendance-status div { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 5px; }

.logout-link { display: block; text-align: center; font-size: 0.85rem; color: var(--light-brown); text-decoration: underline; margin-top: 20px; cursor: pointer; }
.app-footer {
    margin-top: 14px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--light-brown);
    line-height: 1.4;
}

/* Loading Spinner */
.loader {
    display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s infinite linear; margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Report Screen UI --- */
#report-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #f8f4f0; z-index: 10000; display: flex; flex-direction: column;
}
.report-header { background: var(--white); padding: 15px 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border-bottom: 1px solid var(--tan); }
.report-header h1 { font-size: 1.2rem; margin-bottom: 0; }
.report-logo {
    width: 48px;
    height: 48px;
    display: block;
    margin: 0 auto 8px;
    object-fit: contain;
}
.report-content { flex: 1; overflow-y: auto; padding: 15px; }
.report-filters { background: var(--white); padding: 15px; border-radius: 15px; margin-bottom: 15px; border: 1px solid var(--tan); }
.report-filters h3 { font-size: 0.9rem; margin-bottom: 10px; color: var(--primary-brown); }
.report-summary {
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--primary-brown);
    font-weight: 600;
}
.report-date-group {
    margin: 16px 0 8px;
    padding: 9px 11px;
    border-left: 4px solid var(--primary-brown);
    border-radius: 8px;
    background: var(--very-light);
    color: var(--primary-brown);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: capitalize;
}

.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 350px) { .filter-row { grid-template-columns: 1fr; } }

.attendance-card {
    background: var(--white);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(127, 85, 57, 0.1);
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.card-info { min-width: 0; }
.card-info .emp-name { font-weight: 600; font-size: 0.95rem; color: var(--primary-brown); }
.card-info .time-info { font-size: 0.75rem; color: var(--light-brown); margin-top: 4px; }
.card-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-checkin { background: #e7f5e7; color: #2d6a4f; }
.badge-checkout { background: #fdf0e7; color: #7f5539; }
.photo-thumb-btn {
    width: 64px;
    height: 64px;
    border: 1px solid var(--tan);
    border-radius: 10px;
    overflow: hidden;
    padding: 0;
    background: #fdfaf7;
    cursor: pointer;
}
.photo-thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.photo-thumb-placeholder {
    width: 64px;
    height: 64px;
    border: 1px dashed var(--tan);
    border-radius: 10px;
    display: grid;
    place-items: center;
    text-align: center;
    font-size: 0.65rem;
    color: var(--light-brown);
    background: #fdfaf7;
    line-height: 1.2;
}

.photo-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(0, 0, 0, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.photo-modal-content {
    width: min(100%, 720px);
    max-height: calc(100vh - 32px);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.photo-modal-content img {
    width: 100%;
    max-height: calc(100vh - 96px);
    object-fit: contain;
    background: #000;
    border-radius: 12px;
}
.photo-modal-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--white);
    color: var(--primary-brown);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.photo-modal-caption {
    color: var(--white);
    text-align: center;
    font-size: 0.85rem;
}

.report-footer { padding: 15px 20px; background: var(--white); border-top: 1px solid var(--tan); }
.report-footer-text { margin-top: 0; margin-bottom: 10px; }
.report-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 0 6px;
}
.pagination-btn {
    min-width: 112px;
    padding: 10px 12px;
    border: 1.5px solid var(--primary-brown);
    border-radius: 10px;
    background: var(--white);
    color: var(--primary-brown);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.pagination-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.pagination-info {
    flex: 1;
    text-align: center;
    color: var(--primary-brown);
    font-size: 0.8rem;
    font-weight: 600;
}

@media (max-width: 420px) {
    .attendance-card {
        grid-template-columns: 58px minmax(0, 1fr);
        align-items: start;
    }
    .photo-thumb-btn,
    .photo-thumb-placeholder {
        width: 58px;
        height: 58px;
    }
    .card-badge {
        grid-column: 2;
        justify-self: start;
    }
    .report-pagination {
        flex-wrap: wrap;
    }
    .pagination-info {
        order: -1;
        flex-basis: 100%;
    }
    .pagination-btn {
        flex: 1;
        min-width: 0;
    }
}

/* Search Box */
.search-box { position: relative; width: 100%; margin-bottom: 5px; }
.search-box input { padding-left: 35px; background: #fdfaf7; }
.search-box::before { content: "🔍"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 0.9rem; opacity: 0.6; }
