* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100vh;
}

h1 {
    text-align: center;
    color: #1a73e8;
    margin-bottom: 20px;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    aspect-ratio: 3/4;
    height: 75vh; /* fallback height for browsers without aspect-ratio */
    max-height: 720px;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}

/* Ensure FAB is clickable above camera */
.fab-wrapper { position: fixed; right: 16px; bottom: 16px; z-index: 10; }
.fab { width: 52px; height: 52px; border-radius: 50%; border: none; background: #4a90e2; color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.fab-menu { position: absolute; bottom: 64px; right: 0; display: none; flex-direction: column; gap: 10px; }
.fab-item { width: 44px; height: 44px; border-radius: 50%; border: none; background: #6c63ff; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; }

.camera-container video,
.camera-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

#video {
    z-index: 1;
}

#canvas {
    z-index: 2;
}

#opencvCanvas {
    z-index: 3;
    pointer-events: none;
}

.controls {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 25px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Fix the box height to avoid layout jumps; allow internal scroll if needed */
    height: 420px;
    overflow-y: auto;
}

.input-group {
    width: 100%;
    max-width: 300px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    width: 100%;
    padding-bottom: 80px;
}

.main-buttons {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: center;
    margin-bottom: 40px;
}

.icon-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-settings {
    background-color: #4a90e2;
    color: white;
}

.btn-admin {
    background-color: #9c27b0;
    color: white;
}

.admin-controls {
    width: 100%;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 10px 0;
}

.capture-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

#message {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 10px auto;
    width: 100%;
    max-width: 640px;
    /* Reserve vertical space so messages don't resize layout */
    min-height: 44px;
}

select, input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
    margin-bottom: 10px;
    font-size: 14px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-in {
    background-color: #4CAF50;
    color: white;
}

.btn-out {
    background-color: #f44336;
    color: white;
}

.btn-generate {
    background-color: #2196F3;
    color: white;
}

.message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}

.success {
    background-color: #4CAF50;
    color: white;
}

.error {
    background-color: #f44336;
    color: white;
}

.processing {
    background-color: #2196F3;
    color: white;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
}

.settings-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 520px;
    background: rgba(255,255,255,0.98);
    padding: 12px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 6;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-content h3 {
    margin: 0;
    color: #333;
    text-align: left;
}

.btn-settings:hover {
    background-color: #357abd;
}

.settings-panel .input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.settings-panel label {
    font-weight: 500;
    color: #333;
    text-align: left;
}

.settings-panel input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.system-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 14px;
}
.panel-actions { display: flex; gap: 8px; }
.btn-danger { background:#dc3545; color:#fff; }

/* Replace page message with overlay message inside camera */
.overlay-message {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 5;
    max-width: 90%;
    text-align: center;
}

/* Action buttons inside camera bottom center */
.action-buttons {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 5;
}

/* Geo banner inside camera */
.geo-banner {
    position: absolute;
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 12px;
    z-index: 5;
}

/* Top-right readiness indicator inside camera */
.readiness-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(108,117,125,0.25);
    color: #6c757d;
    z-index: 6;
    font-size: 14px;
    position: absolute;
}
.readiness-indicator.ready {
    background: rgba(220, 53, 69, 0.35);
    color: #dc3545;
}
.readiness-indicator.warming { background: rgba(253,126,20,0.25); color: #fd7e14; }

/* Small cached badge under the indicator */
.cached-badge {
    position: absolute;
    top: 48px;
    right: 10px;
    background: rgba(40,167,69,0.25);
    color: #28a745;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 11px;
    z-index: 6;
    display: none;
}
.cached-badge.blue { background: rgba(0,123,255,0.25); color: #0d6efd; }

/* Centered percentage overlay inside the loader */
.readiness-indicator .ri-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.readiness-indicator .ri-wrap i { font-size: 16px; }
.readiness-indicator .ri-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: currentColor;
}

/* Fixed registration panel below camera (no scroll) */
.register-panel {
    width: 100%;
    max-width: 640px;
    margin: 10px auto 0;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.register-panel .capture-controls { justify-content: space-between; }
.register-panel .capture-controls input { flex: 1; margin-right: 10px; }
.register-panel .panel-actions { flex-wrap: nowrap; }

@media (max-width: 480px) {
    .register-panel .capture-controls { flex-direction: column; align-items: stretch; gap: 8px; }
    .register-panel .capture-controls input { margin-right: 0; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        min-height: 100vh;
        gap: 15px;
    }
    
    .camera-container {
        max-width: 100%;
        aspect-ratio: 4/3;
    }
    
    .controls {
        max-width: 100%;
        padding: 20px;
        gap: 10px;
        height: 360px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        position: relative;
        padding-bottom: 70px;
    }
    
    .main-buttons {
        flex-direction: row;
        gap: 10px;
        width: 100%;
        justify-content: center;
        margin-bottom: 30px;
    }
    
    .btn {
        flex: 1;
        max-width: 150px;
        justify-content: center;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .icon-buttons {
        position: absolute;
        bottom: 15px;
        right: 15px;
        gap: 6px;
    }
    
    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    .capture-controls {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .capture-controls input {
        width: 100%;
        margin-right: 0;
        margin-bottom: 8px;
    }
    
    .capture-controls button {
        width: 100%;
        justify-content: center;
    }
    
    .settings-panel {
        max-width: 100%;
        padding: 15px;
        margin: 10px 0;
    }
    
    .settings-content {
        gap: 10px;
    }
    
    .input-group {
        max-width: 100%;
    }
    
    select, input {
        font-size: 16px;
        padding: 12px;
    }
    
    #message {
        max-width: 100%;
        margin: 10px 0;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
        gap: 10px;
    }
    
    .camera-container {
        aspect-ratio: 3/4;
    }
    
    .controls {
        padding: 15px;
        height: 320px;
    }
    
    .button-group {
        padding-bottom: 60px;
    }
    
    .main-buttons {
        gap: 8px;
        margin-bottom: 25px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 14px;
        max-width: 120px;
    }
    
    .icon-buttons {
        bottom: 10px;
        right: 10px;
        gap: 5px;
    }
    
    .icon-btn {
        width: 25px;
        height: 25px;
        font-size: 10px;
    }
    
    .settings-panel {
        padding: 10px;
    }
    
    .settings-content h3 {
        font-size: 16px;
    }
    
    .settings-panel label {
        font-size: 14px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
        padding: 15px;
    }
    
    .camera-container {
        max-width: 600px;
    }
    
    .controls {
        max-width: 600px;
    }
    
    .button-group {
        gap: 15px;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 15px;
    }
}

@media (min-width: 1025px) {
    .container {
        max-width: 900px;
        padding: 30px;
    }
    
    .camera-container {
        max-width: 720px;
    }
    
    .controls {
        max-width: 720px;
        padding: 20px;
    }
    
    .button-group {
        gap: 20px;
    }
    
    .btn {
        padding: 15px 30px;
        font-size: 16px;
    }
} 