/* =========================================
   CORE STYLES & VARIABLES
   ========================================= */
:root {
    --bg-dark: #050505;
    --bg-panel: #0a0a12;
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-green: #0aff0a;
    --neon-red: #ff3333;
    --neon-amber: #ffcc00;
    --text-main: #e0e0e0;
    --grid-line: rgba(0, 243, 255, 0.1);
}

body {
    margin: 0; padding: 0;
    font-family: 'Rajdhani', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 30px 30px;
    height: 100vh;
    color: var(--text-main);
    overflow: hidden;
    touch-action: pan-y;
}

/* Utilities */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--neon-blue); border-radius: 4px; }
.hidden { display: none !important; }

/* Loading Overlay */
#boot-sequence {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: #000; z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    flex-direction: column;
}
.loader-text {
    font-family: 'Share Tech Mono'; color: var(--neon-blue); margin-top: 10px;
    animation: blink 1s infinite;
}

/* View Container */
.view-section {
    width: 100vw; height: 100vh;
    position: absolute; top: 0; left: 0;
    display: none; /* Controlled by JS */
    flex-direction: column;
}

/* =========================================
   LOGIN MODULE STYLES
   ========================================= */
#view-login {
    z-index: 1000;
    background: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.login-panel {
    width: 300px; padding: 40px;
    background: rgba(10, 15, 20, 0.8);
    border: 1px solid var(--neon-blue);
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.15);
    position: relative; overflow: hidden;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    text-align: center;
    transition: all 0.5s ease;
}

.login-panel.success {
    border-color: var(--neon-green);
    box-shadow: 0 0 40px rgba(10, 255, 10, 0.4);
}

.login-panel::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 100%; height: 2px;
    background: var(--neon-blue);
    box-shadow: 0 0 10px var(--neon-blue);
    animation: scan 3s linear infinite;
    opacity: 0.5; pointer-events: none;
}
@keyframes scan { 0% { top: 0%; } 50% { top: 100%; } 100% { top: 0%; } }

.login-header h1 {
    font-family: 'Orbitron', sans-serif; color: var(--neon-blue);
    font-size: 1.5rem; margin: 0; letter-spacing: 2px;
    text-shadow: 0 0 10px var(--neon-blue);
}

.login-sub { font-family: 'Share Tech Mono'; color: #888; font-size: 0.8rem; margin-top: 5px; }

.login-group { margin-bottom: 20px; text-align: left; }
.login-label { display: block; font-family: 'Share Tech Mono'; color: var(--neon-blue); font-size: 0.8rem; margin-bottom: 5px; }

.login-input {
    width: 100%; padding: 12px;
    background: rgba(0, 0, 0, 0.5); border: 1px solid #333;
    color: white; font-family: 'Orbitron'; font-size: 1rem;
    box-sizing: border-box; transition: 0.3s;
}
.login-input:focus { outline: none; border-color: var(--neon-blue); box-shadow: 0 0 10px rgba(0, 243, 255, 0.3); }

.btn-main {
    width: 100%; padding: 15px;
    background: transparent; border: 1px solid var(--neon-blue);
    color: var(--neon-blue); font-family: 'Orbitron'; font-size: 1rem;
    font-weight: bold; cursor: pointer; letter-spacing: 2px;
    transition: all 0.3s;
}
.btn-main:hover { background: var(--neon-blue); color: #000; box-shadow: 0 0 20px var(--neon-blue); }
.btn-main:disabled { opacity: 0.5; cursor: wait; }

.mode-switch {
    margin-top: 20px; font-size: 0.75rem; color: #666;
    cursor: pointer; font-family: 'Share Tech Mono';
    border-bottom: 1px dotted #666; display: inline-block;
}
.mode-switch:hover { color: var(--neon-blue); border-color: var(--neon-blue); }

.feedback-msg {
    font-family: 'Share Tech Mono'; font-size: 0.8rem; margin-top: 15px;
    display: none;
}
.error { color: var(--neon-red); text-shadow: 0 0 5px var(--neon-red); }
.success { 
    color: var(--neon-green); font-family: 'Orbitron'; font-size: 1.5rem; 
    margin-top: 20px; text-shadow: 0 0 10px var(--neon-green); 
    animation: blink 0.5s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* =========================================
   DASHBOARD MODULE STYLES
   ========================================= */
#view-dashboard {
    z-index: 10;
    padding: 20px;
    box-sizing: border-box;
}

.dash-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 30px; border-bottom: 1px solid var(--neon-blue);
    padding-bottom: 10px; box-shadow: 0 4px 15px -5px var(--neon-blue);
}
.dash-header h1 {
    font-family: 'Orbitron'; color: var(--neon-blue); margin: 0;
    font-size: 1.8rem; letter-spacing: 2px; text-shadow: 0 0 10px var(--neon-blue);
}

.user-badge {
    font-family: 'Share Tech Mono'; color: var(--neon-green);
    border: 1px solid var(--neon-green); padding: 5px 10px;
    font-size: 0.8rem; cursor: pointer; transition: 0.2s;
}
.user-badge:hover { background: rgba(10, 255, 10, 0.1); }

.grid-container {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 30px; padding-bottom: 80px; overflow-y: auto;
}

.book-card {
    background: rgba(255, 255, 255, 0.03);
    perspective: 1000px; cursor: pointer;
    height: 300px; transition: transform 0.3s ease;
    position: relative;
}
.book-card:hover { transform: translateY(-5px) scale(1.02); z-index: 20; }

.card-inner {
    width: 100%; height: 100%;
    background: var(--bg-panel);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center;
    color: white; padding: 20px; box-sizing: border-box;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    position: relative;
}

.card-inner h3 {
    font-family: 'Orbitron'; font-size: 1.1rem; margin: 0; z-index: 2;
    text-shadow: 0 0 5px black;
}

.edit-icon {
    position: absolute; top: 10px; right: 10px;
    width: 30px; height: 30px; border-radius: 50%;
    border: 1px solid currentColor;
    display: flex; justify-content: center; align-items: center;
    opacity: 0.6; transition: 0.2s; z-index: 5;
}
.edit-icon:hover { opacity: 1; background: rgba(0,0,0,0.5); }

.add-card {
    border: 1px dashed var(--neon-green); background: rgba(10, 255, 10, 0.05);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    color: var(--neon-green); cursor: pointer; height: 300px;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    transition: all 0.2s;
}
.add-card:hover { box-shadow: inset 0 0 20px rgba(10, 255, 10, 0.2); }

/* =========================================
   NOTEBOOK MODULE STYLES
   ========================================= */
#view-notebook {
    z-index: 20;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
    align-items: center; justify-content: center;
}

/* Nav Bar with AI Buttons */
.nav-bar { 
    position: absolute; top: 15px; left: 15px; right: 15px;
    z-index: 100;
    display: flex; justify-content: space-between;
    pointer-events: none; /* Let clicks pass */
}

.nav-left { pointer-events: auto; }
.nav-right { pointer-events: auto; display: flex; gap: 10px; }

.nav-btn {
    background: rgba(0,0,0,0.6); 
    border: 1px solid;
    padding: 8px 16px;
    font-family: 'Orbitron'; cursor: pointer; text-transform: uppercase;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    transition: 0.2s;
    font-size: 0.8rem;
    color: white;
    display: flex; align-items: center; gap: 8px;
}

.btn-back { border-color: var(--neon-blue); color: var(--neon-blue); }
.btn-back:hover { background: var(--neon-blue); color: black; }

.btn-ai-link { border-color: var(--neon-pink); color: var(--neon-pink); }
.btn-ai-link:hover { background: var(--neon-pink); color: black; box-shadow: 0 0 15px var(--neon-pink); }

.btn-ai-scan { border-color: var(--neon-amber); color: var(--neon-amber); }
.btn-ai-scan:hover { background: var(--neon-amber); color: black; box-shadow: 0 0 15px var(--neon-amber); }

/* Loading Animation State */
.btn-loading { animation: pulse-border 1s infinite; cursor: wait; opacity: 0.7; }
@keyframes pulse-border { 50% { border-color: white; box-shadow: 0 0 10px white; } }

.book-stage {
    width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    perspective: 1500px;
}

.book-3d {
    position: relative; width: 360px; height: 580px;
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

.page {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: 8px;
    transform-origin: left center;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    backface-visibility: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    background: #0f0f13;
}

.page.flipped { transform: rotateY(-180deg); }

/* Layering - Cover always on top of stack logic */
#page-cover { z-index: 1000; }

.cover-content {
    height: 100%; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.9);
    background-size: cover;
}

.title-badge {
    border: 2px solid white; padding: 20px;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    text-align: center; position: relative;
}
.title-badge h1 { font-family: 'Orbitron'; font-size: 2.5rem; margin: 0; text-shadow: 0 0 10px currentColor; }

.sheet-content {
    height: 100%; width: 100%; padding: 25px; box-sizing: border-box;
    background-color: #111;
    background-image: 
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), 
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    box-shadow: inset 0 0 20px rgba(0,243,255,0.05);
    border-right: 1px solid #333;
}

.sheet-header {
    border-bottom: 1px solid; margin-bottom: 10px; padding-bottom: 5px;
    display: flex; justify-content: space-between;
    font-size: 0.8rem; font-family: 'Share Tech Mono';
}

textarea {
    width: 100%; height: calc(100% - 40px);
    background: transparent; border: none; resize: none; outline: none;
    font-family: 'Share Tech Mono'; font-size: 1.1rem; line-height: 1.5;
    color: #0aff0a; text-shadow: 0 0 2px rgba(10, 255, 10, 0.4);
}

.controls {
    position: absolute; bottom: 20px; width: 100%;
    display: flex; justify-content: center; gap: 30px;
    pointer-events: none; z-index: 100;
}
.ctrl-btn {
    pointer-events: auto; width: 60px; height: 60px;
    background: rgba(0,0,0,0.8); border: 2px solid var(--neon-blue);
    border-radius: 50%; color: var(--neon-blue); font-size: 1.5rem;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
}

/* =========================================
   MODAL STYLES (SHARED)
   ========================================= */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 200; justify-content: center; align-items: center;
}
.modal {
    background: rgba(10, 10, 20, 0.95); padding: 30px; 
    width: 85%; max-width: 350px; border: 1px solid var(--neon-blue);
    box-shadow: 0 0 20px var(--neon-blue);
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--neon-blue); font-family: 'Share Tech Mono'; }
.form-group input {
    width: 100%; padding: 12px; background: #000; border: 1px solid #333; color: white;
    font-family: 'Share Tech Mono'; box-sizing: border-box;
}
.color-options { display: flex; gap: 10px; justify-content: center; }
.color-opt {
    width: 30px; height: 30px; cursor: pointer; border: 2px solid #333;
    clip-path: polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%);
}
.color-opt.selected { border-color: white; transform: scale(1.2); }

/* AI Result Modal Special Styling */
#ai-result-content {
    font-family: 'Share Tech Mono'; color: var(--neon-green); 
    max-height: 200px; overflow-y: auto;
    border: 1px solid rgba(0,255,0,0.3); padding: 10px;
    background: rgba(0,0,0,0.5); font-size: 0.9rem;
    white-space: pre-wrap;
}

/* Mobile scaling */
@media (max-width: 450px) { .book-3d { transform: scale(0.85); } }
@media (max-height: 700px) { .book-3d { transform: scale(0.75); } }