:root {
    /* Color Palette */
    --bg-dark: #0f1115;
    --bg-panel: rgba(22, 25, 33, 0.7);
    --primary: #4F46E5;
    --primary-hover: #6366F1;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    /* Glassmorphism */
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    /* Transitions */
    --trans-fast: 0.2s ease;
    --trans-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100dvh;
    width: 100dvw;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15), transparent 25%);
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
}

.hidden { display: none !important; }

/* Views */
.view {
    height: 100dvh;
    width: 100dvw;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Glassmorphism Utilities */
.glass-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}
.glass-card-solid {
    background: #1e212b;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}
.glass-panel {
    background: rgba(20, 23, 31, 0.6);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
}
.glass-header {
    background: rgba(15, 17, 21, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--glass-border);
}

/* Auth Screen */
.auth-container {
    padding: 3rem;
    text-align: center;
    max-width: 450px;
    width: 90%;
    animation: fadeUp 0.8s var(--trans-smooth) forwards;
}
.logo-container {
    position: relative;
    margin-bottom: 1rem;
}
.glow-effect {
    position: absolute;
    width: 100px;
    height: 100px;
    background: var(--primary);
    filter: blur(60px);
    opacity: 0.5;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
}
.auth-container h1 {
    font-size: 3rem;
    font-weight: 800;
}
.highlight {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}
.input-group input {
    width: 100%;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    transition: var(--trans-fast);
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Buttons */
.btn-primary, .btn-success, .btn-secondary {
    width: 100%;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--trans-smooth);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
}
.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #0ea5e9; }
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }

/* Main Layout */
#main-screen {
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
}
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    z-index: 10;
}
.sidebar-header h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}
.user-greeting {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}
.sidebar-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    text-align: left;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--trans-fast);
}
.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}
.nav-btn.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary);
    border-left: 4px solid var(--primary);
}
.stats-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}
.stat-label { display: block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; font-family: 'Outfit'; margin-bottom: 1rem; }
.progress-bar-container { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); width: 0%; transition: width 1s var(--trans-smooth); }

.content-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.sub-view {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s var(--trans-fast);
}

.content-header {
    padding: 1.5rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    flex-shrink: 0;
}
.content-header h1 { font-size: 2rem; }
.glass-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}
.glass-select option { background: var(--bg-dark); }
.glass-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    width: 250px;
    transition: var(--trans-fast);
}
.glass-input:focus { border-color: var(--primary); }
.pagination-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-icon {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: var(--trans-fast);
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }


/* Album Grid */
.album-grid {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2rem;
    align-content: start;
    min-height: 0;
}
.sticker-card {
    position: relative;
    width: 100%;
    padding-bottom: 139.13%; /* 1024/736 = 1.3913 */
    border-radius: 12px;
    background: #11111b;
    border: 2px solid var(--glass-border);
    overflow: hidden;
    transition: var(--trans-smooth);
    display: block;
}
.sticker-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
.sticker-card.missing { border-style: dashed; opacity: 0.5; filter: grayscale(100%); }
.sticker-card.missing:hover { opacity: 0.8; filter: grayscale(50%); }

.card-content {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
}

.sticker-img-placeholder {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: rgba(255,255,255,0.2);
    font-family: 'Outfit';
    font-weight: 800;
    z-index: 0;
}
.sticker-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
}

.sticker-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    z-index: 2;
}
.sticker-code { font-size: 0.8rem; color: var(--primary); font-weight: bold; }
.sticker-name { font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.qty-badge {
    position: absolute;
    top: -10px; right: -10px;
    background: var(--danger);
    color: white;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.5);
    z-index: 2;
}

/* Scanner */
.scan-instructions { color: var(--text-muted); }
.scanner-container {
    margin: 2rem 3rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 0;
}
.video-wrapper {
    flex: 1;
    position: relative;
    background: black;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
}
#camera-stream { width: 100%; height: 100%; object-fit: cover; }
#scan-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.scan-overlay {
    position: absolute; top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.3);
    pointer-events: none;
    transition: background 0.3s;
}
.scan-overlay.frozen { background: rgba(0,0,0,0.6); }

.scanner-controls {
    padding: 2rem;
    background: rgba(15, 17, 21, 0.9);
    display: flex; justify-content: center; align-items: center;
    border-radius: 0 0 20px 20px;
}
.btn-capture {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid white;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    transition: var(--trans-fast);
}
.capture-inner {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: white;
    transition: var(--trans-fast);
}
.btn-capture:hover .capture-inner { transform: scale(0.9); background: var(--primary); }

.scan-results-panel {
    position: absolute;
    bottom: 20px; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 500px;
    padding: 1.5rem;
    max-height: 50vh;
    display: flex; flex-direction: column;
}
.results-list {
    list-style: none;
    margin: 1rem 0;
    overflow-y: auto;
    flex: 1;
}
.result-item {
    padding: 0.8rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex; justify-content: space-between; align-items: center;
    border-left: 3px solid var(--primary);
    animation: slideIn 0.3s ease forwards;
}
.scan-actions { display: flex; gap: 1rem; margin-top: 1rem;}

/* Pokedex / Query */
.query-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
    min-height: 0;
}
.query-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}
.query-item {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--trans-fast);
}
.query-item:hover { transform: translateX(5px); border-color: var(--primary); }
.query-item.missing { opacity: 0.6; }
.query-item-info { display: flex; flex-direction: column; gap: 0.3rem; }
.query-item-code { color: var(--primary); font-weight: bold; font-size: 1.1rem; }
.query-item-name { font-size: 1.2rem; }
.query-item-qty { 
    background: rgba(255,255,255,0.1); 
    padding: 0.5rem 1rem; 
    border-radius: 8px; 
    font-weight: bold;
}
.query-item-qty.owned { background: var(--success); }

/* Custom Modal */
.glass-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    animation: fadeIn 0.3s ease;
}
.glass-modal-content {
    padding: 2.5rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: fadeUp 0.3s ease forwards;
}
.glass-modal-content h2 { margin-bottom: 1rem; color: var(--primary); }
.glass-modal-content p { color: var(--text-muted); font-size: 1.1rem; line-height: 1.5; }

/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    #main-screen {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 60px;
        padding: 0 1.5rem;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        justify-content: space-between;
        align-items: center;
        background: #11141a;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        z-index: 100;
    }
    .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    .sidebar-header h2 { font-size: 1.5rem; margin: 0; }
    .user-greeting { display: none; }
    .mobile-menu-btn { display: flex; align-items: center; }
    .sidebar-footer { display: none; }
    
    .sidebar-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: #11141a;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 1rem;
        padding: 2rem;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: var(--trans-smooth);
        z-index: 90;
    }
    .sidebar-menu.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }
    .nav-btn {
        padding: 1.2rem;
        text-align: center;
        border-radius: 12px;
        margin: 0;
        font-size: 1.2rem;
        border: 1px solid transparent;
        display: block;
        background: rgba(255,255,255,0.05);
    }
    .nav-btn.active {
        border: 1px solid var(--primary);
        border-left: 1px solid var(--primary);
        background: rgba(79, 70, 229, 0.15);
    }
    .content-area {
        flex: 1;
        min-height: 0;
    }
    .content-header {
        padding: 1rem 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    .content-header h1 { font-size: 1.6rem; }
    #view-scan .content-header { display: none; } /* hide header to maximize scan area */
    
    .glass-input { width: 100%; }
    .query-container { padding: 1rem; }
    .album-grid {
        padding: 1rem;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
    }
    .scanner-container {
        margin: 0;
        border-radius: 0;
        height: 100dvh;
        max-height: 100%;
        border: none;
    }
    .video-wrapper { border-radius: 0; }
    .scanner-controls {
        padding: 1rem;
        border-radius: 0;
        background: rgba(15, 17, 21, 1);
        padding-bottom: env(safe-area-inset-bottom, 1rem); /* iPhone notch support */
    }
    .btn-capture { width: 70px; height: 70px; }
    .capture-inner { width: 50px; height: 50px; }
    .scan-results-panel {
        width: 95%;
        padding: 1rem;
        bottom: 90px;
        max-height: 40vh;
    }
}
