/* ============================================
   MOBILE FIX FINAL - MAXIMUM PRIORITY
   Force responsive sur TOUS les téléphones
============================================ */

/* Base - Empêcher TOUT débordement horizontal */
html {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    min-height: 100vh !important;
    height: auto !important;
}

* {
    box-sizing: border-box !important;
}

/* ============================================
   RESPONSIVE MOBILE (< 768px)
============================================ */
@media (max-width: 768px) {

    /* Header */
    .header {
        display: grid !important;
        grid-template-columns: 1fr !important;
        padding: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .nav,
    .nav-right {
        display: none !important;
    }

    .logo {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .logo img {
        height: 38px !important;
        max-width: 100% !important;
    }

    /* Main Container */
    .main-container {
        display: block !important;
        padding: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        overflow: visible !important;
    }

    /* Form Card */
    .form-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 16px !important;
    }

    .form-header {
        padding: 20px 15px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .form-title {
        font-size: 18px !important;
        line-height: 1.4 !important;
        word-wrap: break-word !important;
    }

    .form-subtitle {
        font-size: 13px !important;
        word-wrap: break-word !important;
    }

    .form-body {
        padding: 18px 15px 20px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }

    /* Categories - SCROLL HORIZONTAL ICI UNIQUEMENT */
    .categories-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 20px !important;
        /* Hide scrollbar */
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    .categories-wrapper::-webkit-scrollbar {
        display: none !important;
    }

    .categories-grid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
        width: max-content !important;
        padding: 0 5px !important;
    }

    .category-item {
        width: 90px !important;
        min-width: 90px !important;
        max-width: 90px !important;
        flex-shrink: 0 !important;
        padding: 12px 8px !important;
        border-radius: 12px !important;
    }

    .category-icon-wrapper {
        width: 44px !important;
        height: 44px !important;
        margin: 0 auto 8px !important;
    }

    .category-icon {
        width: 32px !important;
        height: 32px !important;
        max-width: 100% !important;
    }

    .category-label {
        font-size: 12px !important;
        text-align: center !important;
        word-wrap: break-word !important;
    }

    /* Form Groups */
    .form-group {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 16px !important;
    }

    .form-label {
        font-size: 13px !important;
        margin-bottom: 8px !important;
        display: block !important;
    }

    /* Form Controls - CRITIQUE */
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        width: 100% !important;
        max-width: 100% !important;
        padding: 14px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        box-sizing: border-box !important;
        border: 1px solid rgba(255,255,255,0.3) !important;
    }

    textarea.form-control,
    textarea {
        min-height: 100px !important;
        resize: vertical !important;
    }

    /* Upload Zone */
    .upload-zone {
        width: 100% !important;
        max-width: 100% !important;
        padding: 30px 15px !important;
        border-radius: 14px !important;
        box-sizing: border-box !important;
    }

    .upload-icon {
        width: 36px !important;
        height: 36px !important;
    }

    .media-preview {
        width: 100% !important;
        max-width: 100% !important;
    }

    .media-preview img,
    .media-preview video {
        max-width: 100% !important;
        max-height: 200px !important;
        border-radius: 12px !important;
    }

    /* Date Picker */
    .date-input-wrapper {
        width: 100% !important;
    }

    .date-badge {
        padding: 12px 18px !important;
        font-size: 14px !important;
        max-width: 100% !important;
    }

    /* Music Section */
    .music-section {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px !important;
    }

    .music-header {
        padding: 16px !important;
        border-radius: 14px !important;
    }

    .music-list {
        width: 100% !important;
        max-width: 100% !important;
    }

    .music-list.open {
        max-height: none !important;
        overflow: visible !important;
    }

    .music-item {
        padding: 14px !important;
        margin-bottom: 8px !important;
        border-radius: 12px !important;
    }

    .music-icon-wrapper {
        width: 48px !important;
        height: 48px !important;
        flex-shrink: 0 !important;
    }

    .music-title {
        font-size: 14px !important;
    }

    /* Buttons - Full width with margin */
    .btn-submit,
    .btn-preview-mobile,
    .btn-generate,
    button[type="submit"] {
        width: calc(100% - 30px) !important;
        max-width: calc(100% - 30px) !important;
        padding: 16px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        box-sizing: border-box !important;
        min-height: 52px !important;
        touch-action: manipulation !important;
        display: block !important;
        margin-left: 15px !important;
        margin-right: 15px !important;
        margin-bottom: 12px !important;
        text-align: center !important;
        position: relative !important;
    }

    /* Exclude copy button from full width */
    button[onclick="copyShareLink()"] {
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        display: flex !important;
        flex-shrink: 0 !important;
    }

    .btn-submit {
        background: #00426B !important;
        color: white !important;
        border: none !important;
        font-weight: 600 !important;
        margin-top: 20px !important;
        margin-bottom: 12px !important;
    }

    .btn-preview-mobile {
        display: block !important;
        margin-top: 0 !important;
        margin-bottom: 20px !important;
        background-color: rgba(229, 201, 161, 1) !important;
        color: #005792 !important;
        font-weight: 600 !important;
        border: none !important;
        cursor: pointer !important;
    }

    /* Modal Generate Button - Fixed at bottom */
    .btn-generate-preview {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: calc(100% - 40px) !important;
        max-width: calc(100% - 40px) !important;
        margin: 20px 20px !important;
        padding: 16px !important;
        background: #00426B !important;
        color: white !important;
        border: none !important;
        font-weight: 600 !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        z-index: 10 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
        cursor: pointer !important;
        display: block !important;
        touch-action: manipulation !important;
    }

    /* Make sure the modal preview content has the button visible */
    .modal-overlay.active .btn-generate-preview {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 40px) !important;
        max-width: calc(100vw - 40px) !important;
        margin: 0 !important;
        z-index: 10000 !important;
    }

    /* Form buttons container */
    form {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* Hide desktop preview */
    .preview-card {
        display: none !important;
    }

    /* Modal Preview - FULL SCREEN MOBILE */
    .modal-overlay {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.95) !important;
        z-index: 9999 !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    .modal-overlay.active {
        display: flex !important;
    }

    .modal-content {
        background: white !important;
        border-radius: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-header {
        padding: 15px 20px !important;
        border-bottom: 1px solid #e5e7eb !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        background: white !important;
    }

    .modal-title {
        font-size: 18px !important;
        font-weight: 700 !important;
        color: #005792 !important;
    }

    .btn-close-modal {
        background: none !important;
        border: none !important;
        font-size: 32px !important;
        color: #666 !important;
        cursor: pointer !important;
        padding: 0 !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }

    .modal-body {
        padding: 0 !important;
        padding-bottom: 80px !important;
        flex: 1 !important;
        overflow-y: auto !important;
        background: white !important;
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
    }

    /* Preview Content - FULL SCREEN BACKGROUND */
    .preview-content {
        background: #f3f4f6 !important;
        border-radius: 0 !important;
        padding: 30px 20px !important;
        min-height: 100% !important;
        height: 100% !important;
        width: 100% !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: center !important;
        overflow-y: auto !important;
        position: relative !important;
        transition: background 0.3s ease !important;
    }

    /* When preview has content - FULL SCREEN background image */
    .preview-content.has-content {
        background-image: url('/images/clientIamges/Container.png') !important;
        background-position: center center !important;
        background-size: cover !important;
        background-repeat: no-repeat !important;
        border-radius: 0 !important;
    }

    .preview-content.has-content::before {
        content: '' !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.1) !important;
        border-radius: 0 !important;
        pointer-events: none !important;
    }

    .preview-content > * {
        position: relative !important;
        z-index: 1 !important;
    }

    /* Preview Empty State */
    .preview-empty {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        color: #9ca3af !important;
        padding: 40px 20px !important;
    }

    .preview-empty-icon {
        width: 80px !important;
        height: 80px !important;
        margin-bottom: 20px !important;
        opacity: 0.5 !important;
    }

    .preview-empty p {
        font-size: 14px !important;
        line-height: 1.6 !important;
        margin: 2px 0 !important;
    }

    /* Char counters */
    .char-counter {
        font-size: 12px !important;
        text-align: right !important;
        margin-top: 5px !important;
    }

    /* Scroll indicator */
    .scroll-indicator {
        display: flex !important;
        justify-content: center !important;
        gap: 4px !important;
        margin-top: 10px !important;
    }

    .scroll-indicator span {
        width: 6px !important;
        height: 6px !important;
        background: rgba(255,255,255,0.5) !important;
        border-radius: 50% !important;
    }
}

/* ============================================
   SMALL MOBILE (< 480px)
============================================ */
@media (max-width: 480px) {
    .main-container {
        padding: 10px !important;
    }

    .form-header {
        padding: 18px 12px !important;
    }

    .form-title {
        font-size: 17px !important;
    }

    .form-subtitle {
        font-size: 12px !important;
    }

    .form-body {
        padding: 16px 12px !important;
    }

    .category-item {
        width: 75px !important;
        min-width: 75px !important;
        max-width: 75px !important;
        padding: 10px 6px !important;
    }

    .category-icon-wrapper {
        width: 40px !important;
        height: 40px !important;
    }

    .category-icon {
        width: 28px !important;
        height: 28px !important;
    }

    .category-label {
        font-size: 11px !important;
    }

    .form-control,
    input,
    textarea {
        padding: 13px !important;
        font-size: 16px !important;
    }

    .btn-submit,
    .btn-preview-mobile {
        padding: 14px !important;
        font-size: 15px !important;
    }
}

/* ============================================
   TOUCH DEVICES
============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Minimum touch target sizes */
    .category-item,
    .music-item,
    .btn-submit,
    .btn-preview-mobile,
    button[type="submit"],
    button[type="button"] {
        min-height: 44px !important;
        min-width: 44px !important;
        touch-action: manipulation !important;
    }

    /* Copy button specific touch size */
    button[onclick="copyShareLink()"] {
        min-height: 48px !important;
        min-width: 48px !important;
        width: 48px !important;
        height: 48px !important;
    }

    /* Prevent iOS zoom on input focus */
    input,
    textarea,
    select,
    .form-control {
        font-size: 16px !important;
    }
}



