/* ============================================
   RESPONSIVE DESIGN -  للصناعات المعدنية
   تصميم متجاوب لجميع الأجهزة (ملف مُصحح)
   ============================================ */

/* ============================================
   GLOBAL FIXES - إصلاحات عامة
   ============================================ */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw;
    position: relative !important;
    transform: none !important;
    /* Prevent sidebar clipping */
}

body.no-scroll {
    overflow: hidden !important;
}

* {
    max-width: 100%;
}

/* ============================================
   MOBILE NAVIGATION - Hamburger Menu
   ============================================ */
@media (max-width: 992px) {
    .menu-toggle {
        display: flex !important;
        justify-content: center;
        align-items: center;
        width: 45px;
        height: 45px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 10px;
        font-size: 1.5rem;
        z-index: 1100;
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    nav#mainNav {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        right: -100% !important;
        width: 85% !important;
        max-width: 300px !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        background: #0f172a !important;
        background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%) !important;
        padding: 80px 20px 40px !important;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5) !important;
        z-index: 9999 !important;
        /* Extremely high z-index */
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }

    nav#mainNav.active {
        right: 0 !important;
    }

    nav#mainNav ul {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
        padding: 0 !important;
        margin: 0 !important;
        list-style: none !important;
        height: auto !important;
    }

    nav#mainNav ul li {
        width: 100%;
    }

    nav#mainNav ul li>a {
        display: block;
        padding: 14px 18px;
        font-size: 1rem;
        color: #fff;
        border-radius: 8px;
        border-right: 3px solid transparent;
        transition: all 0.3s ease;
        background: rgba(255, 255, 255, 0.05);
        text-decoration: none;
    }

    nav#mainNav ul li>a:hover,
    nav#mainNav ul li>a.active {
        background: rgba(245, 158, 11, 0.15);
        border-right-color: var(--accent-main);
    }

    /* Mobile Dropdown Styles */
    .dropdown {
        position: relative;
    }

    .dropdown>a::after {
        content: '▼';
        font-size: 0.7rem;
        margin-right: 8px;
        transition: transform 0.3s ease;
    }

    .dropdown.active>a::after {
        transform: rotate(180deg);
    }

    .dropdown-content {
        position: static !important;
        display: none;
        background: rgba(0, 0, 0, 0.3);
        margin-top: 8px;
        border-radius: 8px;
        padding: 8px;
        width: 100%;
        box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .dropdown.active .dropdown-content {
        display: block;
    }

    .dropdown-content a {
        display: block;
        padding: 10px 15px;
        font-size: 0.9rem;
        color: #e2e8f0;
        border-radius: 6px;
        transition: all 0.2s ease;
        text-decoration: none;
        margin-bottom: 4px;
    }

    .dropdown-content a:last-child {
        margin-bottom: 0;
    }

    .dropdown-content a:hover {
        background: rgba(245, 158, 11, 0.2);
        color: #fbbf24;
    }

    /* Header adjustments */
    .header-container {
        padding: 0 15px;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    /* Hero adjustments */
    .hero {
        height: auto !important;
        min-height: 55vh !important;
        padding-top: 90px !important;
        padding-bottom: 20px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Page Hero adjustments (for inner pages like services) */
    .page-hero {
        min-height: auto !important;
        padding: 100px 15px 30px !important;
    }

    .page-hero-content {
        padding: 10px !important;
    }

    .page-hero h1 {
        font-size: 1.5rem !important;
        margin-bottom: 8px !important;
        line-height: 1.3 !important;
    }

    .page-hero p {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }

    /* Service Detail Header adjustments */
    .service-detail-header {
        gap: 10px !important;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
    }

    .service-detail-header .icon {
        font-size: 1.8rem !important;
    }

    .service-detail-header h2 {
        font-size: 1.3rem !important;
    }

    .hero-content {

        padding: 20px;
        min-height: unset;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        position: relative;
        z-index: 10;
    }

    .hero-title {
        font-size: 2.2rem;
        letter-spacing: 0;
        margin-bottom: 15px;
        line-height: 1.3;
    }

    .hero-tagline {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 25px;
        padding: 0 10px;
    }

    .hero-btns {
        position: static !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        margin-top: 20px;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        padding: 0 15px;
        display: flex !important;
        align-items: center;
    }

    .dynamic-btn {
        width: 90%;
        max-width: 280px;
        padding: 14px 25px;
        font-size: 0.95rem;
        text-align: center;
    }

    .hero p {
        font-size: 1rem;
        margin-bottom: 20px;
    }

    .scroll-indicator {
        display: none;
    }

    /* Service features */
    .service-feature,
    .service-feature.reverse {
        display: flex !important;
        flex-direction: column !important;
    }

    .service-feature .feature-image,
    .service-feature.reverse .feature-image {
        order: -10 !important;
        width: 100% !important;
        height: auto !important;
        max-height: 220px !important;
        margin-bottom: 15px !important;
        overflow: hidden !important;
    }

    .service-feature .feature-image img,
    .service-feature.reverse .feature-image img {
        width: 100% !important;
        height: auto !important;
        max-height: 220px !important;
        object-fit: cover !important;
        border-radius: 12px !important;
    }

    .service-feature .feature-text,
    .service-feature.reverse .feature-text {
        order: 1 !important;
    }

    /* Tech grid & Services - 2 columns for mobile as suggested */
    .tech-grid,
    #services-content-wrapper.grid-layout {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
        display: grid !important;
    }

    .tech-card,
    #services-content-wrapper.grid-layout .service-feature {
        padding: 18px 12px !important;
        width: 100% !important;
        margin: 0 !important;
        border-top: 4px solid var(--accent-main) !important;
    }

    .tech-image {
        height: 150px;
    }

    .tech-icon {
        font-size: 2.2rem;
    }

    .tech-card h3,
    #services-content-wrapper.grid-layout .service-feature h4 {
        font-size: 1.1rem !important;
        margin-bottom: 8px !important;
    }

    .tech-card p,
    #services-content-wrapper.grid-layout .service-feature p {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }

    /* Equal height tech cards on homepage */
    .tech-card {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }

    .tech-card p {
        flex-grow: 1 !important;
    }

    .tech-card .tech-quote-btn {
        margin-top: auto !important;
    }

    /* Why grid */
    .why-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        display: grid !important;
        align-items: stretch !important;
    }

    .why-card {
        padding: 12px 5px !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        border-top: 4px solid var(--accent-main) !important;
    }

    .why-icon {
        font-size: 1.6rem !important;
        margin-bottom: 5px !important;
    }

    .why-card h3 {
        font-size: 0.95rem !important;
        margin-bottom: 4px !important;
    }

    .why-card p {
        font-size: 0.85rem !important;
        line-height: 1.25 !important;
        flex-grow: 1 !important;
    }
}

/* ============================================
   TABLET STYLES
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 12px !important;
    }

    .section-title {
        margin-bottom: 40px;
    }

    .section-title h2 {
        font-size: 2rem;
    }

    .section-title h2::after {
        width: 80px;
        height: 4px;
    }

    .section-title p {
        font-size: 1rem;
        padding: 0 15px;
    }

    section {
        padding: 60px 0 !important;
    }

    /* About section */
    .about-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .about-image {
        order: -1;
        max-width: 100%;
    }

    /* Footer */
    footer {
        padding-bottom: 100px !important;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }

    .social-links {
        justify-content: center;
    }

    /* About Us - Strengths & Quality */
    .strengths {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        margin-top: 30px !important;
    }

    .strength-item {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 12px 5px !important;
        border-top: 4px solid var(--accent-main) !important;
        text-align: center !important;
    }

    .strength-icon {
        margin: 0 auto 8px !important;
        font-size: 1.4rem !important;
    }

    .strength-text h4 {
        font-size: 0.95rem !important;
        margin-bottom: 4px !important;
    }

    .strength-text p {
        font-size: 0.82rem !important;
        line-height: 1.3 !important;
    }

    .quality-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }

    .quality-card {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 20px 15px !important;
        border-top: 4px solid var(--accent-main) !important;
    }

    .quality-card p {
        flex-grow: 1 !important;
        font-size: 0.85rem !important;
    }
}

/* ============================================
   MOBILE SMALL STYLES
   ============================================ */
@media (max-width: 576px) {
    .hero {
        min-height: 90vh;
        padding-top: 70px;
        padding-bottom: 30px;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .hero-tagline {
        font-size: 0.9rem;
    }

    .dynamic-btn {
        width: 100%;
        max-width: none;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .tech-grid,
    #services-content-wrapper.grid-layout {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .tech-card,
    #services-content-wrapper.grid-layout .service-feature {
        padding: 12px 8px !important;
        border-top-width: 3px !important;
    }

    .tech-card h3,
    #services-content-wrapper.grid-layout .service-feature h4 {
        font-size: 1rem !important;
    }

    .tech-card p,
    #services-content-wrapper.grid-layout .service-feature p {
        font-size: 0.82rem !important;
        line-height: 1.3 !important;
        -webkit-line-clamp: 3 !important;
        line-clamp: 3 !important;
    }

    .tech-quote-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    /* Mobile-friendly blue trigger buttons - ENFORCED CONSISTENCY */
    .interactive-items {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
        margin-top: 25px !important;
        flex-wrap: nowrap !important;
        /* Prevent side-by-side */
    }

    .deep-dive-trigger {
        display: flex !important;
        width: 100% !important;
        min-width: 100% !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 16px 22px !important;
        font-size: 0.9rem !important;
        gap: 12px !important;
        border-radius: 12px !important;
        box-sizing: border-box !important;
        margin-bottom: 0 !important;
        /* Gap handled by parent */
    }

    .deep-dive-trigger span {
        font-size: 0.9rem !important;
        flex: 1 !important;
        text-align: right !important;
        white-space: normal !important;
        /* Allow wrapping for long text */
    }

    .deep-dive-trigger .chevron {
        font-size: 1.1rem !important;
        margin-right: 10px !important;
    }

    /* Services page grid layout specific overrides */
    #services-content-wrapper.grid-layout .interactive-items {
        gap: 8px !important;
    }

    #services-content-wrapper.grid-layout .deep-dive-trigger {
        padding: 10px 15px !important;
        font-size: 0.75rem !important;
    }

    #services-content-wrapper.grid-layout .deep-dive-trigger span {
        font-size: 0.75rem !important;
    }

    /* Equal height cards */
    #services-content-wrapper.grid-layout .service-feature {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }

    #services-content-wrapper.grid-layout .feature-text {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;
    }

    #services-content-wrapper.grid-layout .feature-text p {
        flex-grow: 1 !important;
    }

    .why-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        display: grid !important;
        align-items: stretch !important;
    }

    .why-card {
        padding: 10px 4px !important;
        border-top-width: 3px !important;
    }

    .why-icon {
        font-size: 1.4rem !important;
    }

    .why-card h3 {
        font-size: 0.9rem !important;
    }

    .why-card p {
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }

    .section-title h2 {
        font-size: 1.6rem;
    }

    .section-title p {
        font-size: 0.9rem;
    }

    /* Smaller About Us Cards */
    .strengths {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }

    .strength-item {
        padding: 10px 4px !important;
        border-top-width: 3px !important;
    }

    .strength-icon {
        font-size: 1.2rem !important;
    }

    .strength-text h4 {
        font-size: 0.85rem !important;
    }

    .strength-text p {
        font-size: 0.78rem !important;
        line-height: 1.2 !important;
    }

    .quality-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .quality-card {
        padding: 15px 10px !important;
        border-top-width: 3px !important;
    }

    .quality-card h3 {
        font-size: 0.95rem !important;
    }

    .quality-card p {
        font-size: 0.75rem !important;
    }

    /* Compact Category Tabs for Mobile */
    .services-nav-section {
        padding: 5px 0 !important;
    }

    .category-tabs-wrapper {
        padding: 0 10px !important;
    }

    .category-tab {
        padding: 12px 15px !important;
        font-size: 0.9rem !important;
        gap: 6px !important;
    }

    .category-tab .tab-icon {
        font-size: 1.1rem !important;
    }
}

@media (max-width: 576px) {
    .category-tab {
        padding: 10px 12px !important;
        font-size: 0.8rem !important;
        gap: 5px !important;
    }

    .category-tab .tab-icon {
        font-size: 1rem !important;
    }
}

/* ============================================
   BOTTOM NAVIGATION (Mobile Only)
   ============================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, #0f172a 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 900;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
}

@media (max-width: 992px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    /* Removed padding from body to fix white bar, moved to footer */
    body {
        padding-bottom: 0 !important;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border-radius: 8px;
    gap: 4px;
}

.bottom-nav-item i {
    font-size: 1.3rem;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: #f59e0b;
}

.bottom-nav-item.highlight {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.bottom-nav-item.highlight i {
    font-size: 1.4rem;
}

.bottom-nav.nav-hidden {
    transform: translateY(100%);
}

/* ============================================
   FLOATING ACTIONS
   ============================================ */
.floating-actions {
    position: fixed;
    bottom: 100px;
    left: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 800;
}

@media (max-width: 992px) {
    .floating-actions {
        bottom: 90px;
    }
}

.back-to-top {
    width: 50px;
    height: 50px;
    background: var(--gradient-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.back-to-top:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.whatsapp-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
}

.whatsapp-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.5);
}

@media (max-width: 576px) {
    .floating-actions {
        left: 15px;
    }

    .whatsapp-btn span {
        display: none;
    }

    .whatsapp-btn {
        padding: 12px;
        border-radius: 50%;
    }

    .back-to-top {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* ============================================
   MODAL RESPONSIVE
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: #fff;
    border-radius: 20px;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        max-height: 90vh;
        border-radius: 15px;
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.modal-content {
    padding: 40px;
}

@media (max-width: 576px) {
    .modal-content {
        padding: 25px 20px;
    }
}

/* ============================================
   THEME SWITCH
   ============================================ */
.theme-switch {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    font-size: 1.1rem;
}

.theme-switch:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(20deg);
}

@media (max-width: 992px) {
    .theme-switch {
        position: absolute;
        right: 70px;
        top: 50%;
        transform: translateY(-50%);
    }
}

/* ============================================
   REVEAL ANIMATIONS
   ============================================ */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.active,
.reveal.reveal-active {
    opacity: 1;
    transform: translateY(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-right.active,
.reveal-right.reveal-active {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    header,
    .bottom-nav,
    .floating-actions,
    .modal-overlay {
        display: none !important;
    }

    body {
        padding: 0 !important;
    }

    .hero {
        height: auto;
        min-height: auto;
    }
}