@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --dark-bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --gradient-main: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-glow: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Tajawal', 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
    direction: rtl;
    min-height: 100vh;
    position: relative;
}


/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

/* --- Components --- */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    box-shadow: var(--glass-shadow);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.75rem;
    border-radius: 1rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--gradient-main);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn.glass:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* --- Layout --- */
.navbar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0 5rem;
    /* Increased padding to move links away from edges */
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.logo {
    font-size: 1.75rem;
    font-weight: 900;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    align-items: center;
}

/* Improved Navigation Dropdowns (Desktop) */
.nav-links li {
    position: relative;
    height: 80px;
    /* Force desktop height to match navbar */
    display: flex;
    align-items: center;
}

.nav-links a,
.dropdown-trigger {
    font-weight: 600;
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    white-space: nowrap;
}

.nav-links a:hover,
.dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
}

.dropdown {
    position: absolute;
    top: calc(100% - 10px);
    /* Anchor below the navbar line */
    right: 0;
    background: #1e293b;
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    min-width: 240px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    z-index: 1100;
}

.nav-links li:hover .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(10px);
}

/* Align last dropdown to the left edge to prevent off-screen */
.nav-links li:last-child .dropdown {
    right: auto;
    left: 0;
}

.dropdown a {
    padding: 0.8rem 1rem !important;
    border-radius: 0.6rem;
    font-size: 0.95rem;
    color: var(--text-muted) !important;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
}

.dropdown a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.dropdown a:hover {
    background: rgba(99, 102, 241, 0.1) !important;
    color: white !important;
    transform: translateX(-5px);
}

/* Red tag for unread messages */
.count-badge {
    background: #ef4444;
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 800;
    position: absolute;
    top: -5px;
    left: -5px;
    border: 2px solid var(--dark-bg);
}

/* --- Hero Section --- */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding-top: 80px;
}

.hero-content {
    max-width: 800px;
    z-index: 1;
}

.hero h1 {
    font-size: 4.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    background: linear-gradient(to bottom right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-weight: 300;
}

/* --- Mobile Menu Toggle --- */
.menu-toggle {
    display: none;
    font-size: 1.5rem;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .container {
        padding: 0 1rem;
    }

    .hero h1 {
        font-size: 3.5rem;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 1.5rem;
        height: 70px;
    }

    .menu-toggle {
        display: block;
        z-index: 1001;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 300px;
        height: 100vh;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(25px);
        flex-direction: column;
        padding: 5rem 1rem 2rem;
        gap: 0.5rem;
        /* Compact stack */
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
        transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1000;
        overflow-y: auto;
        align-items: stretch;
        /* Full width items */
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li {
        width: 100%;
        height: auto;
        display: block;
    }

    .nav-links a,
    .dropdown-trigger {
        width: 100%;
        padding: 1rem 1.25rem;
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.02);
        justify-content: b;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .dropdown {
        position: static;
        width: 100%;
        max-height: 0;
        opacity: 0;
        visibility: hidden;
        overflow: hidden;
        transform: none;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.2);
        padding: 0;
        margin: 0;
        border: none;
        transition: max-height 1.5s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 1.5s ease,
            margin 0.5s ease;
        display: flex;
    }

    .dropdown.mobile-open {
        max-height: 1000px;
        /* Large enough for content */
        opacity: 1;
        visibility: visible;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
        padding: 0.5rem;
        border-right: 2px solid var(--primary);
    }

    .dropdown a {
        background: transparent !important;
        border: none !important;
        padding: 0.8rem 2rem !important;
    }

    .glass {
        padding: 1.5rem !important;
        border-radius: 1rem;
    }

    /* Grid Resets for Mobile */
    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns: 1fr 2fr"],
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Adjust specific elements */
    .btn {
        width: 100%;
        justify-content: center;
    }

    form[style*="flex"] {
        flex-direction: column;
    }

    select,
    input {
        width: 100% !important;
    }
}

/* --- Utilities --- */
.animate-fade {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.text-gradient {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bg-gradient {
    background: var(--gradient-main);
}

/* Accordion */
.accordion-header:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.accordion-body {
    display: none;
    border-top: 1px solid var(--glass-border);
}

.accordion.active .accordion-body {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Table */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
}

table {
    width: 100%;
    min-width: 800px;
    /* Force minimum width to trigger scroll on small screens */
    border-collapse: collapse;
}

th,
td {
    text-align: right;
    padding: 1rem;
    white-space: nowrap;
}