/**
 * MycvTop Store - Checkout Page Mobile Optimization
 * Optimisation complète pour smartphone
 */

/* ============================================
   CHECKOUT PAGE - MOBILE OPTIMIZATION
   ============================================ */
@media (max-width: 768px) {
    .checkout-page {
        padding: 1rem 0 6rem; /* Espace pour éviter le sticky bar */
        background: #f8f9fa;
    }
    
    .checkout-page .container {
        padding: 0 1rem;
        max-width: 100%;
    }
    
    /* Header checkout */
    .checkout-header {
        text-align: center;
        margin-bottom: 2rem;
        padding: 0;
    }
    
    .checkout-header h1 {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    .checkout-header p {
        font-size: 0.95rem;
        color: #6c757d;
    }
    
    /* Layout - 1 colonne sur mobile */
    .checkout-content {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
        max-width: 100%;
    }
    
    /* Résumé panier - Optimisé mobile */
    .checkout-cart-summary {
        background: white;
        border-radius: 12px;
        padding: 1.25rem;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        order: 2; /* Afficher après le formulaire */
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    .checkout-cart-summary::-webkit-scrollbar {
        width: 6px;
    }
    
    .checkout-cart-summary::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }
    
    .checkout-cart-summary::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 10px;
    }
    
    .checkout-cart-summary::-webkit-scrollbar-thumb:hover {
        background: var(--primary-dark);
    }
    
    .checkout-cart-summary h2 {
        font-size: 1.25rem;
        margin-bottom: 1.25rem;
        padding-bottom: 0.75rem;
        border-bottom: 2px solid #e9ecef;
    }
    
    /* Items checkout - Design compact */
    .checkout-items {
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }
    
    .checkout-item {
        flex-direction: column;
        padding: 1rem;
        background: #f8f9fa;
        border-radius: 12px;
        border: 1px solid #e9ecef;
        gap: 0.75rem;
    }
    
    .checkout-item-image {
        width: 100%;
        max-width: 200px;
        aspect-ratio: 1 / 1;
        border-radius: 10px;
        margin: 0 auto;
        overflow: hidden;
        background: white;
        border: 2px solid #e9ecef;
        position: relative;
    }
    
    .checkout-item-image::before {
        content: '';
        display: block;
        padding-top: 100%; /* Force le ratio 1:1 */
    }
    
    .checkout-item-image img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
    
    .checkout-item-details {
        width: 100%;
        gap: 0.75rem;
    }
    
    .checkout-item-details h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
        text-align: center;
    }
    
    .checkout-item-meta {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        width: 100%;
    }
    
    .item-price {
        text-align: center;
        font-size: 0.95rem;
        font-weight: 600;
        color: #495057;
    }
    
    /* Contrôles quantité - Design mobile */
    .checkout-quantity-controls {
        width: 100%;
        justify-content: center;
        border: 2px solid #e9ecef;
        border-radius: 10px;
        overflow: hidden;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .qty-btn-checkout {
        width: 44px;
        height: 44px;
        background: var(--gradient-primary);
        color: white;
        font-size: 1.2rem;
        font-weight: 700;
        border: none;
        transition: all 0.2s ease;
    }
    
    .qty-btn-checkout:hover {
        background: var(--primary-dark);
        transform: scale(1.05);
    }
    
    .qty-btn-checkout:active {
        transform: scale(0.95);
    }
    
    .qty-input-checkout {
        width: 70px;
        height: 44px;
        font-size: 1.1rem;
        font-weight: 700;
        border-left: 1px solid #e9ecef;
        border-right: 1px solid #e9ecef;
    }
    
    .item-total {
        text-align: center;
        font-size: 1.1rem;
        font-weight: 800;
        color: var(--primary-color);
        min-width: auto;
        padding: 0.5rem;
        background: #fefce8;
        border-radius: 8px;
    }
    
    .btn-remove-item {
        width: 100%;
        height: 44px;
        border-radius: 10px;
        margin-top: 0.5rem;
    }
    
    /* Résumé total */
    .checkout-summary-total {
        padding-top: 1.25rem;
        border-top: 2px solid #e9ecef;
    }
    
    .summary-row {
        padding: 0.75rem 0;
        font-size: 1rem;
    }
    
    .summary-row.total {
        font-size: 1.4rem;
        padding-top: 1rem;
        margin-top: 0.75rem;
        border-top: 2px solid #e9ecef;
    }
    
    /* Formulaire checkout - Optimisé mobile */
    .checkout-form-wrapper {
        background: white;
        border-radius: 12px;
        padding: 1.5rem;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        order: 1; /* Afficher avant le résumé - Plus logique pour l'achat */
        margin-bottom: 1.5rem;
    }
    
    .checkout-form-wrapper h2 {
        font-size: 1.25rem;
        margin-bottom: 1.25rem;
        padding-bottom: 0.75rem;
        border-bottom: 2px solid #e9ecef;
    }
    
    .checkout-form .form-group {
        margin-bottom: 1.25rem;
    }
    
    .checkout-form label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
        font-weight: 700;
        color: #212529;
        display: block;
    }
    
    .checkout-form input,
    .checkout-form textarea {
        width: 100%;
        padding: 0.875rem;
        border: 2px solid #e9ecef;
        border-radius: 10px;
        font-size: 1rem;
        min-height: 48px;
        transition: all 0.3s ease;
        background: white;
    }
    
    .checkout-form input:focus,
    .checkout-form textarea:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(45, 134, 89, 0.1);
        background: #fefce8;
    }
    
    .checkout-form textarea {
        min-height: 100px;
        resize: vertical;
    }
    
    /* Groupe promo code */
    .promo-input-group {
        display: flex;
        gap: 0.5rem;
        flex-direction: column;
    }
    
    .promo-input-group input {
        flex: 1;
    }
    
    .btn-validate-promo {
        width: 100%;
        padding: 0.875rem;
        background: #6c757d;
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: 700;
        font-size: 1rem;
        min-height: 48px;
        transition: all 0.3s ease;
    }
    
    .btn-validate-promo:hover {
        background: #5a6268;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
    }
    
    #promo-message {
        margin-top: 0.75rem;
        padding: 0.75rem;
        border-radius: 8px;
        font-size: 0.9rem;
        font-weight: 600;
    }
    
    #promo-message span {
        display: block;
    }
    
    /* Bouton confirmer commande */
    .checkout-form .btn-primary {
        width: 100%;
        padding: 1.125rem 2rem;
        font-size: 1.1rem;
        font-weight: 700;
        border-radius: 12px;
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        background: var(--gradient-primary);
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(45, 134, 89, 0.3);
        transition: all 0.3s ease;
        margin-top: 1rem;
    }
    
    .checkout-form .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(45, 134, 89, 0.4);
        background: var(--primary-dark);
    }
    
    .checkout-form .btn-primary:active {
        transform: translateY(0);
    }
    
    /* Alertes */
    .alert {
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 1.25rem;
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .alert-error {
        background: #f8d7da;
        color: #721c24;
        border: 1px solid #f5c6cb;
    }
    
    .alert-success {
        background: #d4edda;
        color: #155724;
        border: 1px solid #c3e6cb;
    }
}

/* ============================================
   SMARTPHONE - OPTIMISATIONS SPÉCIFIQUES
   ============================================ */
@media (max-width: 480px) {
    .checkout-page {
        padding: 0.75rem 0 5.5rem;
    }
    
    .checkout-page .container {
        padding: 0 0.75rem;
    }
    
    .checkout-header {
        margin-bottom: 1.5rem;
    }
    
    .checkout-header h1 {
        font-size: 1.5rem;
    }
    
    .checkout-header p {
        font-size: 0.9rem;
    }
    
    .checkout-content {
        gap: 1.25rem;
    }
    
    .checkout-cart-summary,
    .checkout-form-wrapper {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .checkout-cart-summary h2,
    .checkout-form-wrapper h2 {
        font-size: 1.15rem;
        margin-bottom: 1rem;
    }
    
    .checkout-item {
        padding: 0.875rem;
    }
    
    .checkout-item-image {
        max-width: 180px;
        aspect-ratio: 1 / 1;
    }
    
    .checkout-item-details h3 {
        font-size: 0.95rem;
    }
    
    .checkout-item-meta {
        gap: 0.625rem;
    }
    
    .item-price {
        font-size: 0.9rem;
    }
    
    .qty-btn-checkout {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .qty-input-checkout {
        width: 60px;
        height: 40px;
        font-size: 1rem;
    }
    
    .item-total {
        font-size: 1rem;
        padding: 0.5rem;
    }
    
    .btn-remove-item {
        height: 40px;
        font-size: 0.9rem;
    }
    
    .summary-row {
        font-size: 0.95rem;
        padding: 0.625rem 0;
    }
    
    .summary-row.total {
        font-size: 1.25rem;
    }
    
    .checkout-form .form-group {
        margin-bottom: 1rem;
    }
    
    .checkout-form label {
        font-size: 0.9rem;
    }
    
    .checkout-form input,
    .checkout-form textarea {
        padding: 0.75rem;
        font-size: 0.95rem;
        min-height: 44px;
    }
    
    .checkout-form textarea {
        min-height: 90px;
    }
    
    .checkout-form .btn-primary {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 50px;
    }
    
    /* Thank you modal mobile */
    .thank-you-modal-content {
        padding: 2rem 1.5rem;
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .thank-you-icon {
        width: 80px;
        height: 80px;
        margin-bottom: 1.25rem;
    }
    
    .thank-you-modal-content h2 {
        font-size: 1.5rem;
    }
    
    .thank-you-message {
        font-size: 1rem;
    }
    
    .order-details {
        padding: 1.25rem;
    }
    
    .order-detail-row {
        padding: 0.625rem 0;
        font-size: 0.95rem;
    }
    
    .detail-value {
        font-size: 1rem;
    }
}

/* ============================================
   AMÉLIORATIONS UX MOBILE
   ============================================ */
@media (max-width: 768px) {
    /* Améliorer la lisibilité */
    .checkout-form input::placeholder,
    .checkout-form textarea::placeholder {
        color: #adb5bd;
        font-size: 0.95rem;
    }
    
    /* Focus visible */
    .checkout-form input:focus,
    .checkout-form textarea:focus {
        background: #fefce8;
    }
    
    /* Espacement entre sections */
    .checkout-cart-summary {
        margin-bottom: 1.5rem;
    }
    
    /* Animation douce */
    .checkout-item {
        animation: fadeInUp 0.4s ease-out;
    }
    
    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Scroll smooth */
    .checkout-page {
        scroll-behavior: smooth;
    }
    
    /* Améliorer les zones de touche */
    .qty-btn-checkout,
    .btn-remove-item,
    .btn-validate-promo,
    .checkout-form .btn-primary {
        -webkit-tap-highlight-color: rgba(45, 134, 89, 0.2);
        touch-action: manipulation;
    }
}

/* ============================================
   ORIENTATION PAYSAGE MOBILE
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
    .checkout-item {
        flex-direction: row;
    }
    
    .checkout-item-image {
        width: 120px;
        height: 120px;
        max-width: 120px;
    }
    
    .checkout-item-meta {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .checkout-quantity-controls {
        width: auto;
    }
    
    .item-total {
        width: auto;
        min-width: 100px;
    }
}
