/* ===============================
   RESET خفيف
================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
}

/* ===============================
   ألوان الثيم (لايت / دارك)
================================== */

:root {
    --bg: #050816;
    --bg-soft: #090e1a;
    --bg-elevated: #0f172a;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #38bdf8;
    --accent-soft: rgba(56,189,248,0.15);
    --accent-strong: #0ea5e9;
    --border: rgba(148,163,184,0.35);
    --danger: #fb7185;
    --success: #22c55e;
    --shadow-3d: 0 22px 45px rgba(15,23,42,0.9);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
}

[data-theme="light"] {
    --bg: #f3f4f6;
    --bg-soft: #e5e7eb;
    --bg-elevated: #ffffff;
    --text: #020617;
    --muted: #6b7280;
    --accent: #0ea5e9;
    --accent-soft: rgba(14,165,233,0.12);
    --accent-strong: #0284c7;
    --border: rgba(148,163,184,0.35);
    --danger: #e11d48;
    --success: #16a34a;
    --shadow-3d: 0 18px 35px rgba(15,23,42,0.12);
}

/* ===============================
   العناصر العامة
================================== */

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
}

input,
select {
    font: inherit;
}

/* خلفية فيها شادو و لمعة خفيفة */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 0% 0%, rgba(56,189,248,0.16), transparent 55%),
        radial-gradient(circle at 100% 100%, rgba(129,140,248,0.18), transparent 55%);
    opacity: 0.8;
    z-index: -1;
}

/* ===============================
   صفحة تسجيل الدخول
================================== */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(145deg, rgba(15,23,42,0.98), rgba(15,23,42,0.92));
    border-radius: 28px;
    padding: 2.2rem 2rem;
    border: 1px solid rgba(148,163,184,0.4);
    box-shadow: var(--shadow-3d);
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    animation: cardFloat 1.3s ease-out;
}

/* لمعة 3D */
.auth-card::before {
    content: "";
    position: absolute;
    inset: -40%;
    background: conic-gradient(
        from 210deg,
        rgba(56,189,248,0.0),
        rgba(56,189,248,0.3),
        rgba(129,140,248,0.3),
        rgba(56,189,248,0.0)
    );
    opacity: 0.2;
    mix-blend-mode: screen;
    animation: rotateGlow 9s linear infinite;
}

.auth-card h1 {
    position: relative;
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
}

.auth-card p {
    position: relative;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.auth-card form {
    position: relative;
    display: grid;
    gap: 1rem;
}

.auth-card label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
    display: inline-block;
}

.auth-card input[type="text"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,0.5);
    background: rgba(15,23,42,0.85);
    color: var(--text);
    outline: none;
    transition: border 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.auth-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56,189,248,0.35);
    transform: translateY(-1px);
}

.auth-card button[type="submit"] {
    margin-top: 0.3rem;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    border: none;
    background: radial-gradient(circle at 0 0, var(--accent-strong), var(--accent));
    color: white;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 2px rgba(15,23,42,0.7);
    box-shadow: 0 16px 30px rgba(56,189,248,0.45);
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.auth-card button[type="submit"]:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 20px 40px rgba(56,189,248,0.55);
    filter: brightness(1.05);
}

.auth-card button[type="submit"]:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 12px 25px rgba(56,189,248,0.35);
}

.alert {
    position: relative;
    margin-bottom: 0.9rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(248,113,113,0.08);
    border: 1px solid rgba(248,113,113,0.45);
    color: #fecaca;
    font-size: 0.8rem;
}

/* ===============================
   تخطيط عام بعد تسجيل الدخول
================================== */

.top-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(to bottom, rgba(15,23,42,0.96), rgba(15,23,42,0.85));
    border-bottom: 1px solid rgba(148,163,184,0.25);
    backdrop-filter: blur(14px);
}

[data-theme="light"] .top-nav {
    background: linear-gradient(to bottom, rgba(249,250,251,0.96), rgba(249,250,251,0.92));
}

.top-nav-left strong {
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--accent);
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.85rem;
}

.top-nav-right a {
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid transparent;
    transition: color 0.16s ease, background 0.16s ease, border 0.16s ease, transform 0.12s ease;
}

.top-nav-right a:hover {
    color: var(--accent-strong);
    background: rgba(15,23,42,0.6);
    border-color: rgba(148,163,184,0.4);
    transform: translateY(-1px);
}

[data-theme="light"] .top-nav-right a:hover {
    background: rgba(209,213,219,0.4);
}

.icon-btn {
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,0.5);
    background: rgba(15,23,42,0.7);
    color: var(--muted);
    padding: 0.3rem 0.65rem;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.16s ease;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
    transform: translateY(-1px);
}

/* المحتوى الرئيسي */

.content {
    max-width: 1200px;
    margin: 1.4rem auto 2.5rem auto;
    padding: 0 1.25rem;
}

.content h1 {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.content > p {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1.4rem;
}

/* ===============================
   الكروت و 3D
================================== */

.cards-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.card {
    position: relative;
    background: linear-gradient(150deg, var(--bg-elevated), var(--bg-soft));
    border-radius: var(--radius-xl);
    padding: 1.2rem 1.15rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-3d);
    overflow: hidden;
    transform-style: preserve-3d;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card::before {
    content: "";
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle at 0 0, var(--accent-soft), transparent 55%);
    opacity: 0.6;
    pointer-events: none;
}

.card span {
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.12em;
}

.card strong {
    display: block;
    font-size: 1.3rem;
    margin-top: 0.5rem;
}

.card h2 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.card p {
    font-size: 0.86rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.card:hover {
    transform: translateY(-6px) rotate3d(1,-1,0,7deg);
    box-shadow: 0 26px 55px rgba(15,23,42,0.9);
    border-color: var(--accent-soft);
}

/* ===============================
   فورمات عامة
================================== */

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-size: 0.82rem;
    color: var(--muted);
}

.form-group input,
.form-group select {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(15,23,42,0.9);
    color: var(--text);
    outline: none;
    transition: border 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}

[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select {
    background: #ffffff;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56,189,248,0.35);
    transform: translateY(-1px);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.form-actions button,
.form-actions .btn-primary {
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    color: #fff;
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: 0 14px 28px rgba(56,189,248,0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.form-actions button:hover,
.form-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(56,189,248,0.5);
}

.btn-secondary {
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15,23,42,0.7);
    color: var(--muted);
    font-size: 0.84rem;
    transition: all 0.16s ease;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

/* ===============================
   جدول البيانات
================================== */

.table-wrapper {
    margin-top: 1.4rem;
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border);
    background: rgba(15,23,42,0.95);
    box-shadow: var(--shadow-3d);
}

[data-theme="light"] .table-wrapper {
    background: #ffffff;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table thead {
    background: linear-gradient(to left, rgba(15,23,42,0.98), rgba(30,64,175,0.95));
    color: #e5e7eb;
}

[data-theme="light"] .data-table thead {
    background: linear-gradient(to left, #1d4ed8, #0ea5e9);
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid rgba(148,163,184,0.25);
    text-align: right;
    white-space: nowrap;
}

.data-table tbody tr:nth-child(odd) {
    background: rgba(15,23,42,0.9);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(15,23,42,0.8);
}

[data-theme="light"] .data-table tbody tr:nth-child(odd) {
    background: #f9fafb;
}

[data-theme="light"] .data-table tbody tr:nth-child(even) {
    background: #f3f4f6;
}

.data-table tbody tr:hover {
    background: rgba(56,189,248,0.14);
}

/* حضور/غياب */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-active {
    background: rgba(34,197,94,0.12);
    color: var(--success);
    border: 1px solid rgba(34,197,94,0.5);
}

.status-expired {
    background: rgba(248,113,113,0.12);
    color: var(--danger);
    border: 1px solid rgba(248,113,113,0.5);
}

/* حضور checkbox */

.attendance-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-strong);
}

/* ===============================
   الحضور – فورم أعلى الجدول
================================== */

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 1rem;
}

.form-inline label {
    font-size: 0.82rem;
    color: var(--muted);
}

.form-inline input[type="date"] {
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15,23,42,0.95);
    color: var(--text);
    outline: none;
}

[data-theme="light"] .form-inline input[type="date"] {
    background: #ffffff;
}

.form-inline button {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: none;
    background: rgba(56,189,248,0.16);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.form-inline button:hover {
    background: rgba(56,189,248,0.25);
}

/* ===============================
   موبايل NAV يشبه تطبيق
================================== */

.mobile-nav {
    position: fixed;
    bottom: 0.85rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(480px, 92%);
    height: 58px;
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,0.5);
    background: radial-gradient(circle at 0 0, rgba(56,189,248,0.18), rgba(15,23,42,0.98));
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 22px 40px rgba(15,23,42,0.9);
    z-index: 50;
}

.mobile-nav a {
    flex: 1;
    text-align: center;
    font-size: 0.7rem;
    color: #cbd5f5;
    opacity: 0.7;
    transition: all 0.15s ease;
}

.mobile-nav a.active,
.mobile-nav a:hover {
    opacity: 1;
    color: #ffffff;
    transform: translateY(-2px);
}

/* اخفاء على الشاشات الكبيرة */
@media (min-width: 768px) {
    .mobile-nav {
        display: none;
    }
}

/* ===============================
   أنيميشن
================================== */

@keyframes cardFloat {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ===============================
   إظهار/إخفاء حسب نوع الجهاز
================================== */

.desktop-only {
    display: none;
}

.mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .desktop-only {
        display: block;
    }
    .mobile-only {
        display: none;
    }
}

/* ===============================
   تصميم الجوال لقائمة الطلاب والحضور
================================== */

@media (max-width: 768px) {

    /* إخفاء الجداول في الجوال */
    .table-wrapper,
    .data-table {
        display: none !important;
    }

    /* كرت عام للجوال (قائمة الطلاب) */
    .mobile-card {
        background: var(--bg-elevated);
        border-radius: 18px;
        padding: 0.9rem 1rem;
        margin-top: 0.75rem;
        border: 1px solid var(--border);
        box-shadow: 0 14px 30px rgba(15,23,42,0.85);
    }

    .mobile-card h3 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .mobile-card p {
        font-size: 0.85rem;
        color: var(--muted);
        margin: 2px 0;
    }

    .mobile-status {
        display: inline-block;
        padding: 0.15rem 0.55rem;
        border-radius: 999px;
        font-size: 0.75rem;
        margin-bottom: 0.3rem;
    }

    .mobile-status.active {
        background: rgba(34,197,94,0.15);
        color: var(--success);
        border: 1px solid rgba(34,197,94,0.6);
    }

    .mobile-status.expired {
        background: rgba(248,113,113,0.15);
        color: var(--danger);
        border: 1px solid rgba(248,113,113,0.6);
    }

    /* كروت الحضور للجوال */
    .attendance-mobile-card {
        background: var(--bg-elevated);
        border-radius: 16px;
        padding: 0.85rem 0.95rem;
        margin-top: 0.65rem;
        border: 1px solid var(--border);
        box-shadow: 0 12px 26px rgba(15,23,42,0.8);
    }


    .attendance-mobile-card label {
        font-size: 0.95rem;
        font-weight: 600;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .attendance-mobile-card small {
        font-size: 0.8rem;
        color: var(--muted);
        display: block;
        margin-top: 0.1rem;
    }

    .attendance-checkbox {
        width: 20px;
        height: 20px;
        accent-color: var(--accent-strong);
    }
}
