/* ACS Microhub - Fully Responsive Kiosk Styles */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Dark theme (setup) */
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --surface-dark: #1e293b;

    /* Light theme (kiosk) */
    --bg-light: #ffffff;
    --surface-light: #f8fafc;
    --border-light: #e2e8f0;

    --text-light: #f8fafc;
    --text-dark: #0f172a;
    --text-muted: #64748b;
}

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

html {
    font-size: 16px;
    background-color: var(--bg-dark);
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bg-dark);
    margin: 0;
}

.screen {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ============================================
   Setup Screen (Dark Theme)
   ============================================ */
.setup-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background: linear-gradient(135deg, var(--bg-darker), var(--bg-dark));
    position: relative;
    overflow: hidden;
}

/* Animated background */
.bg-animation {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.05;
    filter: blur(80px);
}

.circle-1 {
    width: 50vw;
    height: 50vw;
    max-width: 400px;
    max-height: 400px;
    top: -10%;
    right: -10%;
    animation: float 15s ease-in-out infinite;
}

.circle-2 {
    width: 40vw;
    height: 40vw;
    max-width: 300px;
    max-height: 300px;
    bottom: -5%;
    left: -5%;
    animation: float 12s ease-in-out infinite reverse;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, -20px);
    }
}

/* Logo */
.logo-section {
    text-align: center;
    margin-bottom: 32px;
    z-index: 1;
}

.logo-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
}

.logo-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: ring-pulse 2s ease-in-out infinite;
}

@keyframes ring-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.logo-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    font-size: 32px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

.logo-section h1 {
    font-size: clamp(1.5rem, 6vw, 2.25rem);
    font-weight: 800;
    color: var(--text-light);
    margin-bottom: 4px;
}

.tagline {
    color: var(--text-muted);
    font-size: clamp(0.875rem, 3vw, 1rem);
}

/* Form */
.setup-form {
    width: 100%;
    max-width: 360px;
    z-index: 1;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.setup-form input {
    width: 100%;
    padding: 14px 16px;
    font-size: clamp(1rem, 4vw, 1.25rem);
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.15em;
    border: 2px solid #475569;
    border-radius: 12px;
    background: var(--surface-dark);
    color: var(--text-light);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.setup-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
}

.setup-form input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-loader.hidden,
.btn-icon.hidden {
    display: none;
}

.hint {
    margin-top: 16px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.setup-footer {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.setup-footer strong {
    color: #94a3b8;
}

/* ============================================
   Kiosk Screen (Bright Theme)
   ============================================ */
#kioskScreen {
    display: none;
    background: var(--bg-light);
    height: 100vh;
    height: 100dvh;
}

#kioskScreen:not(.hidden) {
    display: flex;
}

/* Header */
.kiosk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
}

.client-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-logo-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 18px;
}

.client-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-placeholder {
    font-size: 18px;
}

.client-text {
    display: flex;
    flex-direction: column;
}

.client-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.2;
}

.client-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.stat-badge {
    padding: 6px 12px;
    background: var(--surface-light);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-badge #enrolledCount {
    font-weight: 700;
    color: var(--primary);
}

/* Camera Container - Ring Light Effect */
.camera-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding: 0;
    overflow: hidden;
}

#cameraFeed {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 0;
    box-shadow: none;
}

#captureCanvas {
    display: none;
}

/* Face Frame */
.face-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(220px, 60vw);
    height: min(280px, 45vh);
    pointer-events: none;
}

.frame-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 3px;
}

.frame-corner.top-left {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 10px 0 0 0;
}

.frame-corner.top-right {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 10px 0 0;
}

.frame-corner.bottom-left {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 10px;
}

.frame-corner.bottom-right {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 10px 0;
}

.scan-line {
    position: absolute;
    left: 10%;
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
    animation: scan 2.5s ease-in-out infinite;
}

@keyframes scan {

    0%,
    100% {
        top: 10%;
        opacity: 0;
    }

    10%,
    90% {
        opacity: 1;
    }

    100% {
        top: 90%;
    }
}

/* Camera Instructions & Status */
.camera-instructions {
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 0.8rem;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.camera-status {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 0.8rem;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Result Overlay */
.result-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.result-overlay.success {
    background: linear-gradient(135deg, var(--success), #059669);
}

.result-overlay.failure {
    background: linear-gradient(135deg, var(--danger), #dc2626);
}

.result-card {
    text-align: center;
    color: white;
}

.result-icon {
    font-size: clamp(3rem, 12vw, 5rem);
    margin-bottom: 12px;
}

.result-title {
    font-size: clamp(1.25rem, 5vw, 2rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.result-photo {
    width: clamp(80px, 20vw, 120px);
    height: clamp(80px, 20vw, 120px);
    border-radius: 50%;
    border: 3px solid white;
    object-fit: cover;
    margin-bottom: 16px;
}

.result-name {
    font-size: clamp(1.25rem, 5vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 4px;
}

.result-department {
    font-size: clamp(0.875rem, 3vw, 1.1rem);
    opacity: 0.9;
    margin-bottom: 12px;
}

.result-time {
    font-size: clamp(1rem, 3vw, 1.25rem);
    opacity: 0.8;
}

.result-match {
    margin-top: 12px;
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Attendance Action Badge */
.attendance-action {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 24px;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 600;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
}

.attendance-action.check_in {
    border: 2px solid rgba(16, 185, 129, 0.8);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.attendance-action.check_out {
    border: 2px solid rgba(245, 158, 11, 0.8);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

/* Late Badge */
.late-badge {
    display: inline-block;
    background: rgba(239, 68, 68, 0.3);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: white;
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 6px 0;
    animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Attendance Message */
.attendance-message {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    opacity: 0.9;
    margin: 8px 0;
    font-style: italic;
    max-width: 300px;
}

/* Geo-fence Distance Display */
.geo-distance {
    font-size: clamp(1rem, 3vw, 1.2rem);
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    margin: 16px 0;
    line-height: 1.6;
}

.geo-distance strong {
    font-size: 1.3em;
    color: #fbbf24;
}

/* Countdown */
.countdown-wrapper {
    position: absolute;
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
}

.countdown-ring {
    width: 100%;
    height: 100%;
}

.countdown-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

#countdownCircle {
    transition: stroke-dashoffset 1s linear;
}

.countdown-number {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

/* Footer */
.kiosk-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--border-light);
}

.footer-left {
    display: flex;
    flex-direction: column;
}

.time-display {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.date-display {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 20px;
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 500;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

/* ============================================
   Compliance Badges & Blocked State
   ============================================ */

/* Blocked overlay (amber/orange gradient) */
.result-overlay.blocked {
    background: linear-gradient(135deg, #d97706, #b45309);
}

/* Ignored overlay */
.result-overlay.ignored {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

/* Compliance badges container */
.compliance-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
}

/* Individual badge */
.compliance-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.compliance-badge.pass {
    background: rgba(16, 185, 129, 0.25);
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #d1fae5;
}

.compliance-badge.fail {
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fee2e2;
}

/* Blocked detail message */
.blocked-detail {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    opacity: 0.95;
    margin: 12px 0 6px;
    max-width: 320px;
    line-height: 1.4;
}

/* Policy name label */
.blocked-policy {
    font-size: 0.7rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

/* Member ID on result */
.result-member-id {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 8px;
    font-family: monospace;
    letter-spacing: 0.05em;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Very Small Phones (< 360px) */
@media (max-width: 360px) {
    .camera-container {
        padding: 0;
    }

    .face-frame {
        width: min(160px, 70vw);
        height: min(200px, 35vh);
    }

    .frame-corner {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }

    .camera-instructions {
        font-size: 0.7rem;
        padding: 6px 12px;
        top: 16px;
        bottom: auto;
    }

    .camera-status {
        font-size: 0.7rem;
        padding: 6px 12px;
        bottom: 16px;
        top: auto;
    }

    .kiosk-header,
    .kiosk-footer {
        padding: 8px 12px;
    }

    .client-logo-wrapper {
        width: 28px;
        height: 28px;
    }

    .client-name {
        font-size: 0.8rem;
    }

    .stat-badge {
        padding: 4px 8px;
        font-size: 0.65rem;
    }
}

/* Small Phones (360px - 480px) */
@media (min-width: 361px) and (max-width: 480px) {
    .camera-container {
        padding: 0;
    }

    .face-frame {
        width: min(180px, 65vw);
        height: min(230px, 40vh);
    }

    .frame-corner {
        width: 20px;
        height: 20px;
        border-width: 3px;
    }

    .camera-instructions {
        top: 24px;
    }

    .camera-status {
        bottom: 24px;
    }
}

/* Medium Phones (480px - 640px) */
@media (min-width: 481px) and (max-width: 640px) {
    .camera-container {
        padding: 16px;
    }

    .face-frame {
        width: min(200px, 55vw);
        height: min(260px, 42vh);
    }

    .frame-corner {
        width: 24px;
        height: 24px;
    }
}

/* Tablets (640px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    .camera-container {
        padding: 24px;
    }

    .face-frame {
        width: min(260px, 45vw);
        height: min(330px, 50vh);
    }

    .frame-corner {
        width: 28px;
        height: 28px;
        border-width: 4px;
    }

    .kiosk-header,
    .kiosk-footer {
        padding: 14px 24px;
    }

    .client-logo-wrapper {
        width: 42px;
        height: 42px;
    }

    .client-name {
        font-size: 1rem;
    }

    .time-display {
        font-size: 1.1rem;
    }

    .camera-instructions,
    .camera-status {
        font-size: 0.9rem;
        padding: 10px 20px;
    }
}

/* Large Screens (1024px+) */
@media (min-width: 1025px) {
    .camera-container {
        padding: 40px;
    }

    .face-frame {
        width: 300px;
        height: 380px;
    }

    .frame-corner {
        width: 36px;
        height: 36px;
        border-width: 4px;
    }

    .kiosk-header,
    .kiosk-footer {
        padding: 16px 32px;
    }

    .client-logo-wrapper {
        width: 48px;
        height: 48px;
    }

    .client-name {
        font-size: 1.1rem;
    }

    .time-display {
        font-size: 1.25rem;
    }

    .camera-instructions,
    .camera-status {
        font-size: 1rem;
        padding: 12px 24px;
    }

    #cameraFeed {
        border-radius: 16px;
    }
}

/* Extra Large / Kiosk Displays (1400px+) */
@media (min-width: 1400px) {
    .camera-container {
        padding: 60px;
    }

    .face-frame {
        width: 360px;
        height: 450px;
    }

    .frame-corner {
        width: 44px;
        height: 44px;
        border-width: 5px;
    }

    .camera-instructions,
    .camera-status {
        font-size: 1.1rem;
        padding: 14px 28px;
    }

    #cameraFeed {
        border-radius: 20px;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    }
}

/* Landscape Mode */
@media (max-height: 500px) and (orientation: landscape) {
    .setup-container {
        flex-direction: row;
        gap: 32px;
    }

    .logo-section {
        margin-bottom: 0;
    }

    .logo-wrapper {
        width: 60px;
        height: 60px;
    }

    .logo-icon {
        font-size: 24px;
    }

    .setup-footer {
        display: none;
    }

    /* Landscape kiosk */
    .camera-container {
        padding: 12px;
    }

    .face-frame {
        width: min(160px, 20vw);
        height: min(200px, 70vh);
    }

    .frame-corner {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }

    .kiosk-header,
    .kiosk-footer {
        padding: 6px 16px;
    }

    .camera-instructions {
        top: 20px;
        font-size: 0.7rem;
    }

    .camera-status {
        bottom: 20px;
        font-size: 0.7rem;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}