/* ==========================================================================
   MadaPower - Responsive CSS
   تصميم متجاوب لجميع الشاشات
   Breakpoints:
   - Mobile:  < 640px
   - Tablet:  641 - 1024px
   - Desktop: 1025 - 1280px
   - Large:   > 1280px
   ========================================================================== */

/* ===== Large Desktop (> 1280px) ===== */
@media (min-width: 1281px) {
    .container {
        padding: 0 32px;
    }

    .hero-content {
        gap: 80px;
    }

    .hero-visual {
        height: 460px;
    }

    .hero-image-wrapper {
        width: 340px;
        height: 340px;
    }

    .hero-icon-main {
        font-size: 180px !important;
    }
}

/* ===== Desktop (1025 - 1280px) ===== */
@media (max-width: 1280px) {
    .features-grid,
    .services-grid,
    .why-us-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid,
    .about-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Tablet (769 - 1024px) ===== */
@media (max-width: 1024px) {
    :root {
        --header-height: 70px;
    }

    .nav-desktop {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .nav-mobile {
        display: none;
    }

    /* Show menu only when open */
    .nav-mobile.open {
        display: flex;
    }

    /* Show backdrop when menu is open */
    .menu-backdrop {
        display: none;
    }

    .menu-backdrop.open {
        display: block;
    }

    .add-product-btn-desktop {
        display: none;
    }

    /* Hide global search on tablet, show it as icon */
    .global-search-wrapper {
        display: none;
    }

    .hero {
        padding: 60px 0 80px;
    }

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

    .hero-badge {
        margin-inline: auto;
    }

    .hero-actions {
        justify-content: center;
    }

    .hero-desc {
        margin-inline: auto;
    }

    .hero-visual {
        height: 350px;
        order: -1;
    }

    .hero-image-wrapper {
        width: 260px;
        height: 260px;
    }

    .hero-icon-main {
        font-size: 140px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .features-grid,
    .services-grid,
    .why-us-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .projects-grid,
    .projects-grid-large {
        grid-template-columns: 1fr;
    }

    .related-section .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }

    .footer-brand {
        grid-column: span 2;
    }

    .product-detail-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .specs-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .contact-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .cart-layout {
        grid-template-columns: 1fr;
    }

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

    .cart-summary-card {
        position: static;
    }

    .about-intro {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .about-visual {
        height: 300px;
    }

    .mvv-section {
        grid-template-columns: 1fr;
    }

    .about-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .projects-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .service-cycle {
        flex-direction: column;
    }

    .cycle-arrow, .cycle-connector {
        transform: rotate(90deg);
    }

    .email-item {
        grid-template-columns: auto 1fr auto;
        gap: 12px;
    }

    .email-sender, .email-subject {
        grid-column: span 1;
    }

    .email-date {
        grid-column: span 3;
        flex-direction: row;
        justify-content: space-between;
        padding-top: 8px;
        border-top: 1px solid var(--color-border-light);
    }
}

/* ===== Mobile Large (481 - 768px) ===== */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --top-bar-height: 0px;
    }

    /* Hide top bar entirely on mobile */
    .top-bar {
        display: none;
    }

    .container {
        padding: 0 12px;
    }

    /* ===== Header Mobile Stabilization ===== */
    .header {
        position: sticky;
        top: 0;
        z-index: 1000;
        width: 100%;
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
    }

    .header-content {
        height: var(--header-height);
        gap: 8px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    /* Logo - compact on mobile */
    .logo {
        gap: 8px;
    }

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

    .logo-tagline {
        display: none;
    }

    .logo-icon {
        font-size: 24px !important;
        padding: 6px;
    }

    /* Hide desktop search on mobile */
    .global-search-wrapper {
        display: none;
    }

    /* Header actions - compact */
    .header-actions {
        gap: 2px;
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .icon-btn .material-symbols-rounded {
        font-size: 20px;
    }

    .theme-toggle {
        width: 36px;
        height: 36px;
    }

    .theme-toggle .material-symbols-rounded {
        font-size: 20px;
    }

    /* Hide some icons on small mobile to save space */
    .add-product-btn-desktop {
        display: none;
    }

    /* Hide email & orders icons on small screens - available in mobile menu */
    .header-actions .icon-btn[aria-label="Messages"],
    .header-actions .icon-btn[aria-label="My Orders"] {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        width: 36px;
        height: 36px;
    }

    .mobile-menu-toggle .material-symbols-rounded {
        font-size: 22px;
    }

    /* Cart badge smaller */
    .cart-btn .badge {
        min-width: 16px;
        height: 16px;
        font-size: 0.65rem;
        padding: 0 4px;
    }

    /* ===== Mobile Menu (Full screen dropdown) ===== */
    .nav-mobile {
        position: fixed;
        top: var(--header-height);
        inset-inline: 0;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        box-shadow: var(--shadow-2xl);
        padding: 0;
    }

    .nav-mobile.open {
        padding: 12px;
    }

    .nav-mobile-link {
        padding: 14px 16px;
        font-size: 1rem;
    }

    /* Hero */
    .hero {
        padding: 32px 0 48px;
    }

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

    .hero-desc {
        font-size: 0.95rem;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .hero-visual {
        height: 240px;
    }

    .hero-image-wrapper {
        width: 180px;
        height: 180px;
    }

    .hero-icon-main {
        font-size: 90px !important;
    }

    .hero-card-float {
        padding: 6px 10px;
    }

    .hero-card-float .material-symbols-rounded {
        font-size: 18px;
    }

    .hero-card-float strong {
        font-size: 0.7rem;
    }

    .hero-card-float span {
        font-size: 0.85rem;
    }

    /* Section spacing */
    .stats-section,
    .features-section,
    .featured-section,
    .services-preview-section,
    .projects-preview-section,
    .cta-section {
        padding: 40px 0;
    }

    .section-header {
        margin-bottom: 24px;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .section-desc {
        font-size: 0.9rem;
    }

    /* Stats */
    .stat-card {
        padding: 16px 8px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
    }

    .stat-icon .material-symbols-rounded {
        font-size: 22px;
    }

    /* Features & Services */
    .features-grid,
    .services-grid,
    .why-us-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature-card,
    .service-card,
    .why-us-card {
        padding: 20px 16px;
    }

    .feature-icon,
    .service-icon {
        width: 56px;
        height: 56px;
    }

    .feature-icon .material-symbols-rounded,
    .service-icon .material-symbols-rounded {
        font-size: 28px;
    }

    /* Products */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .product-info {
        padding: 10px;
    }

    .product-name {
        font-size: 0.85rem;
    }

    .product-desc {
        font-size: 0.75rem;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .product-price {
        font-size: 1rem;
    }

    .product-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .product-actions {
        justify-content: stretch;
    }

    .product-actions .btn {
        flex: 1;
        padding: 5px 6px;
        font-size: 0.75rem;
    }

    .product-image {
        aspect-ratio: 1/1;
    }

    /* Filters */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input-wrapper {
        max-width: 100%;
    }

    .category-filters {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .filter-chip {
        padding: 6px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .filter-chip .material-symbols-rounded {
        font-size: 16px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 16px;
        inset-inline-end: 16px;
    }

    .back-to-top .material-symbols-rounded {
        font-size: 20px;
    }

    /* Projects */
    .projects-grid {
        grid-template-columns: 1fr;
    }

    .projects-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .project-stat {
        padding: 16px;
    }

    .project-stat .material-symbols-rounded {
        font-size: 32px;
    }

    .project-stat .stat-value {
        font-size: 1.3rem;
    }

    /* Service Cycle */
    .service-cycle {
        background: transparent !important;
        padding: 0 !important;
        gap: 24px;
    }

    .services-cycle-section .service-cycle {
        background: transparent;
        padding: 0;
    }

    .cycle-step {
        min-width: 100%;
    }

    .cycle-arrow, .cycle-connector {
        transform: rotate(90deg);
    }

    /* CTA */
    .cta-actions {
        flex-direction: column;
        width: 100%;
    }

    .cta-actions .btn {
        width: 100%;
    }

    /* Footer */
    .footer {
        padding: 40px 0 20px;
    }

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

    .footer-brand {
        grid-column: span 1;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    /* Page Header */
    .page-header {
        padding: 24px 0;
    }

    .page-title {
        font-size: 1.3rem;
    }

    /* Product Detail */
    .product-detail-title {
        font-size: 1.3rem;
    }

    .product-detail-image {
        aspect-ratio: 16/10;
    }

    .price-value {
        font-size: 1.3rem;
    }

    .add-to-cart-form {
        flex-direction: column;
        align-items: stretch;
    }

    .add-to-cart-form .btn {
        width: 100%;
    }

    .product-features {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .specifications-section,
    .related-section {
        padding: 16px;
    }

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

    .related-section .products-grid {
        grid-template-columns: 1fr;
    }

    /* Cart */
    .cart-item {
        grid-template-columns: auto 1fr;
        gap: 12px;
        padding: 12px;
    }

    .cart-item-info {
        grid-column: span 2;
        padding-top: 8px;
        border-top: 1px solid var(--color-border-light);
    }

    .cart-item-image {
        width: 56px;
        height: 56px;
    }

    .cart-item-quantity {
        grid-column: span 1;
    }

    .cart-item-subtotal {
        grid-column: span 1;
        text-align: end;
        min-width: auto;
    }

    .btn-remove {
        grid-column: span 2;
        justify-self: end;
    }

    /* Checkout */
    .checkout-card {
        padding: 16px;
    }

    .form-row.two-cols {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Contact */
    .contact-form-card {
        padding: 16px;
    }

    .contact-info-item {
        padding: 12px;
    }

    .map-card {
        padding: 32px 16px;
    }

    /* About */
    .about-visual {
        height: auto;
        grid-template-columns: 1fr;
    }

    .about-card-main {
        grid-row: span 1;
    }

    .about-card {
        padding: 20px 16px;
    }

    .about-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .stat-number {
        font-size: 1.8rem;
    }

    .about-cta {
        padding: 32px 16px;
    }

    .about-cta h2 {
        font-size: 1.3rem;
    }

    /* Emails */
    .email-item {
        grid-template-columns: auto 1fr auto;
        padding: 12px;
        gap: 10px;
    }

    .email-avatar {
        width: 32px;
        height: 32px;
    }

    .email-avatar .material-symbols-rounded {
        font-size: 18px;
    }

    .email-date {
        display: none;
    }

    .email-detail-header {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
        text-align: center;
        align-items: center;
    }

    .email-detail-body {
        padding: 16px;
    }

    .email-detail-actions {
        padding: 12px 16px;
        flex-direction: column;
    }

    .email-detail-actions .btn {
        width: 100%;
    }

    /* Form Card */
    .form-card {
        padding: 16px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Security badges */
    .security-badges {
        gap: 8px;
    }

    .security-badge {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    /* Search page */
    .search-filters-card {
        padding: 16px;
    }

    .search-input-wrapper-large {
        flex-direction: column;
        align-items: stretch;
    }

    .search-submit-btn {
        width: 100%;
        justify-content: center;
    }

    .search-filters-row {
        grid-template-columns: 1fr;
    }

    /* Orders */
    .orders-stats {
        grid-template-columns: 1fr;
    }

    .order-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .order-card-body {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== Mobile Small (< 480px) ===== */ia (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .logo-text {
        display: none;
    }

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

    .hero-card-float {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px 8px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

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

    .product-image {
        aspect-ratio: 16/10;
    }

    .filter-chip {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .filter-chip .material-symbols-rounded {
        font-size: 16px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 16px;
        inset-inline-end: 16px;
    }

    .back-to-top .material-symbols-rounded {
        font-size: 20px;
    }
}

/* ===== Mobile Extra Small (< 360px) ===== */
@media (max-width: 360px) {
    .hero-title {
        font-size: 1.25rem;
    }

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

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

    .icon-btn {
        width: 36px;
        height: 36px;
    }
}

/* ===== Print Styles ===== */
@media print {
    .top-bar,
    .header-actions,
    .footer,
    .back-to-top,
    .mobile-menu-toggle,
    .nav-mobile,
    .cta-section,
    .hero-particles,
    .hero-bg-grid {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .hero {
        background: white;
        color: black;
        padding: 20px 0;
    }

    .hero-title, .hero-desc {
        color: black;
    }

    .gradient-text {
        -webkit-text-fill-color: black;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
