/* === CSS Variables === */
:root {
    --primary: #1A237E;
    --secondary: #FB6D00;
    --text-dark: #14213B;
    --text-main: #454652;
    --text-light: #757575;
    --bg-light: #F5F2FB;
    --bg-white: #FBF8FF;
    --border-color: #C6C5D4;
    --success: #4CAF50;
    --transition: 0.3s ease;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    color: var(--text-main);
    background: #FFFCFC;
    line-height: 1.6;
    /* clip (not hidden) prevents horizontal scroll WITHOUT creating a
       scroll container, so position: sticky keeps working on descendants */
    overflow-x: clip;
}

html {
    scroll-behavior: smooth;
}

/* Support LTR dynamically */
html[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.section-padding {
    padding: 80px 0;
}

.bg-light {
    background-color: var(--bg-light);
}

/* === Buttons === */
.btn {
    padding: 8px 24px;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-weight: 500;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--secondary);
    color: #FFFCFC;
}
.btn-primary:hover {
    background-color: #e65100;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover {
    background-color: var(--primary);
    color: white;
}

.btn-outline-block {
    width: 100%;
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
    padding: 8px;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-outline-block:hover {
    background-color: var(--primary);
    color: white;
}

/* === Header === */
.header {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
}

.logo img {
    height: 50px;
    object-fit: contain;
}

.main-nav ul {
    display: flex;
    gap: 32px;
}

.main-nav a {
    font-weight: 500;
    color: var(--text-main);
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}

.main-nav a.active, .main-nav a:hover {
    color: var(--text-dark);
    border-bottom-color: var(--secondary);
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.lang-toggle {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-family: 'Cairo';
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
}

/* === Hero Section === */
.hero {
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    color: white;
    padding: 80px 0 100px;
    position: relative;
    min-height: 500px;
    display: flex;
    align-items: center;
}

.hero-bg-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.12), transparent 24%),
        radial-gradient(circle at 80% 18%, rgba(251, 109, 0, 0.14), transparent 22%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(10, 16, 72, 0.18) 100%);
    opacity: 1;
    pointer-events: none;
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.hero h1 {
    font-size: 48px;
    line-height: 1.25;
    max-width: 900px;
    text-shadow: 0 4px 12px rgba(0,0,0,0.25);
    font-weight: 800;
}

.hero-subtitle {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
    max-width: 700px;
    text-shadow: 0 3px 10px rgba(0,0,0,0.2);
    line-height: 1.6;
}

.search-box {
    background: var(--bg-white);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 900px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 1;
    min-width: 200px;
}

.search-input-wrapper input {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Cairo';
    font-size: 16px;
    outline: none;
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
}

/* Dropdowns */
.dropdown {
    position: relative;
    min-width: 150px;
}

.dropdown-toggle {
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Cairo';
    justify-content: space-between;
}

/* Override Bootstrap dropdown-toggle caret (causes duplication) */
.search-box .dropdown-toggle::after,
.dropdown-toggle[data-dropdown-button]::after {
    display: none !important;
    content: none !important;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    background: #ffffff;
    border: 1px solid rgba(198, 197, 212, 0.95);
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(20, 33, 59, 0.14);
    width: 100%;
    z-index: 9999;
    display: none;        
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    overflow-y: auto;      
    max-height: 300px;     
    padding: 8px 0;       
} 
html[dir="ltr"] .dropdown-menu {
    right: auto;
    left: 0;
}

.dropdown.active .dropdown-menu {
     display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: block;
    padding: 12px 16px;
    transition: var(--transition);
    color: var(--text-dark);
    font-weight: 500;
}

.dropdown-menu a:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.search-btn {
    height: 58px;
    padding: 0 40px;
}

.register-link {
    color: #E77624;
    font-weight: 500;
    transition: var(--transition);
}
.register-link:hover {
    color: white;
}

/* === Section Headers === */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 48px;
    border-bottom: 2px solid #E5EEFF;
    padding-bottom: 16px;
}

.section-text h2 {
    color: var(--primary);
    font-size: 24px;
}

.section-text p {
    color: var(--text-light);
    font-size: 16px;
}

.view-all {
    color: #9E4200;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    white-space: nowrap;
}

/* === Categories Section === */
.categories-swiper {
    padding-bottom: 50px !important;
}

.category-card {
    background: white;
    border: 1px solid rgba(193,199,210,0.3);
    border-radius: 14px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.category-icon {
    width: 96px;
    height: 96px;
    background: #E5EEFF;
    border-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: var(--primary);
}

.category-card h3 {
    color: var(--text-dark);
    font-size: 18px;
    margin-bottom: 4px;
    text-align: center;
    width: 100%;
    display: block;
}

.category-card span {
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
    display: block;
    width: 100%;
}

/* === Company Cards === */
.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
}

.company-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.company-img {
    height: 200px;
    position: relative;
    background: #eee;
}

.company-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.badge {
    position: absolute;
    top: 16px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge.verified {
    left: 16px;
    background: rgba(76, 175, 80, 0.9);
    color: white;
}

html[dir="ltr"] .badge.verified {
    left: auto;
    right: 16px;
}

.badge.featured {
    right: 16px;
    background: var(--primary);
    color: white;
    border-radius: 9999px;
}

html[dir="ltr"] .badge.featured {
    right: auto;
    left: 16px;
}

.company-info {
    padding: 24px;
    position: relative;
}

.company-logo {
    width: 64px;
    height: 64px;
    background: #EFECF5;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -48px;
    right: 24px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
}

html[dir="ltr"] .company-logo {
    right: auto;
    left: 24px;
}

.company-logo img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.company-info h3 {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 8px;
}

.company-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.company-rating span {
    color: var(--text-light);
}

.company-info p {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* === Products Grid === */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(193,199,210,0.3);
    transition: var(--transition);
}

.product-card:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.product-img {
    height: 200px;
    position: relative;
    background: #f0f0f0;
}

.product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.discount-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #D32F2F;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
}

.product-info {
    padding: 16px;
}

.product-info h3 {
    font-size: 16px;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.product-company {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
    font-size: 14px;
    color: var(--text-light);
}

.price {
    font-weight: 700;
    color: var(--primary);
}

/* === Articles === */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
}

.article-card {
    background: white;
    border: 1px solid rgba(193,199,210,0.3);
    padding: 24px;
    border-radius: 12px;
    transition: var(--transition);
}

.article-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.article-tags {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.article-tags span {
    background: #E5EEFF;
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

.article-card h3 {
    font-size: 18px;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.article-card p {
    color: var(--text-light);
    font-size: 15px;
}

/* Article thumbnail and read-more button */
.article-card .article-img {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}
.article-card .article-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s ease;
}
.article-card:hover .article-img img {
    transform: scale(1.03);
}

.article-card .read-more {
    margin-top: 14px;
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}
.article-card .read-more:hover {
    background: var(--primary);
    color: white;
}

@media (max-width: 768px) {
    .article-card .article-img {
        height: 200px;
    }
}

/* === Newsletter === */
.newsletter {
    background: var(--text-light);
    color: white;
    padding: 60px 0;
}

.newsletter-container {
    text-align: center;
    max-width: 560px;
}

.newsletter h2 {
    margin-bottom: 16px;
}

.newsletter p {
    margin-bottom: 32px;
    opacity: 0.9;
}

.newsletter-form {
    display: flex;
    gap: 16px;
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

.newsletter-form input {
    flex: 1;
    border: none;
    padding: 12px;
    font-family: 'Cairo';
    outline: none;
    border-radius: 8px;
}

.form-message {
    margin-top: 12px;
    font-size: 14px;
}

.form-message.error {
    color: #ff6b6b;
}

.form-message.success {
    color: #81c784;
}

/* === Footer === */
.footer {
    background: var(--primary);
    color: rgba(255,255,255,0.8);
    padding-top: 60px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 40px;
}

.footer h3 {
    color: white;
    font-size: 20px;
    margin-bottom: 20px;
}

.about-col p {
    line-height: 1.8;
}

.footer ul li {
    margin-bottom: 10px;
}

.footer ul a:hover {
    color: var(--secondary);
    padding-inline-start: 5px;
}

.contact-info li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.contact-info i {
    color: var(--secondary);
    margin-top: 5px;
}

.footer-bottom {
    margin-top: 40px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 20px 0;
    text-align: center;
    font-size: 14px;
}

/* === Mobile Menu Overlay === */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Body scroll lock when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Mobile nav actions — hidden on desktop, shown on mobile inside nav */
.mobile-nav-actions {
    display: none;
}

/* === Mobile Responsiveness === */
@media (max-width: 992px) {
    .hero { padding: 50px 0 60px; min-height: auto; }
    .hero h1 { font-size: 32px; }
    .hero-subtitle { font-size: 16px; }

    /* Search box: input on top, dropdowns side-by-side, button full-width */
    .search-box {
        flex-wrap: wrap;
    }
    .search-input-wrapper {
        flex: 1 1 100%;
        order: -1;
        min-width: 0;
    }
    .search-input-wrapper input {
        padding: 14px 16px;
        font-size: 16px;
    }
    .search-box > .dropdown {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
    }
    .dropdown-toggle {
        padding: 10px 12px;
        font-size: 13px;
    }
    .search-btn {
        flex: 1 1 100%;
        height: auto;
        padding: 12px;
        width: auto;
    }

    .category-card { text-align: center; }
    .category-card h3 { text-align: center; }
    .section-header { flex-direction: row; flex-wrap: wrap; }
    .section-header .view-all { margin-inline-start: auto; }
    
    .main-nav {
        position: fixed;
        top: 80px;
        right: -100%; /* RTL off-screen */
        width: 85%;
        max-width: 360px;
        height: calc(100vh - 80px);
        background: var(--bg-white);
        flex-direction: column;
        transition: right 0.3s ease;
        z-index: 999;
        padding: 24px;
        overflow-y: auto;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    }

    html[dir="ltr"] .main-nav {
        right: auto;
        left: -100%;
        transition: left 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    }

    .main-nav.active {
        right: 0; /* Show */
    }

    html[dir="ltr"] .main-nav.active {
        left: 0;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0;
    }

    .main-nav ul li {
        border-bottom: 1px solid rgba(198, 197, 212, 0.3);
    }

    .main-nav ul li:last-child {
        border-bottom: none;
    }

    .main-nav ul li a {
        display: block;
        padding: 14px 0;
        font-size: 16px;
        font-weight: 600;
    }

    /* Dropdown menu inside mobile nav */
    .main-nav .header-dropdown-menu {
        position: static !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 0 0 16px !important;
        min-width: auto !important;
        display: none;
    }

    .main-nav li:hover .header-dropdown-menu,
    .main-nav li.dropdown-open .header-dropdown-menu {
        display: block;
    }

    /* Show mobile-only nav actions */
    .mobile-nav-actions {
        display: block;
        margin-top: 24px;
        padding-top: 20px;
        border-top: 1px solid var(--border-color);
    }

    /* Hide desktop header-actions items on mobile (except hamburger) */
    .header-actions .lang-toggle,
    .header-actions .btn,
    .header-actions form,
    .header-actions a:not(.mobile-menu-btn) {
        display: none !important;
    }

    .mobile-menu-btn {
        display: flex !important;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: background 0.2s;
    }

    .mobile-menu-btn:hover {
        background: rgba(26, 35, 126, 0.08);
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .hero { padding: 36px 0 48px; }
    .hero h1 { font-size: 26px; line-height: 1.3; }
    .hero-subtitle { font-size: 15px; }
    .search-box { padding: 14px; gap: 10px; }
    .search-input-wrapper input { padding: 14px; font-size: 16px; }
    .dropdown-toggle { padding: 10px 8px; font-size: 12px; }
    .dropdown-toggle span { font-size: 12px; }
    .search-btn { height: auto; padding: 12px; font-size: 15px; }

    .companies-grid, .products-grid, .articles-grid {
        grid-template-columns: 1fr;
    }
    .section-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
    }
    .section-header .section-text {
        flex: 1;
        min-width: 0;
    }
    /* عرض الكل دائماً على اليسار في الموبايل */
    .section-header .view-all {
        margin-inline-start: auto;
        order: 0;
    }
    html[dir="rtl"] .section-header .view-all {
        margin-left: auto;
        margin-right: 0;
    }
    .category-card { padding: 16px; }
    .category-icon { width: 72px; height: 72px; font-size: 26px; }
    .category-card h3 { font-size: 16px; }

    .newsletter-container { max-width: 100%; }
    .newsletter-form {
        flex-direction: column;
    }

    .header-container {
        height: 64px;
    }

    .logo img {
        height: 40px;
    }

    .main-nav {
        top: 64px;
        height: calc(100vh - 64px);
    }

    .mobile-menu-overlay {
        top: 64px;
    }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 22px; }
    .hero-subtitle { font-size: 14px; }
    .hero { padding: 28px 0 36px; }
    /* Keep dropdowns side-by-side but more compact */
    .dropdown-toggle { padding: 8px 6px; font-size: 11px; }
    .dropdown-toggle i { font-size: 10px; }
    .dropdown-toggle span { font-size: 11px; }
    .search-input-wrapper input { padding: 12px; font-size: 15px; }
}