/* ============================================================
   style.css — Custom Stylesheet
   نظام إدارة النتائج لجامعة هيك تشاد
   Complements Tailwind CSS + Font Awesome
   ============================================================ */

/* ── Google Fonts Import ── */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&family=Poppins:wght@300;400;500;600;700&display=swap');

/* ─────────────────────────────────────────────
   1. CSS Custom Properties (Design Tokens)
   ───────────────────────────────────────────── */
:root {
    --primary: #3b82f6;
    /* blue-500  */
    --primary-dark: #1e40af;
    /* blue-800  */
    --primary-light: #eff6ff;
    /* blue-50   */
    --success: #10b981;
    /* emerald-500 */
    --danger: #ef4444;
    /* red-500   */
    --warning: #f59e0b;
    /* amber-500 */
    --info: #06b6d4;
    /* cyan-500  */

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-nav: #ffffff;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --border: #e2e8f0;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow: 0 4px 12px rgba(0, 0, 0, .08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .12);

    --transition: 0.2s ease;
    --font-ar: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    --font-en: 'Poppins', 'Segoe UI', sans-serif;
}

/* ─────────────────────────────────────────────
   2. Base / Reset
   ───────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ar);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 0.9375rem;
}

/* RTL global (set in <html dir="rtl">) */
[dir="rtl"] body {
    font-family: var(--font-ar);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

/* ─────────────────────────────────────────────
   3. Navigation Bar
   ───────────────────────────────────────────── */
nav.bg-white {
    background: var(--bg-nav) !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, .12) !important;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--primary-light);
}

nav h1 {
    font-family: var(--font-ar);
    font-weight: 800;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Notification bell badge */
#notification-count {
    font-size: 0.65rem;
    min-width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* ─────────────────────────────────────────────
   4. Sidebar
   ───────────────────────────────────────────── */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius);
    color: var(--text-main);
    font-weight: 500;
    transition: background var(--transition), color var(--transition),
        transform var(--transition), box-shadow var(--transition);
    font-size: 0.9rem;
    box-sizing: border-box;
    /* RTL: right-align content, icon appears on the right */
    direction: rtl;
    text-align: right;
    justify-content: flex-start;
}

/* Make the <li> itself full width so the <a> can stretch */
.bg-white.rounded-lg.shadow ul li,
.bg-white.rounded-lg.shadow ul li>a.sidebar-link {
    width: 100%;
    display: block;
}

.sidebar-link i {
    width: 1.2rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--primary);
    transition: color var(--transition);
}

.sidebar-link:hover {
    background: #3b82f6;
    color: #1e40af !important;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 !important;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1.85rem;
    padding-right: 1.85rem;
}

[dir="rtl"] .sidebar-link:hover {
    margin-left: -1rem;
    margin-right: -1rem;
}

.sidebar-link:hover i {
    color: #1e40af !important;
}

.sidebar-link.active,
.sidebar-link.bg-blue-600 {
    background: #2563eb !important;
    /* Tailwind blue-600 — same as navbar */
    color: #fff !important;
    border-radius: 0 !important;
    /* full-width bar, no rounded corners */
    margin-left: -1rem;
    /* bleed to the edge of the card padding */
    margin-right: -1rem;
    padding-left: 1.85rem;
    padding-right: 1.85rem;
    box-shadow: none;
    font-weight: bold
}

[dir="rtl"] .sidebar-link.active,
[dir="rtl"] .sidebar-link.bg-blue-600 {
    margin-left: -1rem;
    margin-right: -1rem;
}


.sidebar-link.active i,
.sidebar-link.bg-blue-600 i {
    color: #fff !important;
}

/* ─────────────────────────────────────────────
   5. Cards
   ───────────────────────────────────────────── */
.card,
.bg-white.rounded-lg.shadow {
    background: var(--bg-card);
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}

.bg-white.rounded-lg.shadow:hover {
    box-shadow: var(--shadow) !important;
    transform: translateY(-1px);
}

/* Stat icon circles */
.p-3.rounded-full {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .15);
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   6. Tables
   ───────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

thead th {
    padding: 0.85rem 1rem;
    text-align: right;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

[dir="ltr"] thead th {
    text-align: left;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr {
    transition: background var(--transition), box-shadow var(--transition);
}

tbody tr:hover {
    background: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary);
    /* left accent bar on hover */
}

[dir="rtl"] tbody tr:hover {
    box-shadow: inset -3px 0 0 var(--primary);
}

tbody td {
    padding: 0.75rem 1rem;
    color: var(--text-main);
    vertical-align: middle;
}

tbody tr:last-child {
    border-bottom: none;
}

/* overflow wrapper */
.overflow-x-auto {
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────
   7. Forms & Inputs
   ───────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-ar);
    font-size: 0.9rem;
    color: var(--text-main);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
    /* color: var(--text-main); */
}

select option {
    background-color: #ffffff;
    color: var(--text-main);
    /* color: gray; */
}
/* option:hover {
    background-color: var(--primary);
    color: #fff;
} */
label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.3rem;
}

/* ─────────────────────────────────────────────
   8. Buttons
   ───────────────────────────────────────────── */
button,
.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-ar);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none !important;
}

button:active {
    transform: scale(0.97);
}

/* Primary button override for Tailwind classes */
.bg-blue-600 {
    transition: background var(--transition), box-shadow var(--transition) !important;
}

/* ── Colored button hover: lift + glow ── */
.bg-blue-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(37, 99, 235, .45) !important;
    transform: translateY(-1px);
}

.bg-green-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(5, 150, 105, .45) !important;
    transform: translateY(-1px);
}

.bg-red-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(220, 38, 38, .45) !important;
    transform: translateY(-1px);
}

.bg-yellow-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(180, 83, 9, .45) !important;
    transform: translateY(-1px);
}

.bg-purple-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(109, 40, 217, .45) !important;
    transform: translateY(-1px);
}

.bg-indigo-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(79, 70, 229, .45) !important;
    transform: translateY(-1px);
}

.bg-pink-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(219, 39, 119, .45) !important;
    transform: translateY(-1px);
}

.bg-teal-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(13, 148, 136, .45) !important;
    transform: translateY(-1px);
}

.bg-gray-600:hover {
    filter: brightness(1.08);
    box-shadow: 0 5px 14px rgba(75, 85, 99, .45) !important;
    transform: translateY(-1px);
}

/* ─────────────────────────────────────────────
   8b. Icon ↔ Text Spacing (Global)
   ───────────────────────────────────────────── */

/* Any Font Awesome icon that has a sibling text node
   (inside a button, link, or any element) */
a>i[class*="fa-"],
a>i[class*="fas"],
a>i[class*="far"],
a>i[class*="fal"],
button>i[class*="fa-"],
button>i[class*="fas"],
button>i[class*="far"],
span>i[class*="fa-"],
span>i[class*="fas"] {
    display: inline-block;
    /* LTR: space after icon, before text */
    margin-left: 0;
    margin-right: 0.45rem;
    line-height: 1;
    vertical-align: middle;
}

/* RTL: flip — space should be to the LEFT of the icon (i.e. between icon and the Arabic text that follows) */
[dir="rtl"] a>i[class*="fa-"],
[dir="rtl"] a>i[class*="fas"],
[dir="rtl"] a>i[class*="far"],
[dir="rtl"] a>i[class*="fal"],
[dir="rtl"] button>i[class*="fa-"],
[dir="rtl"] button>i[class*="fas"],
[dir="rtl"] button>i[class*="far"],
[dir="rtl"] span>i[class*="fa-"],
[dir="rtl"] span>i[class*="fas"] {
    margin-right: 0;
    margin-left: 0.45rem;
}

/* Tailwind mr-2 override in RTL (Tailwind applies margin-right, wrong side in RTL) */
[dir="rtl"] .mr-2 {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

[dir="rtl"] .mr-3 {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

[dir="rtl"] .mr-4 {
    margin-right: 0 !important;
    margin-left: 1rem !important;
}

/* Also ensure action links/buttons that contain icons are flex so spacing is clean */
a[class*="bg-"],
a[class*="py-"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none !important;
}

/* ─────────────────────────────────────────────
   9. Badges / Status Pills
   ───────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #cffafe;
    color: #164e63;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
}

/* Tailwind text-based status helpers */
.text-green-600 {
    font-weight: 600;
}

.text-red-600 {
    font-weight: 600;
}

/* ─────────────────────────────────────────────
   10. Login Page
   ───────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #06b6d4 100%);
    padding: 1rem;
}

/* The white login card */
body.bg-gray-100.flex>.bg-white {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: none;
}

/* ─────────────────────────────────────────────
   11. Alerts / Flash Messages
   ───────────────────────────────────────────── */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-right: 4px solid transparent;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

[dir="ltr"] .alert {
    border-right: none;
    border-left: 4px solid transparent;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: #10b981;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #ef4444;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}

.alert-info {
    background: #cffafe;
    color: #164e63;
    border-color: #06b6d4;
}

/* Tailwind-generated alert */
.bg-red-100.border.border-red-400 {
    border-radius: var(--radius) !important;
    font-size: 0.875rem;
}

/* ─────────────────────────────────────────────
   12. Notification Dropdown
   ───────────────────────────────────────────── */
#notification-dropdown {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary);
}

#notification-dropdown>div {
    transition: background var(--transition);
}

#notification-dropdown>div:hover {
    background: var(--primary-light);
}

/* User dropdown */
#user-menu-dropdown {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary);
    overflow: hidden;
}

#user-menu-dropdown a {
    color: var(--text-main) !important;
    transition: background var(--transition), color var(--transition);
    font-size: 0.875rem;
}

#user-menu-dropdown a:hover {
    background: var(--primary-light) !important;
    color: var(--primary-dark) !important;
    text-decoration: none !important;
}

/* ─────────────────────────────────────────────
   13. Modals / Popups
   ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(2px);
    animation: fadeIn .2s ease;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 30rem;
    width: 100%;
    animation: slideUp .25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─────────────────────────────────────────────
   14. Page Titles / Section Headers
   ───────────────────────────────────────────── */
.page-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-title i {
    color: var(--primary);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

/* ─────────────────────────────────────────────
   14b. Grade Tab Buttons
   ───────────────────────────────────────────── */

/* Base tab button */
.grade-tab-button {
    position: relative;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius) var(--radius) 0 0;
    font-family: var(--font-ar);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
        border-color var(--transition);
    white-space: nowrap;
}

.grade-tab-button:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Active tab — solid blue background, white bold text */
.grade-tab-button.active,
.grade-tab-button.border-blue-500,
.grade-tab-button.text-blue-600 {
    background: #2563eb !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-bottom: 3px solid #1e40af !important;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -2px 8px rgba(37, 99, 235, .2);
}

/* When only text-blue-600 is set (PHP-rendered active without JS) */
.grade-tab-button.text-blue-600:not(.active) {
    background: #2563eb !important;
    color: #ffffff !important;
    font-weight: 700 !important;
}



/* ─────────────────────────────────────────────
   15. Chart Container
   ───────────────────────────────────────────── */
canvas {
    max-width: 100%;
    height: auto !important;
}

/* ─────────────────────────────────────────────
   16. Transcript / Print View
   ───────────────────────────────────────────── */
@media print {

    nav,
    .lg\:col-span-1,
    .sidebar-link,
    button,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff !important;
        font-family: var(--font-ar);
        font-size: 12pt;
    }

    table {
        border: 1px solid #000;
    }

    thead th,
    tbody td {
        border: 1px solid #999;
        padding: 6px;
    }

    thead {
        background: #e2e8f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .bg-white.rounded-lg.shadow {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
}

/* ─────────────────────────────────────────────
   17. RTL Utilities
   ───────────────────────────────────────────── */
[dir="rtl"] table,
[dir="rtl"] thead th {
    text-align: right;
}

[dir="rtl"] .space-x-2>*+*,
[dir="rtl"] .space-x-3>*+*,
[dir="rtl"] .space-x-4>*+* {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* ─────────────────────────────────────────────
   18. Scrollbar (Webkit)
   ───────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ─────────────────────────────────────────────
   19. Utility Helpers
   ───────────────────────────────────────────── */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ─────────────────────────────────────────────
   20. Responsive Adjustments
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
    nav h1 {
        font-size: 0.9rem;
    }

    body {
        font-size: 0.875rem;
    }

    .sidebar-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.7rem;
    }

    thead th {
        font-size: 0.7rem;
        padding: 0.6rem 0.75rem;
    }

    tbody td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .p-3.rounded-full {
        width: 2.5rem;
        height: 2.5rem;
    }
}