:root {
    --bg: #060913;
    --surface: rgba(13, 20, 36, 0.80);
    --surface-solid: #0d1424;
    --surface-hover: rgba(20, 32, 58, 0.94);
    --border: rgba(56, 189, 248, 0.18);
    --border-strong: rgba(56, 189, 248, 0.45);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #0ea5e9;
    --primary-alt: #3b82f6;
    --primary-hover: #0284c7;
    --cyan-glow: rgba(6, 182, 212, 0.32);
    --accent: #10b981;
    --danger: #ef4444;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 6px 22px var(--cyan-glow); }
    50% { box-shadow: 0 8px 30px rgba(14, 165, 233, 0.52); }
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    background-image: linear-gradient(to bottom, rgba(6, 9, 19, 0.72), rgba(6, 9, 19, 0.93)), url('assets/bg.jpg');
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* Navbar */
.navbar {
    background: rgba(6, 9, 19, 0.84);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-inner { display: flex; justify-content: space-between; align-items: center; min-height: 70px; flex-wrap: wrap; gap: 12px; padding: 8px 0; }
.logo {
    font-size: 1.42rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.5px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.25s ease;
}
.logo:hover { transform: scale(1.02); }
.logo img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 0 14px var(--cyan-glow);
}
.logo span { color: var(--primary); }
.logo small {
    font-size: 0.7rem;
    background: rgba(14, 165, 233, 0.16);
    border: 1px solid var(--border-strong);
    color: #38bdf8;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
}
.nav-links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.93rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.nav-links a:hover, .nav-links a.active { color: #fff; background: rgba(14, 165, 233, 0.12); }
.nav-links a.logout-link { color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.nav-links a.logout-link:hover { background: rgba(239, 68, 68, 0.2); color: #fff; }

.btn-school, .btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-alt));
    color: #fff !important;
    padding: 9px 18px;
    border-radius: 9px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.92rem;
    box-shadow: 0 4px 18px var(--cyan-glow);
    transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}
.btn-school:hover, .btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.45);
}
.btn-school:active, .btn-primary:active { transform: translateY(0); }

.btn-outline {
    background: rgba(13, 20, 36, 0.75);
    border: 1px solid var(--border-strong);
    color: #38bdf8;
    padding: 8px 15px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.86rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.btn-outline:hover { background: rgba(14, 165, 233, 0.18); color: #fff; transform: translateY(-1px); }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-danger:hover { background: var(--danger); color: #fff; transform: translateY(-1px); }

/* Hero */
.hero {
    padding: 68px 0 54px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    animation: fadeInUp 0.65s ease both;
}
.badge {
    display: inline-block;
    background: rgba(14, 165, 233, 0.14);
    border: 1px solid var(--border-strong);
    color: #38bdf8;
    padding: 4px 14px;
    border-radius: 99px;
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 14px;
    animation: floatSlow 4s ease-in-out infinite;
}
.hero h1 { font-size: 2.55rem; margin-bottom: 12px; color: #fff; text-shadow: 0 2px 24px rgba(6, 182, 212, 0.28); }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto 28px; font-size: 1.06rem; }

.search-bar { display: flex; max-width: 560px; margin: 0 auto; gap: 8px; }
.search-bar input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2); }
.search-bar button {
    padding: 12px 22px;
    border: none;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--primary-alt));
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}
.search-bar button:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Filter & Grid */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 34px 0 24px; animation: fadeInUp 0.7s ease both; }
.filter-chip {
    padding: 6px 15px;
    border-radius: 99px;
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.filter-chip:hover, .filter-chip.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-alt));
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 22px;
    margin-bottom: 60px;
}
.article-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.75s ease both;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.article-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 20px rgba(6, 182, 212, 0.14);
}
.card-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 0.85rem; color: var(--muted); }
.tag { background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; padding: 3px 10px; border-radius: 6px; font-weight: 600; }
.tag-cyan { background: rgba(14, 165, 233, 0.14); border: 1px solid rgba(14, 165, 233, 0.3); color: #38bdf8; padding: 3px 10px; border-radius: 6px; font-weight: 600; }
.article-card h2 { font-size: 1.25rem; margin-bottom: 10px; }
.article-card h2 a { color: #fff; text-decoration: none; transition: color 0.2s ease; }
.article-card h2 a:hover { color: #38bdf8; }
.article-card p { color: var(--muted); font-size: 0.95rem; flex: 1; margin-bottom: 18px; }
.read-more { color: #38bdf8; text-decoration: none; font-weight: 600; font-size: 0.9rem; transition: transform 0.2s ease; display: inline-block; }
.read-more:hover { transform: translateX(4px); }

/* Single Article */
.article-single { max-width: 820px; padding: 40px 20px 80px; animation: fadeInUp 0.65s ease both; }
.article-box {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 34px;
}
.back-link { display: inline-block; color: #38bdf8; text-decoration: none; margin-bottom: 20px; font-weight: 500; }
.article-single h1 { font-size: 2.1rem; margin-bottom: 24px; color: #fff; }
.article-content p { margin-bottom: 16px; color: #cbd5e1; }
.article-content h3 { margin: 24px 0 10px; color: #fff; }
.article-content code { background: rgba(6, 9, 19, 0.8); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; font-family: monospace; color: #38bdf8; }

/* Login & School & Admin Panels */
.login-wrapper { display: flex; align-items: center; justify-content: center; padding: 60px 20px; flex: 1; }
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 34px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    animation: fadeInUp 0.65s ease both;
}
.login-card h1 { font-size: 1.6rem; margin-bottom: 8px; color: #fff; }
.login-card p.sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 22px; }

.page-header { margin: 32px 0 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; animation: fadeInUp 0.6s ease both; }
.page-header h1 { font-size: 1.85rem; color: #fff; }
.page-header p { color: var(--muted); font-size: 0.95rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    animation: fadeInUp 0.7s ease both;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.stat-card small { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .num { font-size: 2.05rem; font-weight: 800; color: #38bdf8; margin-top: 6px; }

.panel {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 26px;
    margin-bottom: 26px;
    animation: fadeInUp 0.75s ease both;
}
.panel h2 { font-size: 1.25rem; color: #fff; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.88rem; color: #cbd5e1; margin-bottom: 6px; font-weight: 500; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(6, 9, 19, 0.8);
    color: #fff;
    font-size: 0.94rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-group textarea { min-height: 110px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 0.92rem; }
.alert-success { background: rgba(16, 185, 129, 0.16); border: 1px solid rgba(16, 185, 129, 0.4); color: #6ee7b7; animation: fadeInUp 0.4s ease both; }
.alert-error {
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    animation: shakeError 0.42s ease both;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: #38bdf8; font-weight: 600; background: rgba(6, 9, 19, 0.55); }
tr { transition: background 0.2s ease; }
tr:hover td { background: rgba(20, 32, 58, 0.5); }
.badge-pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; }
.badge-active { background: rgba(16, 185, 129, 0.16); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-inactive { background: rgba(148, 163, 184, 0.16); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.35); }
.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; }

.files-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 60px; }
.file-row {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    animation: fadeInUp 0.65s ease both;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.file-row:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-hover); }
.file-info h3 { font-size: 1.12rem; color: #fff; margin: 6px 0 4px; }
.file-info p { color: var(--muted); font-size: 0.92rem; margin-bottom: 8px; }
.file-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.82rem; color: #94a3b8; }

.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 24px;
    text-align: center;
    margin-bottom: 60px;
}
.empty-state p { color: var(--muted); margin-bottom: 14px; }

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    background: rgba(6, 9, 19, 0.86);
    padding: 24px 0;
    color: var(--muted);
    font-size: 0.9rem;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--muted); text-decoration: none; transition: color 0.2s ease; }
.footer-links a:hover { color: #38bdf8; }

/* AI Chat Widget */
.chat-widget { position: fixed; bottom: 24px; right: 24px; z-index: 100; }
.chat-toggle {
    background: linear-gradient(135deg, var(--primary), var(--primary-alt));
    color: #fff;
    border: none;
    padding: 13px 20px;
    border-radius: 99px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    animation: pulseGlow 3s ease-in-out infinite;
    transition: transform 0.2s ease;
}
.chat-toggle:hover { transform: translateY(-2px) scale(1.03); }
.chat-toggle img { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; }

.chat-box {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 355px;
    max-width: calc(100vw - 32px);
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    animation: popIn 0.25s ease both;
}
.chat-box.hidden { display: none; }
.chat-header {
    background: rgba(14, 165, 233, 0.14);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.chat-header small { display: block; color: var(--muted); font-size: 0.78rem; }
.chat-close { background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; transition: color 0.2s ease; }
.chat-close:hover { color: #fff; }
.chat-messages { padding: 14px; height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 10px; font-size: 0.9rem; max-width: 85%; white-space: pre-wrap; animation: popIn 0.22s ease both; }
.msg.bot { background: rgba(30, 41, 59, 0.92); color: var(--text); align-self: flex-start; border: 1px solid var(--border); }
.msg.user { background: linear-gradient(135deg, var(--primary), var(--primary-alt)); color: #fff; align-self: flex-end; }
.msg.loading { opacity: 0.75; font-style: italic; }

.chat-quick-chips { padding: 8px 14px; display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.quick-chip {
    background: rgba(6, 9, 19, 0.8);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.quick-chip:hover { color: #fff; border-color: var(--primary); transform: translateY(-1px); }

.chat-input-area { display: flex; border-top: 1px solid var(--border); }
.chat-input-area input { flex: 1; padding: 12px; background: transparent; border: none; color: #fff; outline: none; }
.chat-input-area button { background: var(--primary); color: #fff; border: none; padding: 0 16px; font-weight: 600; cursor: pointer; transition: background 0.2s ease; }
.chat-input-area button:hover { background: var(--primary-hover); }

@media (max-width: 640px) {
    .file-row { flex-direction: column; align-items: flex-start; }
    .hero h1 { font-size: 2rem; }
}
