/* ============================================
   ID MERGER APP — Premium Mobile UI
   ============================================ */

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

:root {
    --bg-primary: #F4F7FB;
    --bg-card: #FFFFFF;
    
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    --accent-blue: #3B82F6;
    --accent-blue-hover: #2563EB;
    --accent-green: #10B981;
    --accent-red: #EF4444;

    --border-color: #E2E8F0;
    --border-dashed: #CBD5E1;

    --radius-md: 12px;
    --radius-lg: 20px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(59, 130, 246, 0.2);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* === Header === */
header {
    background: var(--bg-card);
    padding: calc(16px + var(--safe-top)) 20px 16px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

header h1 .material-symbols-rounded {
    color: var(--accent-blue);
}

header p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Main Content === */
main {
    flex: 1;
    padding: 20px;
    padding-bottom: calc(100px + var(--safe-bottom)); /* Space for fixed button */
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* === Upload Cards === */
.upload-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-title .badge {
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    color: var(--text-secondary);
}

/* Upload Zone (The dashed box) */
.upload-zone {
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-md);
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    background: #FAFAFA;
    transition: all 0.2s ease;
    overflow: hidden;
}

.upload-zone:active {
    background: #F1F5F9;
    border-color: var(--accent-blue);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 5;
}

/* Placeholder state */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    pointer-events: none;
}

.placeholder .material-symbols-rounded {
    font-size: 36px;
    color: var(--accent-blue);
    opacity: 0.8;
}

.placeholder span {
    font-size: 13px;
    font-weight: 500;
}

/* Preview Image State */
.preview-img {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
    background: #fff;
}

.upload-card.has-image .upload-zone {
    border: 2px solid var(--accent-blue);
    background: #fff;
}

/* === Action Bar (Fixed Bottom) === */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    padding: 16px 20px calc(16px + var(--safe-bottom));
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    display: flex;
    gap: 12px;
    z-index: 100;
}

.btn {
    height: 52px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    flex: 1;
    background: var(--accent-blue);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.btn-primary.disabled {
    background: var(--border-dashed);
    box-shadow: none;
    color: #fff;
    pointer-events: none;
}

.btn-secondary {
    width: 52px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn .material-symbols-rounded {
    font-size: 20px;
}

/* === Toast Notification === */
.toast {
    position: fixed;
    top: calc(80px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--accent-green); }
.toast.error { background: var(--accent-red); }

/* === Scanner Modal === */
.scanner-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.scanner-modal.active {
    opacity: 1;
    visibility: visible;
}

#scannerVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Overlay with cutout */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

/* 
  Creating the clear guide frame.
  Using box-shadow to darken everything OUTSIDE the frame.
*/
.guide-frame {
    width: 85%;
    /* Standard ID card aspect ratio is approx 1.58:1 (e.g. 85.6mm x 54mm) */
    aspect-ratio: 1.58 / 1; 
    border-radius: 8px;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.6); /* Darken surroundings */
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Corner brackets */
.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: #fff;
    border-style: solid;
    border-width: 0;
}

.top-left { top: -2px; left: -2px; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 8px; }
.top-right { top: -2px; right: -2px; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 8px; }
.bottom-left { bottom: -2px; left: -2px; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 8px; }
.bottom-right { bottom: -2px; right: -2px; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 8px; }

.scanner-instruction {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    margin-top: 30px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    background: rgba(0,0,0,0.4);
    padding: 6px 16px;
    border-radius: 20px;
    /* Must remove the dark background from the overlay flexbox so the cutout works, 
       so the parent has background transparent, and box-shadow does the darkening */
}

/* Fix overlay background so box-shadow cutout works */
.scanner-overlay {
    background: transparent;
}

/* Controls */
.scanner-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px 30px calc(30px + var(--safe-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 3;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-capture {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-capture:active {
    transform: scale(0.95);
}

.capture-inner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    transition: all 0.2s;
}

.btn-capture:active .capture-inner {
    width: 48px;
    height: 48px;
}
