/* ===== المتغيرات: أزرق - كحلي - أبيض - أسود - أخضر - أحمر ===== */
:root {
    --black: #05080f;
    --navy: #0a1128;
    --navy-2: #101a3a;
    --card: #0f1a35;
    --blue: #3b82f6;
    --green: #00ff88;
    --red: #ff4d5e;
    --white: #f4f7ff;
    --muted: #8a97b8;
    --border: #1d2b52;
    --header-h: 64px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--black);
    color: var(--white);
    min-height: 100vh;
    line-height: 1.6;
}

::selection { background: var(--green); color: var(--black); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--green); }

button, input { font-family: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.hidden { display: none !important; }
.neon { color: var(--green); font-weight: 700; }
.muted { color: var(--muted); font-size: 0.8rem; }
.c-blue { color: var(--blue); }
.c-green { color: var(--green); }
.c-red { color: var(--red); }
.c-white { color: var(--white); }

/* ===== صفحة تسجيل الدخول ===== */
.login-page {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: var(--black);
    transition: opacity 0.5s, transform 0.5s;
}
.login-page.leaving { opacity: 0; transform: scale(1.05); }
#matrixCanvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.35; }

.login-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    background: rgba(15, 26, 53, 0.88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.15);
    overflow: hidden;
    animation: cardIn 0.8s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(40px) scale(.95); } }

.login-glow-line {
    position: absolute; top: 0; right: 0; width: 100%; height: 3px;
    background: linear-gradient(to left, var(--green), var(--blue), transparent);
    background-size: 200% 100%;
    animation: slideLine 3s linear infinite;
}
@keyframes slideLine { to { background-position: -200% 0; } }

.login-card.shake { animation: shake 0.45s; }
@keyframes shake {
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.login-head { text-align: center; margin-bottom: 1.8rem; }
.login-icon {
    width: 64px; height: 64px; margin: 0 auto 0.8rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: var(--green);
    background: var(--black); border: 1px solid var(--green); border-radius: 50%;
    animation: pulse 2.2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.5); }
    70% { box-shadow: 0 0 0 16px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}
.login-head h1 { font-size: 1.5rem; font-weight: 800; }
.login-head p { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.field { margin-bottom: 1.2rem; }
.field label { display: block; font-size: 0.85rem; color: #c3cde6; margin-bottom: 0.35rem; }

.input-wrap { position: relative; }
.input-icon {
    position: absolute; top: 50%; right: 0.9rem; transform: translateY(-50%);
    color: var(--muted); transition: color 0.2s;
}
.input-wrap:focus-within .input-icon { color: var(--green); }

.input-wrap input {
    width: 100%; padding: 0.7rem 2.6rem;
    background: var(--black); color: var(--white);
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 1rem; transition: 0.2s;
}
.input-wrap input::placeholder { color: #4a5678; }
.input-wrap input:focus {
    outline: none; border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.15);
}
.input-wrap input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 77, 94, 0.18); }

.eye-btn {
    position: absolute; top: 50%; left: 0.6rem; transform: translateY(-50%);
    background: none; border: none; color: var(--muted); padding: 0.3rem 0.5rem;
    transition: color 0.2s;
}
.eye-btn:hover { color: var(--green); }

.hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; transition: color 0.2s; }
.hint.error { color: var(--red); animation: pop 0.3s; }
@keyframes pop { 50% { transform: scale(1.04); } }

.btn-login {
    width: 100%; padding: 0.8rem; border: none; border-radius: 10px;
    background: linear-gradient(to right, #0b8f5a, var(--green));
    color: var(--black); font-weight: 800; font-size: 1rem;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: transform 0.15s, box-shadow 0.2s;
}
.btn-login:hover { box-shadow: 0 6px 22px rgba(0, 255, 136, 0.35); transform: translateY(-2px); }
.btn-login:active { transform: scale(0.97); }

/* ===== شريط التقدم أثناء التمرير ===== */
.scroll-progress {
    position: fixed; top: 0; right: 0; height: 3px; width: 0;
    background: linear-gradient(to left, var(--green), var(--blue));
    z-index: 70; transition: width 0.1s;
}

/* ===== الهيدر ===== */
.main-content { min-height: 100vh; display: flex; flex-direction: column; animation: fadeIn 0.6s both; }
@keyframes fadeIn { from { opacity: 0; } }

.site-header {
    position: sticky; top: 0; z-index: 60; height: var(--header-h);
    background: rgba(10, 17, 40, 0.88); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: 1100px; margin: 0 auto; height: 100%; padding: 0 1rem;
    display: flex; align-items: center; justify-content: space-between;
}
.header-right, .header-left { display: flex; align-items: center; gap: 0.8rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.15rem; }
.brand > i { color: var(--green); font-size: 1.5rem; }

.welcome {
    display: none; font-size: 0.85rem; color: #c3cde6;
    background: var(--black); padding: 0.25rem 0.8rem; border-radius: 999px; border: 1px solid var(--border);
}
@media (min-width: 640px) { .welcome { display: inline-block; } }

.btn-logout {
    font-size: 0.8rem; color: var(--red);
    background: rgba(255, 77, 94, 0.1); border: 1px solid rgba(255, 77, 94, 0.4);
    padding: 0.4rem 0.8rem; border-radius: 8px; transition: 0.2s;
}
.btn-logout:hover { background: rgba(255, 77, 94, 0.25); }

/* زر الثلاث شرط */
.menu-btn {
    width: 42px; height: 42px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px;
    background: var(--black); border: 1px solid rgba(0, 255, 136, 0.35); border-radius: 10px;
    transition: 0.2s;
}
.menu-btn:hover { background: var(--navy-2); }
.menu-btn span {
    display: block; width: 20px; height: 2px; background: var(--green); border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}
.menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== القائمة الجانبية ===== */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); z-index: 65;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

.sidebar {
    position: fixed; top: 0; right: 0; width: 290px; height: 100%; z-index: 70;
    background: var(--navy); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; justify-content: space-between;
    transform: translateX(100%); transition: transform 0.35s cubic-bezier(.2, .8, .2, 1);
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
    padding: 1.2rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head h2 { font-size: 1.05rem; color: var(--green); display: flex; gap: 0.5rem; align-items: center; }
.close-btn { background: none; border: none; color: var(--muted); font-size: 1.3rem; transition: 0.2s; }
.close-btn:hover { color: var(--white); transform: rotate(90deg); }

.sidebar-nav { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1rem;
    color: #d5dcf0; text-decoration: none; font-weight: 500;
    border: 1px solid transparent; border-radius: 12px;
    transition: 0.25s;
    opacity: 0; transform: translateX(30px);
}
.sidebar.open .sidebar-nav a { opacity: 1; transform: none; }
.sidebar.open .sidebar-nav a:nth-child(1) { transition-delay: 0.10s; }
.sidebar.open .sidebar-nav a:nth-child(2) { transition-delay: 0.16s; }
.sidebar.open .sidebar-nav a:nth-child(3) { transition-delay: 0.22s; }
.sidebar.open .sidebar-nav a:nth-child(4) { transition-delay: 0.28s; }
.sidebar-nav a i { width: 1.2rem; text-align: center; }
.sidebar-nav a:hover { background: var(--card); color: var(--green); border-color: rgba(0, 255, 136, 0.25); transition-delay: 0s; }
.sidebar-nav a.active { background: var(--card); color: var(--green); border-color: var(--green); }

.sidebar-foot { padding: 1rem; text-align: center; font-size: 0.75rem; color: #5f6d92; border-top: 1px solid var(--border); }

/* ===== المحتوى ===== */
main { width: 100%; max-width: 960px; margin: 0 auto; padding: 2rem 1rem; flex-grow: 1; display: flex; flex-direction: column; gap: 3rem; }

section[id] { scroll-margin-top: calc(var(--header-h) + 8px); }

/* Hero */
.hero { display: flex; flex-direction: column; gap: 1.5rem; }
.hero-terminal {
    background: var(--black); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.15);
}
.term-bar { display: flex; align-items: center; gap: 6px; padding: 0.6rem 0.9rem; background: var(--navy-2); }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.red { background: var(--red); } .dot.yellow { background: #ffd24d; } .dot.green { background: var(--green); }
.term-title { margin-right: auto; font-family: monospace; font-size: 0.75rem; color: var(--muted); direction: ltr; }
.term-body { padding: 1.2rem; font-family: 'Courier New', monospace; font-size: 1.05rem; min-height: 90px; color: var(--green); }
.prompt { color: var(--blue); }
.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    padding: 1rem; text-align: center; transition: 0.25s;
}
.stat:hover { border-color: var(--green); transform: translateY(-4px); }
.stat b { display: block; font-size: 2rem; color: var(--green); font-weight: 800; }
.stat span { color: var(--muted); font-size: 0.85rem; }

/* البطاقات */
.card {
    position: relative; background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; padding: 1.6rem; overflow: hidden;
}
.card-blue { box-shadow: 0 0 22px rgba(59, 130, 246, 0.18); }
.card-green { box-shadow: 0 0 22px rgba(0, 255, 136, 0.14); }

.section-title { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.2rem; }
.section-title h2 { font-size: 1.6rem; font-weight: 800; }
.icon-box {
    width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; background: var(--black); border-radius: 12px; border: 1px solid;
}
.icon-box.blue { color: var(--blue); border-color: rgba(59, 130, 246, 0.5); }
.icon-box.green { color: var(--green); border-color: rgba(0, 255, 136, 0.5); }
.icon-box.white { color: var(--white); border-color: rgba(244, 247, 255, 0.4); }
.icon-box.red { color: var(--red); border-color: rgba(255, 77, 94, 0.5); }

.about-text { color: #c9d2ea; font-size: 1.05rem; line-height: 1.9; margin-bottom: 1.4rem; }
.sub-title { font-size: 1rem; margin-bottom: 0.9rem; display: flex; gap: 0.5rem; align-items: center; }

.tools-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
@media (min-width: 640px) { .tools-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .tools-grid { grid-template-columns: repeat(5, 1fr); } }
.tool {
    background: var(--black); border: 1px solid var(--border); border-radius: 12px;
    padding: 0.9rem 0.5rem; text-align: center; cursor: pointer; transition: 0.25s;
}
.tool i { display: block; font-size: 1.7rem; margin-bottom: 0.3rem; transition: transform 0.3s; }
.tool span { font-size: 0.85rem; font-weight: 600; }
.tool:hover { border-color: var(--green); transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0, 255, 136, 0.12); }
.tool:hover i { transform: scale(1.2) rotate(-8deg); }
.tool.selected { border-color: var(--green); background: var(--navy-2); }
.tool-info {
    margin-top: 1rem; padding: 0.7rem 1rem; font-size: 0.9rem; color: var(--green);
    background: var(--black); border-right: 3px solid var(--green); border-radius: 8px;
}
.tool-info.flash { animation: pop 0.3s; }

/* الأنشطة */
.progress-wrap { margin-bottom: 1.2rem; }
.progress-info { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.progress-bar { height: 8px; background: var(--black); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
#progressFill {
    height: 100%; width: 0; border-radius: 999px;
    background: linear-gradient(to left, var(--green), var(--blue));
    transition: width 0.6s cubic-bezier(.2, .8, .2, 1);
}

.add-row { display: flex; gap: 0.7rem; margin-bottom: 1.2rem; }
.add-row input {
    flex-grow: 1; padding: 0.8rem 1rem; background: var(--black); color: var(--white);
    border: 1px solid var(--border); border-radius: 12px; font-size: 1rem; transition: 0.2s;
}
.add-row input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.15); }
.add-row input.invalid { border-color: var(--red); }
.add-row button {
    width: 54px; border: none; border-radius: 12px; background: var(--green); color: var(--black);
    font-size: 1.2rem; transition: 0.2s;
}
.add-row button:hover { transform: rotate(90deg) scale(1.08); box-shadow: 0 0 18px rgba(0, 255, 136, 0.4); }

.activities { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }
.activity {
    display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
    padding: 0.9rem 1rem; background: var(--black); border: 1px solid var(--border); border-radius: 12px;
    transition: border-color 0.25s, transform 0.25s;
    animation: itemIn 0.4s both;
}
.activity:hover { border-color: rgba(0, 255, 136, 0.4); transform: translateX(-4px); }
.activity.removing { animation: itemOut 0.3s forwards; }
@keyframes itemIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes itemOut { to { opacity: 0; transform: translateX(-40px); height: 0; padding: 0; margin: 0; } }

.act-main { display: flex; align-items: center; gap: 0.7rem; flex-grow: 1; min-width: 0; }
.act-main > i { color: var(--green); }
.activity.done .act-main > i { color: #4a5678; }
.act-text { font-weight: 500; word-break: break-word; transition: color 0.3s; }
.activity.done .act-text { text-decoration: line-through; color: #5b6890; }
.badge {
    font-size: 0.7rem; font-weight: 700; color: var(--green); white-space: nowrap;
    background: rgba(0, 255, 136, 0.1); border: 1px solid rgba(0, 255, 136, 0.3);
    padding: 0.1rem 0.55rem; border-radius: 999px; animation: pop 0.35s;
}
.edit-input {
    width: 100%; padding: 0.4rem 0.7rem; background: var(--card); color: var(--white);
    border: 1px solid var(--green); border-radius: 8px; font-size: 0.95rem;
}
.edit-input:focus { outline: none; }

.act-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.act-btn {
    min-width: 36px; height: 36px; padding: 0 0.7rem; border-radius: 9px; font-size: 0.8rem; font-weight: 700;
    border: 1px solid var(--border); background: var(--card); transition: 0.2s;
}
.act-btn:hover { transform: translateY(-2px); }
.act-btn.edit { color: var(--blue); }
.act-btn.edit:hover { background: rgba(59, 130, 246, 0.15); border-color: var(--blue); }
.act-btn.ok { color: var(--green); border-color: rgba(0, 255, 136, 0.4); background: rgba(0, 255, 136, 0.1); }
.act-btn.ok:hover { background: rgba(0, 255, 136, 0.25); }
.act-btn.del { color: var(--red); border-color: rgba(255, 77, 94, 0.4); background: rgba(255, 77, 94, 0.1); }
.act-btn.del:hover { background: rgba(255, 77, 94, 0.25); }
.act-btn.done-btn { color: var(--green); border-color: rgba(0, 255, 136, 0.4); background: rgba(0, 255, 136, 0.08); }
.activity.done .act-btn.done-btn { color: var(--muted); border-color: var(--border); background: var(--card); }

.empty { text-align: center; color: var(--muted); padding: 1.2rem; border: 1px dashed var(--border); border-radius: 12px; }
.empty i { margin-left: 0.4rem; }

/* المعلمون والطلاب */
.people-section { display: flex; flex-direction: column; gap: 1rem; }
.people-section .section-title { margin-bottom: 0.3rem; }

.person-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
    transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}
.person-card:hover { transform: translateY(-3px); }
.person-card.blue-hover:hover, .person-card.blue-hover.open { border-color: rgba(59, 130, 246, 0.7); box-shadow: 0 6px 24px rgba(59, 130, 246, 0.15); }
.person-card.red-hover:hover, .person-card.red-hover.open { border-color: rgba(255, 77, 94, 0.6); box-shadow: 0 6px 24px rgba(255, 77, 94, 0.12); }

.person-top { padding: 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.person-info { display: flex; align-items: center; gap: 1rem; }
.person-info h3 { font-size: 1.15rem; font-weight: 700; }
.avatar {
    width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 800; border: 2px solid;
    transition: transform 0.4s;
}
.person-card:hover .avatar { transform: rotate(360deg); }
.avatar.blue { background: rgba(59, 130, 246, 0.15); color: #8fb8ff; border-color: var(--blue); }
.avatar.red { background: rgba(255, 77, 94, 0.12); color: #ff98a2; border-color: var(--red); }

.more-btn {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem;
    background: var(--black); color: var(--green); border: 1px solid var(--border); border-radius: 10px;
    font-size: 0.85rem; transition: 0.2s;
}
.more-btn:hover { border-color: var(--green); }
.more-btn i { transition: transform 0.35s; }
.more-btn[aria-expanded="true"] i { transform: rotate(180deg); }

/* فتح وغلق سلس */
.person-details { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.4s ease; }
.person-card.open .person-details { grid-template-rows: 1fr; }
.details-inner {
    overflow: hidden; min-height: 0; display: flex; align-items: center; gap: 0.8rem;
    padding: 0 1.2rem; background: rgba(5, 8, 15, 0.7); border-top: 1px solid transparent;
    color: #c9d2ea; font-size: 1.05rem; transition: padding 0.4s, border-color 0.4s;
}
.person-card.open .details-inner { padding: 1.1rem 1.2rem; border-top-color: var(--border); }

/* الفوتر */
.site-footer { background: var(--navy); border-top: 1px solid var(--border); padding: 1.4rem 1rem; margin-top: 2rem; color: var(--muted); font-size: 0.85rem; }
.footer-inner { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.7rem; align-items: center; justify-content: space-between; }
@media (min-width: 640px) { .footer-inner { flex-direction: row; } }
.credit {
    color: var(--green); font-family: 'Courier New', monospace; background: var(--black);
    padding: 0.25rem 0.8rem; border-radius: 8px; border: 1px solid rgba(0, 255, 136, 0.25);
}

/* زر الصعود للأعلى */
.to-top {
    position: fixed; bottom: 1.2rem; left: 1.2rem; z-index: 55;
    width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--green);
    background: var(--navy); color: var(--green); font-size: 1.1rem;
    opacity: 0; transform: translateY(20px); pointer-events: none; transition: 0.3s;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--green); color: var(--black); }

/* إشعارات */
.toast-box { position: fixed; bottom: 1.2rem; right: 50%; transform: translateX(50%); z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.toast {
    padding: 0.6rem 1.2rem; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
    background: var(--navy); border: 1px solid var(--green); color: var(--green);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.35s both;
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.out { animation: toastOut 0.3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20px); } }

/* ظهور الأقسام عند التمرير */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 0.7s, transform 0.7s; }
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    html { scroll-behavior: auto; }
}
