:root {
    --primary: #0c2340;
    --primary-light: #1b365d;
    --primary-glow: rgba(27, 54, 93, 0.15);
    --secondary: #c5a059;
    --secondary-hover: #b08d4b;
    --secondary-glow: rgba(197, 160, 89, 0.2);
    --light: #f4f6f9;
    --white: #ffffff;
    --dark: #1e293b;
    --gray: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --info: #06b6d4;
    --shadow: 0 10px 30px -5px rgba(12, 35, 64, 0.05), 0 5px 15px -3px rgba(12, 35, 64, 0.03);
    --font: 'Outfit', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
    font-family: var(--font);
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header & Navbar */
header {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 2px solid var(--secondary);
}

.top-bar {
    background: #051020;
    color: rgba(255, 255, 255, 0.85);
    padding: 8px 30px;
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--secondary);
}

.top-bar-contact {
    display: flex;
    gap: 20px;
    align-items: center;
}

.top-bar-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.btn-lang {
    background: transparent;
    border: 1px solid var(--secondary);
    color: var(--secondary);
    padding: 3px 12px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-lang:hover {
    background: var(--secondary);
    color: var(--primary);
    box-shadow: 0 0 10px var(--secondary-glow);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand img {
    height: 60px;
    width: auto;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.2));
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.brand-text p {
    font-size: 0.78rem;
    color: var(--secondary);
    font-weight: 600;
    margin-top: 3px;
}

.nav-menu {
    display: flex;
    gap: 8px;
    list-style: none;
    align-items: center;
}

.nav-item a {
    font-size: 0.88rem;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
}

.nav-item a:hover, .nav-item.active a {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active a {
    border-bottom: 2px solid var(--secondary);
    border-radius: 6px 6px 0 0;
}

/* Dropdown Menu Styles */
.has-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #081526;
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-top: 3px solid var(--secondary);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: none;
    min-width: 200px;
    padding: 8px 0;
    margin: 0;
    list-style: none;
    z-index: 100;
}

.dropdown-menu li {
    width: 100%;
}

.dropdown-menu li a {
    display: block;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.85rem !important;
    border-radius: 0;
    border: none !important;
    transition: all 0.2s ease;
    text-align: right; /* Default for Arabic */
}

/* Align text for English left-to-right */
html[dir="ltr"] .dropdown-menu li a {
    text-align: left;
}

.dropdown-menu li a:hover {
    background: rgba(197, 160, 89, 0.15) !important;
    color: var(--secondary) !important;
}

.has-dropdown:hover .dropdown-menu {
    display: block;
}

html[dir="rtl"] .dropdown-menu {
    left: auto;
    right: 0;
}

/* Mobile dropdown adjustments */
@media (max-width: 991px) {
    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(0, 0, 0, 0.2);
        width: 100%;
        display: block; /* Always visible in mobile drawer */
        padding: 0 15px;
        margin-top: 5px;
    }
    .dropdown-menu li a {
        padding: 8px 15px;
        font-size: 0.8rem !important;
    }
}

.btn-portal {
    background: var(--secondary);
    color: var(--primary) !important;
    font-weight: 700 !important;
    border-radius: 30px !important;
    padding: 8px 18px !important;
    box-shadow: 0 4px 10px var(--secondary-glow);
}

.btn-portal:hover {
    background: var(--white) !important;
    color: var(--primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 255, 255, 0.2);
}

.menu-toggle {
    display: none;
    font-size: 1.6rem;
    background: transparent;
    border: none;
    color: var(--white);
    cursor: pointer;
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
    padding: 40px 30px;
}

/* Footer styling */
footer {
    background: var(--primary);
    color: var(--white);
    padding: 50px 30px 25px;
    margin-top: auto;
    border-top: 5px solid var(--secondary);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    max-width: 1300px;
    margin: 0 auto;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.footer-col h3 {
    color: var(--secondary);
    margin-bottom: 25px;
    font-size: 1.15rem;
    border-bottom: 2px solid var(--secondary);
    display: inline-block;
    padding-bottom: 6px;
}

.footer-col p, .footer-col ul {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.8;
}

.footer-col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-col ul li a:hover {
    color: var(--secondary);
    padding-left: 8px;
}

.footer-bottom {
    text-align: center;
    padding-top: 25px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Cards & Containers */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
    transition: transform 0.3s;
}

.card-title {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.4rem;
    border-bottom: 2px solid var(--secondary);
    padding-bottom: 6px;
    display: inline-block;
    font-weight: 700;
}

/* Hero and Slider Section */
.hero-slider {
    background: radial-gradient(circle at 10% 20%, #0c2340 0%, #1b365d 90%);
    color: var(--white);
    padding: 80px 40px;
    border-radius: 16px;
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hero-slider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 80% 80%, rgba(197, 160, 89, 0.1), transparent 50%);
    pointer-events: none;
}

.hero-slider h2 {
    font-size: 2.4rem;
    color: var(--secondary);
    margin-bottom: 20px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.hero-slider p {
    font-size: 1.15rem;
    max-width: 850px;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.88);
    font-weight: 400;
}

/* Dynamic Grid layouts */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.feature-card {
    background: var(--white);
    border-radius: 12px;
    border-top: 4px solid var(--secondary);
    padding: 30px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    border-top: 4px solid var(--secondary);
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -10px rgba(12, 35, 64, 0.12);
}

.feature-card h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 1.25rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.92rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.3s;
    background-color: #fcfdfe;
}

.form-control:focus {
    border-color: var(--primary);
    background-color: var(--white);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--primary);
    box-shadow: 0 4px 12px var(--secondary-glow);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--secondary-glow);
}

/* Responsive Table */
.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

th, td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    background-color: var(--primary);
    color: var(--white);
    font-weight: 700;
    border-bottom: 2px solid var(--secondary);
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) {
    background-color: #fafbfc;
}

/* Responsive breakpoints */
@media (max-width: 1150px) {
    .menu-toggle {
        display: block;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
        background: var(--primary-light);
        border-radius: 8px;
        margin-top: 15px;
        overflow: hidden;
        box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-item {
        width: 100%;
        text-align: center;
    }

    .nav-item a {
        display: block;
        padding: 14px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .btn-portal {
        border-radius: 0 !important;
        padding: 14px !important;
        box-shadow: none;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 15px 20px;
    }
    .brand img {
        height: 50px;
    }
    .brand-text h1 {
        font-size: 1.05rem;
    }
    .hero-slider {
        padding: 60px 20px;
    }
    .hero-slider h2 {
        font-size: 1.8rem;
    }
    .hero-slider p {
        font-size: 1rem;
    }
}

/* 🌙 Dark Mode System Overrides */
html.dark-theme, :root.dark-theme {
    --light: #0b0f19;
    --white: #111827;
    --dark: #f1f5f9;
    --border: #1e293b;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.dark-theme .card, .dark-theme .feature-card {
    background: var(--white);
    border-color: var(--border);
    color: var(--dark);
}

.dark-theme th {
    background-color: #0f172a;
    color: #ffffff;
    border-bottom-color: var(--secondary);
}

.dark-theme td {
    border-bottom-color: var(--border);
}

.dark-theme tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.dark-theme .form-control {
    background-color: #1e293b;
    border-color: var(--border);
    color: var(--white);
}

.dark-theme .form-control:focus {
    background-color: #0f172a;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.25);
}

/* 🤖 AI Chatbot Floating Styles */
#chatbot-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--secondary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(12, 35, 64, 0.3);
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid var(--primary);
}

#chatbot-bubble:hover {
    transform: scale(1.1) rotate(5deg);
}

#chatbot-window {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 360px;
    height: 480px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(12, 35, 64, 0.25);
    border: 3px solid var(--secondary);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transition: all 0.3s ease;
}

.chatbot-header {
    background: var(--primary);
    color: var(--white);
    padding: 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--secondary);
}

.chatbot-header button {
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

.dark-theme .chatbot-messages {
    background: #0b0f19;
}

.chat-msg {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.88rem;
    line-height: 1.4;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.bot-msg {
    background: #e2e8f0;
    color: #0f172a;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.dark-theme .bot-msg {
    background: #1e293b;
    color: #f1f5f9;
}

.user-msg {
    background: var(--primary);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.dark-theme .user-msg {
    background: var(--secondary);
    color: var(--primary);
}

.chatbot-input-area {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--white);
    gap: 8px;
}

.chatbot-input-area input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 30px;
    outline: none;
    font-size: 0.88rem;
    background: #f8fafc;
}

.dark-theme .chatbot-input-area input {
    background: #1e293b;
    color: white;
    border-color: var(--border);
}

.chatbot-input-area button {
    background: var(--secondary);
    color: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.chatbot-input-area button:hover {
    background: var(--secondary-hover);
}

/* 🌐 RTL specific adjustments for Chatbot position */
body[dir="rtl"] #chatbot-bubble {
    right: auto;
    left: 30px;
}

body[dir="rtl"] #chatbot-window {
    right: auto;
    left: 30px;
}

/* 📱 Mobile Responsive Adjustments for Student Portal */
@media (max-width: 768px) {
    .portal-header {
        flex-direction: column !important;
        gap: 15px !important;
        text-align: center !important;
        padding: 15px 10px !important;
    }
    
    .portal-header > div {
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .portal-header > div:last-child {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
    }
    
    .portal-header .btn, 
    .portal-header .btn-lang {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        text-align: center !important;
        flex: 1 1 auto !important;
    }
    
    .student-profile-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
        padding: 15px !important;
        text-align: center !important;
    }
    
    .student-profile-bar > div:first-child > div {
        justify-content: center !important;
    }
    
    .student-profile-bar > div:last-child {
        justify-content: center !important;
        width: 100% !important;
    }

    .student-profile-bar .btn {
        width: 100% !important;
        text-align: center !important;
    }
    
    .main-wrapper {
        padding: 15px 10px !important;
    }
    
    .card {
        padding: 15px !important;
    }
    
    .meta-table, 
    .meta-table tbody, 
    .meta-table tr, 
    .meta-table td {
        display: block !important;
        width: 100% !important;
    }
    
    .meta-table td {
        border-bottom: 1px solid var(--border) !important;
        padding: 10px !important;
        font-size: 0.9rem !important;
    }
    
    .meta-table tr:last-child td:last-child {
        border-bottom: none !important;
    }
    
    /* Enhance table scrolling on mobile */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-top: 15px !important;
        border: 1px solid var(--border) !important;
        width: 100% !important;
    }
    
    .table-responsive table {
        width: 100% !important;
        min-width: 600px !important; /* Ensure columns don't squish too much, forces scroll instead */
    }
}

