/* ========================
   Minimal Scanner Style
   ======================== */

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

body {
    font-family: 'Nokora', 'Inter', sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Container chính */
.scanner-container {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Camera Preview */
#video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #111;
}

/* Guide Overlay */
.guide-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.guide-frame {
    width: 85%;
    aspect-ratio: 3 / 4; /* Tỷ lệ phổ biến cho tài liệu A4/ID */
    max-width: 320px;
    border: 2px dashed #4CAF50;
    border-radius: 16px;
    opacity: 0.45;
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.25);
    background: transparent;
}

.guide-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 18px;
    line-height: 1.4;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9);
    pointer-events: none;
}

.guide-text small {
    font-size: 14px;
    opacity: 0.75;
    display: block;
    margin-top: 8px;
    font-family: 'Inter', sans-serif;
}

/* Floating Action Button (FAB) */
.fab {
    position: absolute;
    bottom: 110px;
    right: 24px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #2196F3;
    border: none;
    color: white;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.45);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.fab:disabled {
    background: #444;
    box-shadow: none;
    opacity: 0.6;
}

.fab:active:not(:disabled) {
    transform: scale(0.92);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

/* Bottom Controls */
.bottom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10;
}

.bottom-controls button {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    padding: 12px 20px;
    cursor: pointer;
    transition: transform 0.15s;
}

.bottom-controls button:active {
    transform: scale(0.9);
}

/* Progress Overlay */
.progress-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 6px solid #2196F3;
    border-top: 6px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.progress-overlay p {
    font-size: 18px;
    color: #ddd;
}

/* Result Sheet (Bottom Sheet style) */
.result-sheet {
    position: absolute;
    inset: 0;
    background: rgba(18, 18, 18, 0.98);
    backdrop-filter: blur(12px);
    padding: 24px 16px;
    overflow-y: auto;
    z-index: 15;
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.result-header h2 {
    font-size: 22px;
    margin: 0;
    font-weight: 500;
}

.close-btn {
    background: #333;
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 14px;
    cursor: pointer;
}

.preview-thumb {
    width: 100%;
    max-height: 220px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.preview-thumb img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.result-text {
    font-size: 18px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    flex: 1;
    color: #f0f0f0;
}

.action-bar {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-bottom: 16px;
}

.action-bar button {
    flex: 1;
    padding: 14px;
    background: #2196F3;
    border: none;
    color: white;
    font-size: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.action-bar button:active {
    background: #1976D2;
}

/* Error Message */
.error-message {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(244, 67, 54, 0.92);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    max-width: 85%;
    text-align: center;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

/* Responsive nhỏ (điện thoại nhỏ ở Campuchia) */
@media (max-width: 360px) {
    .guide-frame {
        width: 90%;
    }
    .fab {
        bottom: 100px;
        width: 64px;
        height: 64px;
        font-size: 28px;
    }
    .result-text {
        font-size: 17px;
    }
}