/* =========================================================
   KPS Portal — Glass Design System
   Palette pulled from the KPS star-and-book emblem.
   Two glass registers:
     - "ink glass"   : dark, translucent, on the navy mesh (header/sidebar/hero/footer)
     - "frost glass" : light, translucent, sits on top of the mesh (content cards)
   Signature motif: the emblem's eight-point star, reused as a
   quiet recurring mark (nav bullets, section dividers, card corners).
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Tajawal:wght@700;800;900&display=swap');

:root {
    --ink-950: #060b22;
    --ink-900: #0c163f;
    --navy-800: #142a6e;
    --blue-700: #1e40af;
    --blue-600: #2b52c9;
    --blue-400: #5f8bf2;
    --blue-200: #bcd2ff;
    --star-gold: #eef2ff;

    --frost-bg: rgba(255, 255, 255, 0.72);
    --frost-bg-strong: rgba(255, 255, 255, 0.86);
    --frost-border: rgba(255, 255, 255, 0.55);

    --ink-glass-bg: rgba(255, 255, 255, 0.08);
    --ink-glass-bg-strong: rgba(255, 255, 255, 0.14);
    --ink-glass-border: rgba(255, 255, 255, 0.22);

    --text-on-dark: #eef2ff;
    --text-on-dark-dim: #a9b8e8;
    --text-on-light: #1b2450;
    --text-on-light-dim: #4c5878;

    --shadow-soft: 0 20px 45px rgba(6, 11, 34, 0.35);
    --shadow-lift: 0 26px 55px rgba(6, 11, 34, 0.45);

    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    color: var(--text-on-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;

    background-color: var(--ink-950);
    background-image:
        radial-gradient(circle at 18% 15%, rgba(95, 139, 242, 0.35), transparent 42%),
        radial-gradient(circle at 88% 8%, rgba(43, 82, 201, 0.40), transparent 46%),
        radial-gradient(circle at 60% 95%, rgba(20, 42, 110, 0.55), transparent 55%),
        linear-gradient(160deg, #060b22 0%, #0c163f 45%, #142a6e 100%);
    background-attachment: fixed;
    background-size: cover;
    position: relative;
}

/* faint star-field texture behind everything, echoing the emblem's three stars */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
    background-image:
        radial-gradient(circle, rgba(255,255,255,0.55) 1px, transparent 1.4px),
        radial-gradient(circle, rgba(255,255,255,0.35) 1px, transparent 1.4px);
    background-size: 140px 140px, 90px 90px;
    background-position: 20px 30px, 60px 110px;
}

h1, h2, h3 { font-family: 'Tajawal', 'IBM Plex Sans Arabic', sans-serif; font-weight: 800; }

/* ---------- shared glass utility ---------- */
.glass {
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
}

/* ============ HEADER ============ */
header.top-header {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    padding: 14px 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ink-glass-bg-strong);
    border-bottom: 1px solid var(--ink-glass-border);
    box-shadow: var(--shadow-soft);
}
header.top-header .brand {
    display: flex;
    align-items: center;
    gap: 16px;
}
.school-logo-frame {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--ink-glass-bg);
    border: 1px solid var(--ink-glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}
.school-logo-img { height: 100%; width: auto; display: block; }
.school-info h1 { font-size: 1.35rem; color: var(--text-on-dark); letter-spacing: 0.2px; }
.school-info p { font-size: 0.82rem; color: var(--text-on-dark-dim); margin-top: 2px; }

.header-star {
    color: var(--blue-400);
    font-size: 1.1rem;
    letter-spacing: 6px;
    opacity: 0.85;
    display: none;
}
@media (min-width: 700px) { .header-star { display: inline; } }

/* ============ LAYOUT ============ */
.page-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    width: 100%;
    max-width: 1400px;
    gap: 22px;
    padding: 22px 0 40px 5%;
    align-items: flex-start;
}

/* ============ SIDEBAR ============ */
.sidebar-menu {
    width: 235px;
    flex: 0 0 235px;
    flex-shrink: 0;
    position: sticky;
    top: 22px;
    z-index: 10;

    background: var(--ink-glass-bg-strong);
    border: 1px solid var(--ink-glass-border);
    border-radius: var(--radius-lg);

    padding: 14px 10px;
    direction: rtl;

    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.sidebar-menu .nav {
    width: 100%;
    gap: 7px;
}

.sidebar-menu .nav-link {
    width: 100%;
    min-height: 52px;
    padding: 12px 13px !important;

    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;

    color: var(--text-on-dark-dim) !important;
    background: transparent;
    border: 1px solid transparent !important;
    border-radius: var(--radius-sm) !important;

    font-family: inherit;
    font-size: 0.94rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: right !important;
    text-decoration: none;

    white-space: normal;
    transition:
        background 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        transform 0.2s ease,
        box-shadow 0.25s ease;
}

.sidebar-menu .nav-link i {
    flex: 0 0 24px;
    width: 24px;
    min-width: 24px;
    margin: 0 !important;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 1.15rem !important;
    line-height: 1;
}

.sidebar-menu .nav-link span {
    flex: 1;
    min-width: 0;
}

.sidebar-menu .nav-link:hover {
    background: var(--ink-glass-bg);
    color: var(--text-on-dark) !important;
    border-color: var(--ink-glass-border) !important;
    transform: translateX(-2px);
}

.sidebar-menu .nav-link.active {
    background: linear-gradient(
        135deg,
        rgba(95,139,242,0.42),
        rgba(43,82,201,0.38)
    ) !important;
    color: #ffffff !important;
    border-color: rgba(255,255,255,0.30) !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.sidebar-menu .nav-link.active::after {
    content: "✦";
    margin-right: auto;
    margin-left: 0;
    color: var(--blue-200);
    font-size: 0.75rem;
}

.sidebar-menu .nav-link:not(.active)::after {
    content: "";
    margin-right: auto;
}

.sidebar-menu .nav-link:focus-visible {
    outline: 2px solid var(--blue-400);
    outline-offset: 2px;
}

/* تحسين خاص للأزرار التي تستخدم Bootstrap tabs */
.sidebar-menu button.nav-link {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.sidebar-menu button.nav-link:not(.active) {
    opacity: 1;
}

/* ============ MAIN ============ */
main.main-content, main {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.hero-section {
    position: relative;
    overflow: hidden;
    padding: 46px 44px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(43,82,201,0.55), rgba(20,42,110,0.75));
    border: 1px solid var(--ink-glass-border);
    color: var(--text-on-dark);
    box-shadow: var(--shadow-lift);
}
.hero-section::after {
    content: "✦";
    position: absolute;
    left: -10px;
    top: -30px;
    font-size: 9rem;
    color: rgba(255,255,255,0.06);
    transform: rotate(15deg);
}
.hero-section h2 { font-size: 2rem; color: var(--text-on-dark); margin-bottom: 10px; }
.hero-section p { color: var(--blue-200); font-size: 1.05rem; max-width: 60ch; }

.page-title { text-align: center; margin-bottom: 6px; }
.page-title h2 { font-size: 2rem; color: var(--text-on-dark); margin-bottom: 8px; }
.page-title p { color: var(--text-on-dark-dim); font-size: 1.05rem; }

/* ============ CARDS ============ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
}

.card, .info-card {
    position: relative;
    overflow: hidden;
    background: var(--frost-bg);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--frost-border);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.card:hover, .info-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lift);
    background: var(--frost-bg-strong);
}
.card::before, .info-card::before {
    content: "✦";
    position: absolute;
    top: -14px;
    left: -10px;
    font-size: 3.4rem;
    color: rgba(30,64,175,0.08);
}
.card h2, .info-card h3 {
    font-size: 1.15rem;
    color: var(--blue-700);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.card p, .info-card p {
    line-height: 1.8;
    color: var(--text-on-light-dim);
    font-size: 0.97rem;
    text-align: justify;
}
.card, .info-card { border-top: 4px solid var(--blue-700); border-radius: var(--radius-md); }

.highlight-quote {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--blue-700), var(--navy-800));
    color: #fff;
    padding: 28px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow: var(--shadow-soft);
}

/* ============ LOGIN SCREEN STYLES ============ */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 40px 20px;
    position: relative;
    z-index: 2;
}

.login-card {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    text-align: center;
    padding: 36px 30px;
    box-shadow: var(--shadow-lift);
}

.login-card h1 {
    font-size: 1.6rem;
    color: var(--blue-700);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-on-light);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--blue-200);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(43, 82, 201, 0.2);
}

.login-card button[type="submit"] {
    width: 100%;
    padding: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, var(--blue-600), var(--navy-800));
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(20, 42, 110, 0.25);
}

.login-card button[type="submit"]:hover {
    background: linear-gradient(135deg, var(--blue-700), var(--ink-900));
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(20, 42, 110, 0.35);
}

.login-card a.link {
    display: inline-block;
    color: var(--blue-700);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-card a.link:hover {
    color: var(--blue-600);
    text-decoration: underline;
}

.error {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.3);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 16px;
    text-align: center;
}

/* ============ FOOTER ============ */
footer.site-footer {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 22px 5%;
    background: var(--ink-glass-bg-strong);
    border-top: 1px solid var(--ink-glass-border);
    color: var(--text-on-dark-dim);
}
.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.88rem;
    max-width: 1400px;
    margin: 0 auto;
}
.footer-row span { display: flex; align-items: center; gap: 6px; }
.visitor-badge {
    text-align: center;
    margin-top: 14px;
    font-size: 1rem;
    color: var(--text-on-dark);
    max-width: 1400px;
    margin-inline: auto;
}
.visitor-badge b {
    background: var(--ink-glass-bg);
    border: 1px solid var(--ink-glass-border);
    padding: 4px 14px;
    border-radius: 999px;
    color: var(--blue-200);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) and (min-width: 901px) {
    .sidebar-menu {
        width: 210px;
        flex-basis: 210px;
    }

    .sidebar-menu .nav-link {
        font-size: 0.88rem;
        padding-inline: 10px !important;
    }
}

@media (max-width: 900px) {
    .page-wrapper { 
        flex-direction: column; 
        padding-right: 5%;
    }
    .sidebar-menu {
        width: 100%;
        flex: 0 0 auto;
        position: static;
        padding: 8px;
        border-radius: var(--radius-md);
        overflow-x: auto;
    }

    .sidebar-menu .nav {
        flex-direction: row !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
    }

    .sidebar-menu .nav-link {
        width: auto;
        min-width: max-content;
        min-height: 48px;
        white-space: nowrap;
        padding: 10px 13px !important;
    }
    header.top-header { flex-direction: column; text-align: center; gap: 10px; }
    .hero-section { padding: 30px 24px; }
    .footer-row { flex-direction: column; text-align: center; }
}

/* ============ PRINT ============ */
@media print {
    @page {
        margin: 1cm;
    }

    header, .sidebar, .no-print, nav, aside, footer { display: none !important; }
    body, .report-container { margin: 0; padding: 0; width: 100%; max-width: 100%; background: #fff; }
    main { margin: 0 !important; padding: 0 !important; }
    .print-title { display: block; font-size: 24px; font-weight: bold; }
    .print-footer-info { display: block; }
    .report-table { width: 100%; border-collapse: collapse; }
    .report-table th, .report-table td { border: 1px solid #dee2e6; padding: 8px; }
    .class-header { border: 1px solid #dee2e6; box-shadow: none; margin-bottom: 20px; }
}