/* ====================================================
   RESPONSIVE MOBILE OPTIMIZATION
   Optimisations pour smartphones et tablettes
   ==================================================== */

/* ============================================
   MEDIA QUERIES - MOBILE FIRST
   ============================================ */

.mobile-header {
    display: none;
}


/* Smartphones et Tablettes (max 1024px) */
@media (max-width: 1024px) {

    /* Body et conteneurs */
    body {
        font-size: 14px;
        padding: 0 !important;
        margin: 0 !important;
        /* Padding removed to fix global spacing issue */
    }

    /* Hero Section - Page d'accueil */
    .hero-banner {
        padding: 2rem 5% !important;
    }

    .hero-content h1 {
        font-size: 1.8rem !important;
        line-height: 1.3 !important;
    }

    .hero-content p {
        font-size: 1rem !important;
    }

    .btn-hero {
        padding: 0.8rem 1.5rem !important;
        font-size: 0.9rem !important;
        width: 100%;
        display: block;
    }

    /* Grilles de produits */
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 0 1rem;
    }

    .categories-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Cards produits */
    .product-card {
        margin-bottom: 1rem;
    }

    .product-image {
        height: 200px !important;
    }

    .product-info {
        padding: 1rem !important;
    }

    .product-name {
        font-size: 1rem !important;
    }

    .product-price {
        font-size: 1.2rem !important;
    }

    /* Sections */
    .products-section,
    .categories-section {
        padding: 2rem 5% !important;
    }

    .section-header h2 {
        font-size: 1.8rem !important;
    }

    /* Boutique - Shop */
    .shop-container {
        grid-template-columns: 1fr !important;
        padding: 0 1rem !important;
        gap: 1rem !important;
    }

    .shop-header {
        padding: 2rem 5% !important;
    }

    .shop-header h1 {
        font-size: 1.8rem !important;
    }

    .sidebar {
        display: block !important;
        position: fixed;
        width: 250px !important;
        height: 100vh;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 9999;
        background: #0d2c54;
    }

    /* Panier */
    .cart-container {
        padding: 1rem !important;
    }

    .cart-items {
        padding: 0 !important;
    }

    .cart-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    .cart-item-image {
        width: 100% !important;
        height: 150px !important;
    }

    .cart-item-details {
        width: 100% !important;
    }

    .cart-item-actions {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .quantity-controls {
        margin: 0.5rem 0 !important;
    }

    /* Checkout */
    .checkout-container {
        padding: 1rem !important;
    }

    .checkout-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .form-group label {
        font-size: 0.9rem !important;
    }

    .form-group input,
    .form-group textarea {
        font-size: 14px !important;
        padding: 10px !important;
    }

    /* Admin - Gestion des commandes */
    .orders-container {
        padding: 1rem !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .stat-card {
        padding: 15px !important;
    }

    .stat-card .value {
        font-size: 24px !important;
    }

    .orders-filters {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .filter-group {
        width: 100% !important;
    }

    .filter-group select,
    .filter-group input {
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Table responsive - Card View (Like Clients) */
    .orders-table {
        border: none;
        overflow: visible;
        margin-bottom: 20px;
    }

    .orders-table table,
    .orders-table thead,
    .orders-table tbody,
    .orders-table th,
    .orders-table td,
    .orders-table tr {
        display: block;
    }

    .orders-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .orders-table tr {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        margin-bottom: 15px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        padding: 10px;
    }

    .orders-table td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50% !important;
        text-align: right;
        white-space: normal;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .orders-table td:last-child {
        border-bottom: none;
        justify-content: center !important;
        padding-left: 10px !important;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .orders-table td::before {
        position: absolute;
        top: 50%;
        left: 15px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        transform: translateY(-50%);
        text-align: left;
        font-weight: bold;
        color: #0d2c54;
        /* Primary color */
        /* Default content empty, filled by specific rules below */
        content: "";
    }

    /* Specific Labels for Orders Table */
    .orders-table td:nth-of-type(1)::before {
        content: "Numéro";
    }

    .orders-table td:nth-of-type(2)::before {
        content: "Client";
    }

    .orders-table td:nth-of-type(3)::before {
        content: "Téléphone";
    }

    .orders-table td:nth-of-type(4)::before {
        content: "Date";
    }

    .orders-table td:nth-of-type(5)::before {
        content: "Total";
    }

    .orders-table td:nth-of-type(6)::before {
        content: "Statut";
    }

    /* No label for Actions column */
    .orders-table td:nth-of-type(7)::before {
        display: none;
    }

    /* Special styling for Action column */
    .orders-table td:nth-of-type(7) {
        border-bottom: none;
        justify-content: center !important;
        padding-left: 10px !important;
        display: flex;
        flex-direction: column;
        gap: 10px;
        height: auto;
        /* Allow flexible height */
        padding-top: 15px;
        padding-bottom: 5px;
    }

    /* Full width buttons */
    .orders-table .action-btn {
        width: 100% !important;
        max-width: none !important;
        padding: 10px 20px !important;
        font-size: 14px !important;
        margin: 5px 0 !important;
        display: block !important;
        text-align: center;
        border-radius: 6px;
    }

    .orders-table .action-btn i {
        margin-right: 8px !important;
    }

    /* Ensure all columns are visible */
    .orders-table th:nth-child(3),
    .orders-table td:nth-child(3),
    .orders-table th:nth-child(4),
    .orders-table td:nth-child(4) {
        display: flex !important;
        /* Restore hidden columns */
    }

    /* Reset card view styles if they exist */
    .orders-table thead,
    .orders-table tbody,
    .orders-table tr {
        display: table-row-group;
        /* Reset to default */
    }

    .orders-table thead {
        display: table-header-group;
    }

    .orders-table tr {
        display: table-row;
        border: none;
        margin-bottom: 0;
        box-shadow: none;
    }

    .orders-table td {
        display: table-cell;
        border: none;
        border-bottom: 1px solid #eee;
        text-align: left;
        padding-left: 10px !important;
        /* Reset padding */
    }

    .orders-table td:before {
        display: none;
        /* Hide data-labels */
    }

    .action-buttons {
        flex-direction: column !important;
        gap: 5px !important;
    }

    .btn-view,
    .btn-delete {
        width: 100% !important;
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    /* Order detail page */
    .order-content {
        grid-template-columns: 1fr !important;
    }

    .order-header {
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: flex-start !important;
    }

    /* Navbar public mobile */
    .navbar-menu {
        gap: 1rem !important;
    }

    .navbar-link {
        font-size: 0.9rem !important;
    }

    /* Sidebar admin */
    .sidebar {
        width: 100% !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 9999;
    }

    .sidebar.active {
        transform: translateX(0) !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
    }

    /* Floating social buttons */
    .floating-social {
        right: 10px !important;
        gap: 10px !important;
    }

    .float-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.2rem !important;
    }

    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important;
        /* Évite le zoom automatique sur iOS */
    }

    /* Mobile Header */
    .mobile-header {
        display: flex !important;
        background: #0d2c54;
        /* Primary color */
        padding: 10px 20px;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 1002;
        /* Above sidebar overlay */
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    #sidebarToggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.8rem;
        cursor: pointer;
        padding: 15px;
        z-index: 2000;
        pointer-events: auto;
        display: block;
        /* Ensure it takes space */
    }

    /* Buttons */
    button,
    .btn,
    .btn-primary,
    .btn-secondary {
        padding: 12px 20px !important;
        font-size: 14px !important;
        width: 100%;
        margin: 0.5rem 0;
    }

    /* Tables génériques */
    table {
        font-size: 12px !important;
    }

    table th,
    table td {
        padding: 8px 4px !important;
    }

    /* Modals */
    .modal-content {
        width: 95% !important;
        margin: 1rem !important;
    }

    /* Images */
    img {
        max-width: 100%;
        height: auto;
    }

    .mobile-logo img {
        height: 40px !important;
        width: auto !important;
    }

    /* Text alignment */
    .text-center-mobile {
        text-align: center !important;
    }

    /* Spacing utilities */
    .p-mobile-1 {
        padding: 0.5rem !important;
    }

    .p-mobile-2 {
        padding: 1rem !important;
    }

    .m-mobile-1 {
        margin: 0.5rem !important;
    }

    .m-mobile-2 {
        margin: 1rem !important;
    }

    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* Smartphones en paysage et petites tablettes (481px à 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .shop-container {
        grid-template-columns: 200px 1fr !important;
    }

    .sidebar {
        display: block !important;
        padding: 1rem !important;
    }

    .hero-content h1 {
        font-size: 2.5rem !important;
    }
}

/* Tablettes (769px à 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .hero-content h1 {
        font-size: 3rem !important;
    }
}

/* ============================================
   TOUCH IMPROVEMENTS
   ============================================ */

/* Améliorer les zones tactiles */
@media (hover: none) and (pointer: coarse) {

    button,
    a,
    .clickable,
    .btn {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Feedback visuel au toucher */
    button:active,
    a:active,
    .btn:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* ============================================
   ORIENTATION LANDSCAPE
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .hero-banner {
        padding: 1.5rem 5% !important;
    }

    .hero-content h1 {
        font-size: 1.5rem !important;
    }

    .modal-content {
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* ============================================
   PRINT OPTIMIZATION
   ============================================ */

@media print {

    .sidebar,
    .navbar,
    .floating-social,
    .mobile-header,
    button,
    .hide-print {
        display: none !important;
    }

    body {
        padding: 0 !important;
        margin: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}