/* =========================================
   1. GENERAL WEBSITE STYLES (FROM UPLOAD)
   ========================================= */
:root {
    /* General Site Colors */
    --primary-color: #0d6efd; /* Bootstrap Blue */
    --secondary-color: #6c757d; /* Bootstrap Gray */
    --light-gray: #f8f9fa;
    --dark-color: #212529;
    --text-color: #333;
    --font-family: 'Poppins', sans-serif; 
    
    /* LAMP SPECIFIC VARIABLES */
    --lamp-primary: #4ade80; /* Neon Green */
    --lamp-danger: #ef4444;  /* Red */
    --lamp-bg-light: #1f2937;      /* Dark Grey Blue */
    --lamp-bg-dark: #050505;       /* Pitch Black */
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    background-color: #fff;
    color: var(--text-color);
}

/* Header & Navigation */
.navbar-brand { font-weight: 700; font-size: 1.5rem; }
.navbar { box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.navbar-logo { height: 45px; margin-right: 10px; }

/* =========================================
   2. ANIMATED LOGIN PAGE STRUCTURE
   ========================================= */

body.animated-login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: auto; /* Allows content to grow */
    background-color: var(--lamp-bg-dark);
    
    /* Scrolling Setup */
    overflow-y: auto; 
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    
    font-family: 'Poppins', sans-serif;
    user-select: none;
    transition: background-color 0.5s;
}

.login-container-wrapper {
    display: flex;
    align-items: center;
    gap: 40px;
    position: relative;
    z-index: 10;
    width: 100%;
    justify-content: center;
}

/* --- LAMP SVG WRAPPER --- */
.lamp-wrapper {
    width: 220px;
    height: 450px;
    position: relative;
    z-index: 10;
}

.lamp-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

#lampHeadGroup {
    transform-origin: 110px 140px; /* Pivot point for wobble */
    cursor: pointer;
}

.smooth-return {
    transition: transform 0.8s cubic-bezier(0.5, -0.5, 0.2, 1.5);
}

/* Lamp Components */
.lamp-shade { fill: #374151; transition: fill 0.3s; }
.lamp-stand { fill: #6b7280; }
.lamp-joint { fill: #9ca3af; }

.beam-path {
    fill: url(#beamGradient);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.cord-line { stroke: #9ca3af; stroke-width: 2; pointer-events: none; }
.cord-handle { fill: #e5e7eb; cursor: grab; }
.cord-handle:active { cursor: grabbing; fill: white; }
.snap-cord { transition: all 0.6s cubic-bezier(0.5, -0.5, 0.2, 1.5); }


/* --- LOGIN BOX (Collapsible) --- */
.login-box {
    width: 360px;
    background: #1e1e1e;
    border-radius: 20px;
    /* Initial Hidden State */
    max-height: 0; 
    padding: 0 40px; 
    overflow: hidden;
    border: 0 solid #374151;
    
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-logo {
    width: 100px;
    height: auto;
    margin: 0 auto 5px auto;
    display: block;
}

.login-box h2 {
    color: white;
    margin-bottom: 5px;
    font-weight: 700;
    text-align: center;
}

.login-box p {
    color: #9ca3af;
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

/* Inputs */
.input-group-lamp { display: flex; flex-direction: column; gap: 8px; }

.input-group-lamp input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    background: #2d2d2d;
    border: 1px solid #4b5563;
    color: white;
    outline: none;
    font-size: 14px;
}
.input-group-lamp input:focus { border-color: var(--lamp-primary); }

/* Button */
.login-lamp-btn {
    width: 100%;
    padding: 12px;
    background: var(--lamp-primary);
    color: #065f46;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}
.login-lamp-btn:hover { box-shadow: 0 0 15px var(--lamp-primary); }

.links {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}
.links a { color: #6b7280; font-size: 0.85rem; text-decoration: none; }
.links a:hover { color: var(--lamp-primary); }


/* =========================================
   3. INTERACTIVE STATES
   ========================================= */

/* --- POWER ON (Light On / Form Open) --- */
body.power-on { background-color: var(--lamp-bg-light); }
body.power-on .lamp-shade { fill: var(--lamp-primary); }
body.power-on .beam-path { opacity: 1; }

/* Expand Form */
body.power-on .login-box {
    max-height: 600px; 
    padding: 40px;     
    border: 2px solid var(--lamp-primary); 
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    box-shadow: 0 0 30px rgba(74, 222, 128, 0.15);
}

/* --- PEEKING (Password Typing - Dark Mode) --- */
body.power-on.peeking { background-color: var(--lamp-bg-dark); }
body.power-on.peeking .lamp-shade { fill: #374151; }
body.power-on.peeking .beam-path { opacity: 0; }

body.power-on.peeking .login-box {
    border-color: var(--lamp-danger);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}
body.power-on.peeking .login-lamp-btn {
    background-color: var(--lamp-danger);
    color: white;
    box-shadow: none;
}
body.power-on.peeking .input-group-lamp input:focus {
    border-color: var(--lamp-danger);
}


/* =========================================
   4. ANIMATIONS (Blinking, Flicker, Glitch)
   ========================================= */

/* --- A. HUMAN BLINKING (For Happy Face) --- */
@keyframes blink {
    0%, 96%, 100% { transform: scaleY(1); }
    98% { transform: scaleY(0.1); } /* Fast snap close */
}

.blink-eyes {
    animation: blink 5s infinite; /* Blink every 5 seconds */
    transform-origin: 110px 100px; /* Pivot from center of eyes */
    transform-box: user-space-on-use; 
}

/* --- B. LIGHT FLICKER (For Idle/Annoyed State) --- */
@keyframes flicker-beam {
    0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
    20%, 24%, 55% { opacity: 0.2; }
    21%, 23%, 56% { opacity: 0.6; }
}
@keyframes flicker-shade {
    0%, 18%, 22%, 25%, 53%, 57%, 100% { fill: var(--lamp-primary); }
    20%, 24%, 55% { fill: #2d3748; }
}

/* Classes added via JS when idle */
body.idle-mode .beam-path { animation: flicker-beam 3s infinite; }
body.idle-mode .lamp-shade { animation: flicker-shade 3s infinite; }

/* --- C. GLITCH TRANSITION (On Face Change) --- */
@keyframes glitch-anim {
    0% { transform: translate(0) skew(0deg); opacity: 1; filter: none; }
    20% { transform: translate(-3px, 3px) skew(10deg); opacity: 0.8; filter: hue-rotate(90deg); }
    40% { transform: translate(3px, -3px) skew(-5deg); opacity: 1; filter: none; }
    60% { transform: translate(-3px, 0) skew(20deg); opacity: 0.5; filter: invert(1); }
    80% { transform: translate(3px, 0) skew(0deg); opacity: 1; filter: none; }
    100% { transform: translate(0) skew(0deg); opacity: 1; filter: none; }
}

/* Class added briefly via JS */
.glitch-active .lamp-shade, 
.glitch-active #face-group {
    animation: glitch-anim 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* --- D. BROKEN LAMP (Error State) --- */
.shake-animation { animation: shake 0.6s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}
body.broken .lamp-shade { fill: #4b5563 !important; }
body.broken #lampHeadGroup {
    transform: rotate(25deg) translateY(5px) !important;
    transition: transform 0.5s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}
body.broken .beam-path { opacity: 0 !important; transition: none; }
body.broken .login-box {
    /* Force show login box even if broken so user can retry */
    max-height: 600px;
    padding: 40px;
    opacity: 1;
    border: 2px solid #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
}

/* --- E. WELCOME ANIMATION (Success) --- */
.welcome-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 20;
    display: none;
    width: 100%;
}
.welcome-text {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 20px var(--lamp-primary);
    opacity: 0;
    transform: scale(0.8);
    animation: welcomePop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.welcome-subtext {
    font-size: 1.5rem;
    color: #9ca3af;
    margin-top: 10px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s ease 0.3s forwards;
}
@keyframes welcomePop { to { opacity: 1; transform: scale(1); } }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

body.success-mode { background-color: var(--lamp-bg-light); }
body.success-mode .lamp-shade { fill: var(--lamp-primary); }
body.success-mode .beam-path { opacity: 1; }


/* =========================================
   5. NEON HINT TEXT ("Please light On the lamp")
   ========================================= */

.lamp-hint {
    position: absolute;
    top: 140px;  
    left: 220px; 
    
    /* Allow width to adapt to long text */
    width: auto; 
    white-space: nowrap;
    
    color: #fff;
    font-family: 'Courier New', monospace; 
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1.4;
    text-transform: uppercase;
    
    text-shadow: 
        0 0 5px #fff,
        0 0 10px var(--lamp-primary),
        0 0 20px var(--lamp-primary);
    
    animation: electric-flicker 3s infinite;
    pointer-events: none; 
    opacity: 1;
    transition: opacity 0.5s ease;
    z-index: 5;
}

.lamp-hint .arrow {
    font-size: 1.5rem;
    vertical-align: middle;
    margin-right: 5px;
}

@keyframes electric-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; text-shadow: 0 0 5px #fff, 0 0 10px var(--lamp-primary); }
    20%, 24%, 55% { opacity: 0.1; text-shadow: none; }
}

/* --- IMPORTANT: HIDE HINT ON SUCCESS --- */
body.power-on .lamp-hint,
body.broken .lamp-hint,
body.success-mode .lamp-hint { /* <--- ADDED THIS LINE */
    opacity: 0;
    animation: none; 
}


/* =========================================
   6. MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 850px) {
    body.animated-login-page {
        display: flex;
        flex-direction: column; 
        justify-content: flex-start; 
        align-items: center; 
        padding: 40px 0; 
        height: auto;
    }

    .login-container-wrapper {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 100%;
        gap: 0;
    }

    .lamp-wrapper {
        width: 200px;
        height: 380px;
        margin: 0 auto -40px auto; 
        transform: scale(0.9);
        z-index: 1;
        flex-shrink: 0; 
    }

    .login-box {
        width: 90%;
        max-width: 350px;
        margin: 0 auto 50px auto; 
        position: relative;
        z-index: 2;
        background: #1e1e1e;
    }
    
    .welcome-text { font-size: 2rem; }
    .welcome-subtext { font-size: 1.2rem; }

    .lamp-hint {
        left: 160px; 
        top: 110px;
        width: 180px;
        white-space: normal;
        font-size: 0.65rem;
    }
}

/* =========================================
   7. STUDENT DASHBOARD & DARK MODE (NEW)
   ========================================= */

:root {
    --dash-bg: #f4f6f9;
    --dash-card-bg: #ffffff;
    --dash-text: #333333;
    --dash-header-bg: linear-gradient(135deg, #0d6efd, #0043a8);
    --dash-border: #e0e0e0;
    --dash-muted: #6c757d;
}

[data-bs-theme="dark"] {
    --dash-bg: #121212;
    --dash-card-bg: #1e1e1e;
    --dash-text: #e0e0e0;
    --dash-header-bg: linear-gradient(135deg, #000000, #1a1a1a);
    --dash-border: #333333;
    --dash-muted: #a0a0a0;
    --bs-body-color: #e0e0e0;
    --bs-body-bg: #0f1012;
}

/* Only apply these when NOT on the login page */
body:not(.animated-login-page) {
    background-color: var(--dash-bg);
    color: var(--dash-text);
}

.dashboard-header {
    background: var(--dash-header-bg);
    padding: 20px 0 60px 0;
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    margin-bottom: -40px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.dash-card {
    background-color: var(--dash-card-bg);
    color: var(--dash-text);
    border: 1px solid var(--dash-border);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}
.dash-card:hover { transform: translateY(-2px); }

.profile-img-box {
    width: 90px; height: 90px;
    border-radius: 50%;
    border: 4px solid var(--dash-card-bg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    object-fit: cover;
    background-color: #fff;
}

.status-box {
    background-color: var(--light-gray);
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    height: 100%;
    color: var(--dash-text);
}

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background-color: var(--dash-card-bg);
    border-top: 1px solid var(--dash-border);
    padding-bottom: env(safe-area-inset-bottom);
    display: flex; justify-content: space-around; padding: 10px 0; z-index: 1000;
}
.nav-item-mobile { text-align: center; color: var(--dash-muted); text-decoration: none; font-size: 0.75rem; }
.nav-item-mobile.active { color: var(--primary-color); font-weight: 600; }

.theme-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    color: white; background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.qr-display-box { background: #fff !important; padding: 15px; border-radius: 10px; display: inline-block; border: 2px dashed var(--primary-color); }

/* =========================================
   EXISTING STYLES PRESERVED (Keep your existing CSS)
   ========================================= */
/* ... [Your existing CSS content] ... */

/* =========================================
   NEW FEATURES & ANIMATIONS
   ========================================= */

/* --- 1. TRANSMISSION / PAGE TRANSITIONS --- */
.page-transition {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(30px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- 2. CHAT INTERFACE --- */
.chat-widget-container {
    height: 75vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    font-size: 0.95rem;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

@keyframes popIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

.msg-sent {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.msg-received {
    align-self: flex-start;
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.msg-system {
    align-self: center;
    background: rgba(255, 193, 7, 0.15);
    color: #856404;
    font-size: 0.8rem;
    padding: 5px 15px;
    border-radius: 20px;
    text-align: center;
    margin: 10px 0;
}

.chat-img-preview {
    max-width: 150px;
    border-radius: 10px;
    margin-top: 5px;
    border: 2px solid rgba(255,255,255,0.5);
}

/* --- 3. FLIPBOOK / LEARNING BOOK --- */
.book-scene {
    perspective: 1500px;
    width: 100%;
    height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.book {
    width: 400px;
    height: 550px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.book-page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: white;
    border-radius: 5px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
    transform-origin: left center;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    backface-visibility: hidden;
    z-index: 1;
    padding: 30px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.book-page.flipped {
    transform: rotateY(-180deg);
    z-index: 0;
}

.book-page img {
    max-width: 100%;
    border-radius: 5px;
}

.book-nav {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100;
}

/* --- 4. NOTICES --- */
.notice-board-card {
    border-left: 5px solid var(--primary-color);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s;
}
.notice-board-card:hover { transform: translateY(-5px); }

.notice-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 5px 10px;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }