:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-elevated: #1c1c28;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2a2a3a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Login Screen */
.screen { min-height: 100vh; }

#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
}

.login-card {
    background: var(--bg-card);
    padding: 3rem 2.5rem;
    border-radius: 24px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.05), inset 0 1px 0 rgba(255,255,255,0.05);
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    text-shadow: 0 0 40px rgba(99, 102, 241, 0.4);
}

.login-tagline {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
}

.accent {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-word {
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
}

.title-plain {
    display: inline;
}

.title-word .accent {
    display: inline;
    margin: 0;
    padding: 0;
}

.version-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 0.2rem;
    align-self: flex-end;
    padding-bottom: 0.2rem;
    letter-spacing: 0.04em;
    opacity: 0.8;
}

.acn {
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* Forms */
form { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-top: 0.5rem; }

input[type="email"], input[type="password"], input[type="text"] {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
input::placeholder { color: var(--text-muted); }

button {
    padding: 0.85rem 1.5rem;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    letter-spacing: 0.01em;
    margin-top: 0.5rem;
}
button:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px var(--accent-glow); }
button:active { transform: translateY(0); }

.error { color: var(--error); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.25rem; }

.forgot-link {
    display: block;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 0.5rem;
    transition: color 0.15s ease;
}
.forgot-link:hover { color: var(--accent-hover); }

.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

/* App screen layout */
#app-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#app-screen > main {
    flex: 1;
}


header {
    width: 100%;
    padding: 0 2rem;
    height: 64px;
    background: rgba(18, 18, 26, 0.8);
    backdrop-filter: blur(20px);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    justify-self: start;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
}
.home-link:hover { opacity: 0.85; }

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.5));
}

nav { display: flex; gap: 0.4rem; align-items: center; justify-self: center; }

#logout-btn { justify-self: end; }

.nav-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s ease;
    margin-top: 0;
}
.nav-btn:hover { color: var(--text-primary); background: var(--bg-elevated); transform: none; box-shadow: none; opacity: 1; }
.nav-btn.active { color: var(--text-primary); background: var(--accent); background-image: var(--gradient); }
.nav-btn.secondary { color: var(--text-muted); }
.nav-btn.secondary:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

main h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Video Cards */
.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.video-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent-glow);
}
.video-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.video-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.video-card .reason {
    font-style: italic;
    color: var(--accent);
    font-size: 0.85rem;
}

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.tag {
    background: var(--bg-elevated);
    color: var(--accent-hover);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-badge.completed { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status-badge.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-badge.failed { background: rgba(239, 68, 68, 0.15); color: var(--error); }

/* Player View */
#player-view { max-width: 1000px; }
#back-btn {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}
#back-btn:hover { color: var(--text-primary); background: var(--bg-card); transform: none; box-shadow: none; opacity: 1; }

#video-player {
    width: 100%;
    border-radius: 16px;
    background: #000;
    margin-bottom: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

#video-meta {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}
#video-summary {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
}
#video-topics { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Admin View */
#admin-view { max-width: 800px; }
#upload-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

input[type="file"] {
    padding: 0.85rem 1rem;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
}
input[type="file"]:hover { border-color: var(--accent); }
input[type="file"]::file-selector-button {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 1rem;
    font-weight: 500;
}

#upload-status {
    color: var(--accent);
    font-size: 0.9rem;
    margin-top: 1rem;
    min-height: 1.25rem;
}

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    gap: 1rem;
}
.admin-item-info { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.admin-item-title { color: var(--text-primary); font-weight: 500; }
.admin-item-summary { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.admin-item button {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0;
}
.admin-item button:hover { background: rgba(239, 68, 68, 0.1); transform: none; box-shadow: none; opacity: 1; }

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
    font-size: 1rem;
}

/* Chatbot */
#chatbot { position: fixed; bottom: 2rem; right: 2rem; z-index: 100; }

#chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px var(--accent-glow);
    padding: 0;
    margin: 0;
}
#chat-toggle:hover { transform: scale(1.05); }

#chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
#chat-close {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin: 0;
}
#chat-close:hover { color: var(--text-primary); background: var(--bg-card); transform: none; box-shadow: none; opacity: 1; }

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-msg.bot {
    align-self: flex-start;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-msg.typing { opacity: 0.7; font-style: italic; }
.chat-video-link {
    color: var(--accent-hover);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

#chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}
#chat-form input {
    flex: 1;
    border-radius: 20px;
    padding: 0.75rem 1rem;
}
#chat-form button {
    padding: 0.75rem 1.25rem;
    border-radius: 20px;
    margin: 0;
}

/* Shared progress bar (used in upload toast) */
.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-bar.indeterminate .progress-fill {
    width: 40%;
    animation: indeterminate 1.5s ease-in-out infinite;
}
@keyframes indeterminate {
    from { transform: translateX(-100%); }
    to   { transform: translateX(350%); }
}

/* Upload Toast */
#upload-toast {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 300;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    min-width: 260px;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.25s ease;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
#upload-toast.toast-success { border-color: rgba(34, 197, 94, 0.4); }
#upload-toast.toast-error   { border-color: rgba(239, 68, 68, 0.4); }
#toast-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
#toast-icon { font-size: 1.1rem; flex-shrink: 0; }
#toast-title { flex: 1; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
#toast-close {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    margin: 0;
    line-height: 1;
    flex-shrink: 0;
}
#toast-close:hover { color: var(--text-primary); background: var(--bg-card); transform: none; box-shadow: none; opacity: 1; }
#toast-percent {
    font-size: 0.78rem;
    color: var(--accent-hover);
    font-weight: 600;
    min-height: 1rem;
    margin-top: 0.25rem;
}

/* Edit Metadata Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}
.edit-modal-content {
    max-width: 500px;
    text-align: left;
}
.edit-modal-content h3 { margin-bottom: 1.25rem; font-size: 1.15rem; }
.edit-modal-content textarea {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    width: 100%;
    transition: all 0.2s ease;
}
.edit-modal-content textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.field-hint { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.edit-modal-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
.edit-modal-actions button { flex: 1; margin-top: 0; }
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    background-image: none;
}
.btn-secondary:hover { background: var(--bg-card); color: var(--text-primary); box-shadow: none; }
.admin-item button.edit-btn {
    background: transparent;
    color: var(--accent-hover);
    border: 1px solid var(--accent);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0;
}
.admin-item button.edit-btn:hover { background: rgba(99, 102, 241, 0.1); transform: none; box-shadow: none; opacity: 1; }
.admin-item-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    header { padding: 0 1rem; grid-template-columns: auto 1fr auto; }
    header h1 { font-size: 1.1rem; }
    .logo-icon { width: 26px; height: 26px; }
    nav { gap: 0.25rem; }
    .nav-btn { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
    main { padding: 1rem; }
    .video-grid { grid-template-columns: 1fr; }
    #chat-panel { width: calc(100vw - 2rem); right: -1rem; }
    .login-card { margin: 1rem; padding: 1.5rem; }
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.footer-name {
    color: var(--accent-hover);
    text-decoration: none;
    transition: color 0.15s ease;
    cursor: pointer;
}
.footer-name:hover { color: var(--accent); }
.footer-powered { font-size: 0.75rem; opacity: 0.6; }

/* Fireworks */
#fireworks-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}
