:root {
    --orange-50: #fff8f3;
    --orange-100: #fff3ea;
    --orange-200: #ffe8c5;
    --orange-300: #ffd7a0;
    --orange-400: #ffb86b;
    --orange-500: #ff8c00;
    --orange-600: #e07a00;
    --muted: #3b2a1a;
    --glass: rgba(255, 255, 255, 0.6);
    --card-shadow: 0 12px 30px rgba(224, 138, 44, 0.08);
    --focus-glow: rgba(255, 170, 85, 0.16);
    --radius: 14px;
    --ff: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.video-container {
    position: relative;
    /* Essential for absolute positioning of children */
    display: none;
    /* Hidden until startButton is clicked */
    justify-content: center;
}

video,
canvas {
    position: absolute;
    /* Stack them on top of each other */
    top: 0;
    left: 0;
}

canvas {
    z-index: 10;
    /* Ensure the drawing layer is above the video */
    pointer-events: none;
    /* Let clicks pass through to the video if needed */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html,
body {
    height: 100%
}

body {
    font-family: var(--ff);
    background: linear-gradient(to bottom right, #eea334ff, #ffe0b2, #ff9100ce);
    color: var(--muted);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    padding: 24px;
}

/* make "Current time:" sit tight with the time pill and improve layout */
.title {
    justify-content: center;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    /* small gap between label and time */
    font-weight: 700;
    font-size: 1.15rem;
    padding: 0;
}

/* refined current-time pill (compact, warm orange + clock badge) */
#current-time {
    display: inline-flex;
    align-items: center;
    margin: auto;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: linear-gradient(90deg, #fff7f0, #fff2ea);
    color: #7a3500;
    font-weight: 800;
    font-size: 3em;
    border: 1px solid rgba(255, 140, 0, 0.08);
    box-shadow: 0 10px 28px rgba(224, 138, 44, 0.08), inset 0 3px 10px rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

/* smaller decorative clock badge */
#current-time::before {
    content: "🕒";
    border-radius: 8px;
    color: #fff;
    font-size: inherit;
    background: linear-gradient(135deg, #ff8c00, #ffb86b);
    box-shadow: 0 8px 20px rgba(255, 140, 0, 0.14);
    animation: cpulse 2600ms infinite ease-in-out;
}

/* make inner time pieces visually separated */
#current-time .time-main {
    font-size: 1.05rem;
    letter-spacing: .4px;
}

#current-time .time-sec,
#current-time .time-ampm {
    font-size: .78rem;
    color: rgba(58, 42, 26, 0.62);
}

/* hover micro-interaction */
.title:hover #current-time {
    transform: translateY(-3px);
    box-shadow: 0 24px 48px rgba(224, 138, 44, 0.12);
}

/* responsive adjustments */
@media (max-width:720px) {
    .title {
        gap: 8px;
        font-size: 1rem;
    }

    #current-time {
        padding: 7px 10px;
        gap: 8px;
        font-size: .95rem;
    }

    #current-time::before {
        width: 30px;
        height: 30px;
        font-size: .9rem;
    }
}

/* Page layout */
.container {
    max-width: 1200px;
    min-height: 100vh;
    max-height: fit-content;
    margin: 0 auto
}

.main {
    display: flex;
    flex-direction: column;
    gap: 18px
}

.title {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    color: var(--muted)
}

.flex-container {
    display: flex;
    flex-direction: column; /* Stack video and buttons vertically */
    height: calc(100vh - 100px); /* Fill screen minus title height */
    gap: 18px;
}

/* 2. Make the flex-item take all available space */
.flex-item {
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
    height: 100%;
}

/* 3. Expand the Video Container */
.video-container {
    position: relative;
    flex-grow: 1;       /* This forces it to take up all empty space */
    display: flex;      /* Keep as flex to center video/canvas */
    padding: 0;         /* Remove padding so video touches edges */
    background: #000;   /* Black background for cinema feel */
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    min-height: 0;      /* Crucial for flex-grow to work properly in some browsers */
}

#toast-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    z-index: 100; /* Sit on top of video and canvas */
}

.attendance-toast {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border-left: 6px solid var(--orange-500);
    animation: toastPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.attendance-toast.time-in { border-left-color: #28a745; }
.attendance-toast.time-out { border-left-color: #ff6b6b; }

@keyframes toastPop {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast-details .name { 
    display: block; 
    font-weight: 800; 
    font-size: 1.1rem; 
    color: var(--muted);
}
.toast-details .action { 
    font-size: 0.85rem; 
    color: var(--orange-600); 
    font-weight: 600;
}

/* 4. Force Video/Canvas to fill the container exactly */
.video-container video, 
.video-container canvas {
    width: 100%;
    height: 100%;
    position: absolute; /* Stack them */
    top: 0;
    left: 0;
    object-fit: cover;  /* Ensures no black bars, fills the area */
}

.flash-success {
    animation: success-glow 1.5s ease-out;
}

/* Error Glow (Red) */
.flash-error {
    animation: error-glow 1.5s ease-out;
}

@keyframes success-glow {
    0% { border-color: #28a745; box-shadow: 0 0 0px #28a745; }
    20% { border-color: #28a745; box-shadow: 0 0 40px #28a745; }
    100% { border-color: rgba(255, 140, 0, 0.08); box-shadow: var(--card-shadow); }
}

@keyframes error-glow {
    0% { border-color: #ff6b6b; box-shadow: 0 0 0px #ff6b6b; }
    20% { border-color: #ff6b6b; box-shadow: 0 0 40px #ff6b6b; }
    100% { border-color: rgba(255, 140, 0, 0.08); box-shadow: var(--card-shadow); }
}

.attendance-toast.status-flex {
    border-left-color: #3498db;
    background: #f0f9ff;
}

/* Late worker theme - Orange */
.attendance-toast.status-late {
    border-left-color: #e67e22;
    background: #fffaf0;
}

.status-tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: white;
    font-weight: bold;
    margin-left: 8px;
}

.tag-flex { background: #3498db; }
.tag-late { background: #e67e22; }
.tag-ontime { background: #27ae60; }

/* Buttons */
.button-container {
    display: flex;
    gap: 12px;
    margin-top: 6px
}

.btn {
    flex: 1;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 800;
    letter-spacing: 0.2px;
    cursor: pointer;
    border: none;
    box-shadow: 0 8px 22px rgba(255, 140, 0, 0.08);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.btn-in {
    background: linear-gradient(180deg, var(--orange-500), var(--orange-400));
    color: #fff;
}

.btn-out {
    background: linear-gradient(180deg, #ff6b6b, #e14b3b);
    color: #fff;
}

.btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(255, 140, 0, 0.12)
}

.btn:active {
    transform: translateY(-1px) scale(.995)
}

/* Time In button - green theme (override .btn-in) */
.btn-in {
    background: linear-gradient(180deg, #28a745, #218838);
    color: #fff;
    border: none;
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.12);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.btn-in:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(40, 167, 69, 0.18);
    filter: brightness(1.03);
}

.btn-in:active {
    transform: translateY(-1px) scale(.995);
    box-shadow: 0 8px 18px rgba(40, 167, 69, 0.10);
}

/* Active / hover interactions for inputs (warm orange theme) */
input[type="text"],
input[type="password"],
textarea,
select {
    transition: transform .14s cubic-bezier(.2, .9, .2, 1),
        box-shadow .14s ease,
        border-color .12s ease,
        background .12s ease;
    will-change: transform, box-shadow, border-color;
}

/* subtle lift and warm inner glow on hover */
input[type="text"]:hover,
input[type="password"]:hover,
textarea:hover,
select:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 140, 0, 0.22);
    background: linear-gradient(180deg, #fffaf8, #fff3ef);
    box-shadow:
        0 14px 36px rgba(255, 140, 0, 0.10),
        inset 0 6px 18px rgba(255, 140, 0, 0.04);
}

/* pressed / active state */
input[type="text"]:active,
input[type="password"]:active,
textarea:active,
select:active {
    transform: translateY(-1px);
    box-shadow: inset 0 6px 16px rgba(255, 140, 0, 0.06);
    border-color: rgba(255, 120, 0, 0.28);
}

/* focus — strong orange gradient ring */
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border: 2px solid transparent;
    border-radius: 10px;
    border-image: linear-gradient(90deg, #ff8c00, #ffb86b) 1;
    box-shadow:
        0 18px 44px rgba(255, 140, 0, 0.14),
        inset 0 6px 20px rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

/* visible focus for keyboard users */
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
    box-shadow:
        0 20px 48px rgba(255, 140, 0, 0.16),
        inset 0 6px 22px rgba(255, 255, 255, 0.55);
}

/* small-screen tweak */
@media (max-width:480px) {

    input[type="text"],
    input[type="password"],
    textarea,
    select {
        padding: 9px 10px;
    }
}


/* Status badge */
.status {
    display: inline-block;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    margin-bottom: 10px;
    color: #7a2b00;
    background: linear-gradient(180deg, #fff8f3, #fff3ea);
    border: 1px solid rgba(255, 140, 0, 0.06);
}

.status.success {
    background: linear-gradient(180deg, #e6fff0, #dff7e6);
    color: #126334;
    border-color: rgba(10, 120, 60, 0.06)
}

.status.error {
    background: linear-gradient(180deg, #fff2ec, #ffe9e0);
    color: #7a2b00;
    border-color: rgba(200, 60, 40, 0.06)
}

/* Log card */
.log-container {
    background: linear-gradient(180deg, var(--orange-50), #fff);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 140, 0, 0.06);
    max-height: 72vh;
    overflow: auto;
}

.log-title {
    font-weight: 800;
    color: var(--muted);
    margin-bottom: 8px
}

/* Attendance list */
.attendance-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    margin: 0
}

.attendance-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    background: linear-gradient(180deg, #fff, #fffaf6);
    border: 1px solid rgba(255, 140, 0, 0.04);
    box-shadow: 0 6px 14px rgba(255, 140, 0, 0.03) inset;
    transition: transform .12s ease, box-shadow .12s ease;
    animation: fadeIn .28s ease both;
}

.attendance-list li:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(255, 140, 0, 0.07)
}

.attendance-list li i {
    display: inline-flex;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}

.time-in i {
    background: linear-gradient(135deg, #6adf83, #2fb86b);
    color: #063a1d;
    box-shadow: 0 6px 14px rgba(20, 120, 60, 0.06)
}

.time-out i {
    background: linear-gradient(135deg, #ff8b7a, #ff6b6b);
    color: #5a1b14;
    box-shadow: 0 6px 14px rgba(200, 60, 40, 0.06)
}

.details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 12px
}

.name {
    font-weight: 800
}

.action {
    font-size: .88rem;
    color: rgba(58, 42, 26, 0.7)
}

.time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 120px
}

.hour {
    font-weight: 800
}

.day {
    font-size: .78rem;
    color: rgba(58, 42, 26, 0.6)
}

/* empty state */
.attendance-list li.empty {
    justify-content: center;
    color: rgba(58, 42, 26, 0.6)
}

/* Scrollbar (orange) */
.log-container::-webkit-scrollbar {
    width: 12px
}

.log-container::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #fffaf6, #fff3ec);
    border-radius: 12px
}

.log-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #ffb86b, #ff8c00);
    border-radius: 12px;
    border: 3px solid #fff6ef
}

@media (max-width:1000px) {
    .attendance-list li {
        padding: 10px 8px
    }

    .time {
        min-width: 90px
    }
}

/* small animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

/* current time styling */
#current-time {
    font-weight: 800;
    color: var(--orange-600);
    background: linear-gradient(90deg, #fff7f0, #fff2ea);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 140, 0, 0.06)
}