/* style.css - Modern Glassmorphic Cyberpunk Theme for Knowledge Kingdom */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

:root {
    --font-main: 'Kanit', sans-serif;
    --bg-dark: #0a0c16;
    --panel-bg: rgba(15, 23, 42, 0.75);
    --panel-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(12px);
    
    --primary: #8b5cf6;       /* Violet */
    --primary-glow: rgba(139, 92, 246, 0.4);
    --secondary: #06b6d4;     /* Cyan */
    --secondary-glow: rgba(6, 182, 212, 0.4);
    --danger: #ef4444;        /* Red */
    --success: #10b981;       /* Emerald */
    --warning: #f59e0b;       /* Amber */
    
    --text-white: #f8fafc;
    --text-gray: #94a3b8;
    --text-dark: #0f172a;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 10% 20%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(6, 182, 212, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Landing Page Styles */
.landing-container {
    max-width: 1000px;
    margin: 50px auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.hero-logo {
    font-size: 3.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px var(--primary-glow);
    margin-bottom: 5px;
    text-align: center;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-gray);
    margin-bottom: 40px;
    text-align: center;
    letter-spacing: 1px;
}

.auth-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 480px;
    backdrop-filter: var(--glass-blur);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
}

.auth-card:hover {
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 8px 32px 0 var(--primary-glow);
}

.tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-gray);
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.tab-btn.active {
    color: var(--text-white);
    border-bottom: 3px solid var(--primary);
    text-shadow: 0 0 8px var(--primary-glow);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.auth-form.active {
    display: flex;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input, .form-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-white);
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 10px var(--secondary-glow);
    background: rgba(255, 255, 255, 0.08);
}

.sprite-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 5px;
}

.sprite-option {
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
}

.sprite-option.selected {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.15);
    box-shadow: 0 0 10px var(--primary-glow);
}

.sprite-option svg {
    width: 48px;
    height: 48px;
}

.btn {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, #0891b2 100%);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px var(--secondary-glow);
}

/* Main Game Layout */
.game-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 40px);
}

@media (max-width: 1024px) {
    .game-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.player-panel, .quest-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: var(--glass-blur);
}

/* HUD elements */
.avatar-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.avatar-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin: 6px 0 15px 0;
    position: relative;
}

.hud-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.hud-hp { background: linear-gradient(90deg, #ef4444, #f87171); }
.hud-mp { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.hud-exp { background: linear-gradient(90deg, #10b981, #34d399); }

.hud-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

.currency-info {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.currency-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

/* Canvas Area */
.game-viewport-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-canvas-area {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    background: #000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    aspect-ratio: 4/3;
    max-height: 600px;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Quest Tracker */
.quest-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.quest-item:last-child {
    border-bottom: none;
}

.quest-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--secondary);
}

.quest-progress {
    font-size: 0.85rem;
    color: var(--text-gray);
}

/* Chatbox styles */
.chat-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 180px;
    backdrop-filter: var(--glass-blur);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    padding-right: 5px;
}

.chat-msg {
    line-height: 1.4;
}

.chat-sender {
    font-weight: 600;
    color: var(--secondary);
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
}

.chat-input:focus {
    border-color: var(--primary);
}

/* Overlays and Modals */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 22, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.overlay-content {
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid var(--primary);
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 0 30px var(--primary-glow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Dialog Box */
.dialog-box {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.92);
    border: 2px solid var(--secondary);
    border-radius: 12px;
    padding: 16px 20px;
    backdrop-filter: var(--glass-blur);
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.dialog-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.dialog-text {
    font-size: 1rem;
    line-height: 1.5;
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    font-size: 0.8rem;
    color: var(--text-gray);
    font-weight: 500;
    animation: blink 1s infinite;
}

/* Battle Overlay (Combat Screen) */
.battle-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #1e1b4b 0%, #030712 100%);
    z-index: 60;
    display: none;
    flex-direction: column;
    padding: 20px;
    justify-content: space-between;
}

.battle-arena {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex: 1;
}

.battle-character {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.battle-sprite {
    width: 96px;
    height: 96px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.battle-sprite svg {
    width: 100%;
    height: 100%;
}

.battle-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.battle-hp-bar {
    width: 120px;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.battle-hp-fill {
    height: 100%;
    background: #ef4444;
    transition: width 0.3s ease;
}

/* Battle action panels */
.battle-controls {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 15px;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 15px;
}

.battle-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.battle-btn {
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

.battle-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.battle-log {
    border-left: 1px solid rgba(255,255,255,0.1);
    padding-left: 15px;
    height: 110px;
    overflow-y: auto;
    font-size: 0.85rem;
    color: var(--text-gray);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Question Modal inside Battle */
.question-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 12, 26, 0.98);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 25px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 0 25px var(--primary-glow);
    z-index: 70;
    display: none;
    flex-direction: column;
    gap: 15px;
}

.question-text {
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-white);
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    text-align: left;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.option-btn:hover {
    background: rgba(6, 182, 212, 0.1);
    border-color: var(--secondary);
    box-shadow: 0 0 8px var(--secondary-glow);
}

/* Floating damage numbers */
.floating-damage {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    animation: floatUp 0.8s ease-out forwards;
    pointer-events: none;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

/* Admin / Teacher Dashboard styles */
.admin-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    backdrop-filter: var(--glass-blur);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 20px;
    margin-bottom: 25px;
}

.admin-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.card-num {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--secondary);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.admin-table th, .admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-gray);
    font-weight: 600;
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

/* Animations */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-40px) scale(1.2); opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes popScale {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Custom Game Alert Styles */
.alert-popup-content {
    background: rgba(15, 23, 42, 0.98) !important;
    border: 2px solid var(--primary);
    border-radius: 18px;
    padding: 30px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 40px var(--primary-glow);
    animation: popScale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.alert-success-title {
    color: var(--success) !important;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.alert-error-title {
    color: var(--danger) !important;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.alert-info-title {
    color: var(--secondary) !important;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

