/* =========================================
   1. GLOBAL VARIABLES & THEME
   ========================================= */
   
:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #3b82f6;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --cyan: #06b6d4;
    --purple: #a855f7;
    --pink: #ec4899;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Inter, Roboto, sans-serif; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;     /* allow page to grow */
    display: flex;
    flex-direction: column;
}

/* =========================================
   2. BACKGROUND
   ========================================= */
.orb {
    position: absolute; border-radius: 50%; filter: blur(90px); z-index: -1; opacity: 0.6;
    animation: float 15s infinite ease-in-out;
}
.orb-1 { width: 400px; height: 400px; background: #2563eb; top: -100px; left: -100px; }
.orb-2 { width: 300px; height: 300px; background: #7c3aed; bottom: 10%; right: -50px; animation-delay: -5s; }
.orb-3 { width: 200px; height: 200px; background: #06b6d4; top: 40%; left: 30%; filter: blur(120px); opacity: 0.3; }

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, 40px); }
}

.glass { background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(12px); border-bottom: 1px solid var(--glass-border); }
.glass-card {
    background: var(--glass-bg); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    position: relative; overflow: hidden; 
}
.glass-inset { background: rgba(0, 0, 0, 0.3); box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); border-radius: 12px; }

/* =========================================
   3. NAVIGATION
   ========================================= */
.topnav {
    position: fixed; top: 0; width: 100%; padding: 0 30px; height: 70px;
    display: flex; justify-content: space-between; align-items: center; z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-brand-link { display: flex; align-items: center; height: 100%; text-decoration: none; }
.nav-logo-img {
    height: 55px; width: auto; border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.2);
}
.nav-brand-link:hover .nav-logo-img { transform: scale(1.1) rotate(-5deg); box-shadow: 0 0 25px rgba(236, 72, 153, 0.5); }
.nav-title { font-size: 22px; font-weight: 800; letter-spacing: 1px; display: inline-flex; align-items: center; }

.char-cyan { color: var(--cyan); text-shadow: 0 0 15px rgba(6, 182, 212, 0.5); }
.char-blue { color: var(--primary); text-shadow: 0 0 15px rgba(59, 130, 246, 0.5); }
.char-purple { color: var(--purple); text-shadow: 0 0 15px rgba(168, 85, 247, 0.5); }
.char-pink { color: var(--pink); font-weight: 600; margin-left: 4px; text-shadow: 0 0 15px rgba(236, 72, 153, 0.5); }

.nav-icon {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; color: var(--text-muted); transition: 0.3s;
    text-decoration: none;
    flex-shrink: 0; /* FIX: Prevents squishing */
}
.nav-icon:hover { background: rgba(255,255,255,0.1); color: white; transform: scale(1.1); }

/* =========================================
   4. LAYOUT & VIEWPORTS
   ========================================= */
.container-center {
    flex: 1; 
    width: 100%; 
    max-width: 600px;
    margin: 100px auto 20px; /* Reduced bottom margin so footer sits tighter */
    padding: 0 20px;
    display: flex; 
    flex-direction: column; 
    align-items: center;
    /* FIX: Allow scrolling inside container if content is tall */
    overflow-y: auto;
    /* FIX: Hide scrollbar for cleaner look */
    scrollbar-width: none; 
}
.container-center::-webkit-scrollbar { display: none; }

.scanner-app {
    width: 100%;
    min-height: 650px;
    display: flex; flex-direction: column;
}

/* Views */
.view {
    flex: 1; display: flex; flex-direction: column; padding: 25px;
    opacity: 0; transition: opacity 0.4s ease, transform 0.4s ease;
    position: absolute; top: 0; bottom: 0; left: 0; right: 0;
    pointer-events: none;
}
.view.active { opacity: 1; pointer-events: all; transform: scale(1); position: relative; }
.view.hidden { display: none; }

/* Landing */
#view-landing .content-center { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; text-align: center; }
.page-title { font-size: 2rem; margin-bottom: 10px; color: white; }
.page-subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 1.1rem; }

/* =========================================
   5. CAMERA & OVERLAY
   ========================================= */
.camera-wrapper {
    flex: 1; 
    background: #000; 
    border-radius: 12px; 
    overflow: hidden;
    position: relative; 
    margin-bottom: 15px; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

#video-feed, #overlay-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: auto;
    min-width: 100%;
    min-height: 100%;
}

@media (max-aspect-ratio: 3/4) { 
    #video-feed, #overlay-canvas {
        width: auto;
        height: 100%;
    }
}

#overlay-canvas {
    pointer-events: none;
    z-index: 10;
}

/* Thumbnails */
.thumbnails-container {
    height: 80px; display: flex; gap: 10px; overflow-x: auto;
    padding-bottom: 5px; margin-bottom: 15px;
}
.thumb {
    height: 70px; width: 50px; border-radius: 6px; border: 2px solid var(--primary);
    object-fit: cover; flex-shrink: 0; animation: popIn 0.3s ease;
}

/* Controls */
.controls { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.action-row { display: flex; justify-content: space-between; width: 100%; align-items: center; }

/* Preview */
.pdf-preview-container {
    flex: 1; width: 100%; margin: 10px 0 20px; 
    border: 1px solid var(--glass-border);
    overflow-y: auto; 
    background: rgba(255, 255, 255, 0.1);
    display: flex; flex-direction: column; align-items: center; gap: 15px; padding: 20px;
}
.preview-page { width: 100%; max-width: 400px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); border-radius: 4px; }

/* =========================================
   6. BUTTONS & UI
   ========================================= */
.button-group { display: flex; gap: 15px; width: 100%; }
.button-group button { flex: 1; }
button { cursor: pointer; border: none; outline: none; transition: all 0.3s ease; }

.btn-primary {
    background: var(--primary); color: white; padding: 12px 24px;
    border-radius: 12px; font-weight: 600; font-size: 1rem;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 6px 0 #1e40af;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #1e40af; }
.btn-primary:disabled { background: var(--glass-border); color: var(--text-muted); box-shadow: none; transform: none; cursor: not-allowed; }

.btn-secondary {
    background: rgba(255, 255, 255, 0.1); color: white; padding: 10px 20px;
    border-radius: 10px; font-weight: 500; border: 1px solid var(--glass-border);
}

.btn-circle {
    width: 70px; height: 70px; border-radius: 50%;
    background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4);
    display: flex; justify-content: center; align-items: center;
}
.inner-circle { width: 55px; height: 55px; border-radius: 50%; background: white; transition: transform 0.1s; }
.btn-circle:active .inner-circle { transform: scale(0.9); background: var(--primary); }

@keyframes popIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* =========================================
   7. FOOTER (MOVED OUTSIDE MEDIA QUERY)
   ========================================= */
footer {
    text-align: center;
    padding: 25px;
    color: var(--text-muted);
    font-size: 0.9rem;
    /* FIX: Pushes footer to bottom */
    margin-top: auto; 
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(5px);
    width: 100%;
}

.footer-content { display: flex; flex-direction: column; gap: 8px; align-items: center; }

.heart-beat { color: #ef4444; display: inline-block; animation: heartbeat 1.5s infinite ease-in-out; }
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.3); }
    60% { transform: scale(1); }
}

.copyright-text { font-size: 0.85rem; opacity: 0.9; }

.name-highlight {
    font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
    background: linear-gradient(90deg, #fbbf24, #f472b6, #a78bfa, #fbbf24);
    background-size: 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shineName 3s linear infinite;
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.4));
    display: inline-block;
}
@keyframes shineName { to { background-position: 200% center; } }

footer {
    text-align: center;
    padding: 25px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(5px);
    width: 100%;
    margin-top: auto;   /* <— pushes footer to bottom */
    position: static;   /* <— ensures footer scrolls normally */
    box-sizing: border-box;
}

/* =========================================
   8. RESPONSIVE / MOBILE FIXES
   ========================================= */
@media(max-width: 600px){
      html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden !important;
        position: relative;
    }
    
.topnav {
    overflow: hidden;        /* prevent horizontal scroll */
    max-width: 100vw;        /* prevent extra width */
}

.nav-title {
    white-space: nowrap;     /* keep text in one line */
    overflow: hidden;        /* hide overflow */
    text-overflow: ellipsis; /* add ... if needed */
}

.nav-brand {
    min-width: 0;            /* allow shrinking */
}

.nav-brand-link {
    min-width: 0;
}

.nav-logo-img {
    flex-shrink: 0;          /* prevent logo squish */
}

.nav-icon {
    flex-shrink: 0;          /* prevents icon from squishing */
}

    
    .container-center {
        padding-bottom: 90px !important; /* enough space above footer */
        overflow-y: auto;                 /* allow scrolling again */
        -webkit-overflow-scrolling: touch;
    }

    .view {
        overflow-y: auto; /* ensure inner view can scroll */
    }

    .camera-wrapper {
        flex: 1; 
        min-height: 0; 
        margin-bottom: 10px;
        border-radius: 8px;
        width: 100%;
    }
    
    #video-feed, #overlay-canvas {
        max-width: 100vw;
    }

    .thumbnails-container { height: 60px; flex-shrink: 0; margin-bottom: 10px; }
    .thumb { height: 50px; width: auto; }
    .controls { flex-shrink: 0; gap: 10px; padding-bottom: 5px; }

    /* Hide Footer explicitly on Mobile to save space (as per your comment) */
   footer {
        padding: 15px 10px;
        font-size: 0.85rem;
        position: static !important;   /* <— ensures footer stays at end */
    }

    .container-center {
        padding-bottom: 20px; /* space before footer */
        overflow-y: auto;
    }

.footer-content { display: flex; flex-direction: column; gap: 8px; align-items: center; }

.heart-beat { color: #ef4444; display: inline-block; animation: heartbeat 1.5s infinite ease-in-out; }
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.3); }
    60% { transform: scale(1); }
}

.copyright-text { font-size: 0.85rem; opacity: 0.9; }

.name-highlight {
    font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
    background: linear-gradient(90deg, #fbbf24, #f472b6, #a78bfa, #fbbf24);
    background-size: 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shineName 3s linear infinite;
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.4));
    display: inline-block;
}
@keyframes shineName { to { background-position: 200% center; } }

}
