/* ========================================
   VARIABLES CSS
   ======================================== */
:root {
    --primary-color: #3b82f6;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --border-color: #e5e7eb;
    --background-light: #f9fafb;
    --font-family: 'Inter', sans-serif;
}

/* ========================================
   STRUCTURE DE BASE
   ======================================== */
.lcgc-giftcard {
    display: inline-block;
    position: relative;
}

.lcgc-giftcard__open {
    background-color: #3b82f6;
    border: none;
    border-radius: 999px;
    color: #ffffff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.875rem 1.75rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.lcgc-giftcard__open:hover,
.lcgc-giftcard__open:focus {
    background-color: #2563eb;
    transform: translateY(-1px);
}

.lcgc-giftcard__overlay {
    align-items: center;
    background: rgba(17, 24, 39, 0.85);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 2rem;
    position: fixed;
    z-index: 999;
    pointer-events: none; /* Permet aux clics de passer à travers */
    opacity: 0; /* Initial invisible */
    visibility: hidden; /* Initial caché */
    transition: opacity 0.3s ease, visibility 0.3s ease; /* Animation douce */
}

.lcgc-giftcard__overlay.is-open {
    display: flex;
    opacity: 1; /* CORRECTION: Rendre visible */
    visibility: visible; /* CORRECTION: Rendre accessible */
    pointer-events: auto; /* CORRECTION: Permettre les interactions (clics, saisie) */
}

body.lcgc-modal-open {
    overflow: hidden;
}

.lcgc-giftcard__modal {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(30, 64, 175, 0.45);
    max-height: calc(100vh - 4rem);
    max-width: 1200px;
    overflow: hidden;
    position: relative;
    pointer-events: auto; /* Garantit que le contenu est interactif */
    width: 100%;
}


.lcgc-giftcard__close {
    appearance: none;
    background: rgba(15, 23, 42, 0.75);
    border: none;
    border-radius: 999px;
    color: #f8fafc;
    cursor: pointer;
    font-size: 1.5rem;
    height: 2.5rem;
    line-height: 1;
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 2.5rem;
}

.lcgc-giftcard__close:hover,
.lcgc-giftcard__close:focus {
    background: #0f172a;
}

.lcgc-alert {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #7f1d1d;
    padding: 1rem;
    margin: 1rem 0;
}.lcgc-connect,
.lcgc-checkout {
    margin: 1.5rem 0;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
}

.lcgc-connect__badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.lcgc-connect__badge--success {
    background: #dcfce7;
    color: #166534;
}

.lcgc-connect__badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.lcgc-connect__button,
.lcgc-checkout__button {
    background-color: #3b82f6;
    border: none;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.lcgc-connect__button:hover,
.lcgc-connect__button:focus,
.lcgc-checkout__button:hover,
.lcgc-checkout__button:focus {
    background-color: #2563eb;
    transform: translateY(-1px);
}

.lcgc-connect__button:disabled,
.lcgc-checkout__button:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.lcgc-connect__message,
.lcgc-checkout__message {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #374151;
}

/* ========================================
   MEDIA QUERIES RESPONSIVE MOBILE
   ======================================== */

/* Tablettes et petits écrans (< 900px) */
@media (max-width: 900px) {
    .lcgc-giftcard__overlay {
        padding: 1rem;
    }

    .lcgc-giftcard__modal {
        max-width: 95%;
        max-height: 92vh;
    }

    .lcgc-giftcard__close {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.75rem;
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* Smartphones en mode paysage et portrait (< 768px) */
@media (max-width: 768px) {
    .lcgc-giftcard__overlay {
        padding: 0.5rem;
        align-items: flex-start;
    }

    .lcgc-giftcard__modal {
        max-width: 95%;
        width: 95%;
        max-height: 95vh;
        margin-top: 0.5rem;
        border-radius: 12px;
    }

    .lcgc-giftcard__close {
        width: 3rem;
        height: 3rem;
        font-size: 2rem;
        top: 0.5rem;
        right: 0.5rem;
        background: rgba(15, 23, 42, 0.85);
        z-index: 1000;
    }

    .lcgc-giftcard__close:hover,
    .lcgc-giftcard__close:focus {
        background: #0f172a;
        transform: scale(1.05);
    }

    /* Adapter le bouton d'ouverture pour mobile */
    .lcgc-giftcard__open {
        width: 100%;
        max-width: 100%;
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
    }
}

/* Très petits smartphones (< 480px) */
@media (max-width: 480px) {
    .lcgc-giftcard__overlay {
        padding: 0.25rem;
    }

    .lcgc-giftcard__modal {
        max-width: 98%;
        width: 98%;
        max-height: 97vh;
        border-radius: 8px;
    }

    .lcgc-giftcard__close {
        width: 3.25rem;
        height: 3.25rem;
        font-size: 2.25rem;
        top: 0.25rem;
        right: 0.25rem;
    }

    /* Messages d'alerte adaptés */
    .lcgc-alert {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Boutons adaptés au tactile */
    .lcgc-connect__button,
    .lcgc-checkout__button {
        padding: 1rem 1.25rem;
        font-size: 1rem;
        width: 100%;
    }
}

/* Mode paysage pour smartphones (hauteur < 500px) */
@media (max-height: 500px) and (orientation: landscape) {
    .lcgc-giftcard__overlay {
        align-items: flex-start;
        padding: 0.25rem;
    }

    .lcgc-giftcard__modal {
        max-height: 98vh;
        margin-top: 0.25rem;
    }

    .lcgc-giftcard__close {
        top: 0.25rem;
        right: 0.25rem;
    }
}

/* ========================================
   STRUCTURE MODALE INTERNE
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.main-container {
    background-color: transparent;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    max-height: 90vh;
    gap: 30px;
    overflow-y: auto;
    box-shadow: none;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    pointer-events: auto;
}

.gift-card-form-wrapper {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 400px;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--secondary-color);
    z-index: 20;
    transition: color 0.2s;
}

.close-button:hover {
    color: var(--danger-color);
}

/* ========================================
   STYLES FORMULAIRE
   ======================================== */
.lcgc-modal-root {
    font-family: var(--font-family);
    background-color: transparent;
    margin: 0;
    padding: 0;
    font-size: 14px;
}

.title {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label,
legend {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1f2937;
    font-size: 0.95em;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.optional-label {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.85em;
    font-style: italic;
}

input[type="text"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.2s;
    font-size: 0.95em;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-color);
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.half-width {
    width: 48%;
    display: inline-block;
}

.form-group.half-width:first-child {
    margin-right: 4%;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 5px;
    margin-top: 10px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

/* ========================================
   TOGGLE SWITCH
   ======================================== */
.toggle-group {
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-input {
    display: none;
}

.toggle-label {
    cursor: pointer;
    display: inline-block;
    width: 50px;
    height: 28px;
    background-color: #ccc;
    border-radius: 14px;
    position: relative;
    transition: background-color 0.2s;
}

.toggle-label:after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-input:checked + .toggle-label {
    background-color: var(--success-color);
}

.toggle-input:checked + .toggle-label:after {
    transform: translateX(22px);
}

.toggle-status {
    font-weight: 700;
    color: #4b5563;
}

/* ========================================
   BOUTONS
   ======================================== */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.2s, opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.primary:hover:not(:disabled) {
    background-color: #2563eb;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.btn.secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn.secondary:hover:not(:disabled) {
    background-color: #4b5563;
}

.btn.success {
    background-color: var(--success-color);
    color: white;
}

.btn.success:hover:not(:disabled) {
    background-color: #059669;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.action-group {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
}

#step1 button,
#paymentFormContent .action-group button {
    flex-grow: 1;
}

#paymentFormContent .action-group button:first-child {
    margin-right: 15px;
}

/* ========================================
   NAVIGATION PAR ÉTAPES
   ======================================== */
.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

.step-content h2 {
    font-size: 1.2em;
    margin-bottom: 15px;
    font-weight: 600;
}

.progress-bar-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.progress-step {
    padding: 4px 8px;
    font-weight: 600;
    color: var(--secondary-color);
    position: relative;
    opacity: 0.5;
    flex-grow: 1;
    text-align: center;
    font-size: 0.9em;
}

.progress-step.active {
    color: var(--primary-color);
    opacity: 1;
}

.progress-step.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px;
}

/* ========================================
   FIELDSETS ET SUPPLÉMENTS
   ======================================== */
fieldset {
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
}

legend {
    width: auto;
    padding: 0 8px;
    font-size: 1em;
    font-weight: 600;
    color: var(--primary-color);
}

.supplements-fieldset {
    padding: 12px 15px;
}

.supplement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 3px 0;
}

.supplement-item label {
    margin-bottom: 0;
    font-weight: 400;
    flex-grow: 1;
    padding-right: 15px;
    font-size: 0.9em;
}

.supplement-item select {
    width: 80px;
}

/* ========================================
   MONTANT TOTAL
   ======================================== */
.total-amount-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 2px dashed var(--border-color);
}

.total-label {
    font-size: 1.1em;
    font-weight: 600;
    color: #1f2937;
}

.amount {
    font-size: 1.8em;
    font-weight: 900;
    color: var(--success-color);
}

/* ========================================
   APERÇU DU BON CADEAU
   ======================================== */
.preview-wrapper {
    flex-shrink: 0;
    width: 100%;
    padding-bottom: 30px;
    order: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.preview-card {
    width: 600px;
    height: 400px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    background-size: cover;
    background-position: center;
    position: relative;
    transition: background-image 0.5s ease;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
}

.card-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 30px;
    box-sizing: border-box;
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.25) 30%,
            rgba(0, 0, 0, 0.25) 70%,
            rgba(0, 0, 0, 0) 100%);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-main-body {
    display: flex;
    flex-grow: 1;
    align-items: stretch;
    justify-content: center;
    position: relative;
}

.card-left-column {
    flex: 1;
    padding-right: 15px;
    border-right: 2px dashed rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.card-right-column {
    flex: 2;
    padding-left: 20px;
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-message-content {
    font-style: italic;
    font-size: 1em;
    text-align: left;
    padding: 15px;
    max-height: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    line-clamp: 6;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.card-header {
    min-height: 20px;
}

.card-header h3 {
    font-size: 1.4em;
    margin: 0 0 15px 0;
    font-weight: 700;
    text-align: center;
    border-bottom: none;
    padding-bottom: 5px;
    font-family: 'Brush Script MT', cursive;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.card-details p {
    margin: 5px 0;
    font-size: 0.95em;
    font-weight: 400;
}

.card-details span {
    font-weight: 600;
}

.value-info {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.7);
}

.value-info span:first-child {
    font-size: 0.85em;
    font-weight: 400;
}

#previewValue,
[id$="-previewValue"] {
    font-size: 1.2em;
    font-weight: 900;
    color: #ffeb3b !important;
    display: block;
    margin-top: 5px;
}

.card-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.7);
    padding-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.75em;
    min-height: auto;
}

#previewReference,
[id$="-previewReference"] {
    font-size: 1.1em;
    opacity: 1;
    padding-bottom: 0;
    margin: 0;
    white-space: nowrap;
}

#previewReference span,
[id$="-previewReference"] span,
[id$="-refCode"] {
    font-weight: 900;
    color: #ffeb3b !important;
    font-size: 1em;
}

.card-footer p {
    font-size: 1.1em;
    margin: 0;
    white-space: nowrap;
    font-weight: 600;
}

/* ========================================
   SÉLECTION DE THÉMATIQUE
   ======================================== */
.theme-select {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-option {
    flex: 1 1 100px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px;
    transition: all 0.2s;
}

.theme-option.selected {
    border-color: var(--primary-color);
    background-color: #e0f2fe;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
}

.theme-option img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 5px;
}

/* ========================================
   MESSAGES ET NOTIFICATIONS
   ======================================== */
.success-message {
    text-align: center;
    padding: 40px 20px;
    border: 2px solid var(--success-color);
    border-radius: 12px;
    background-color: #ecfdf5;
    color: #065f46;
    font-size: 1.1em;
    font-weight: 500;
    line-height: 1.5;
    margin-top: 20px;
}

.success-message h2 {
    color: var(--success-color);
    margin-top: 0;
    font-size: 1.8em;
}

.success-message p {
    margin: 15px 0;
}

.success-icon {
    font-size: 3em;
    color: var(--success-color);
    margin-bottom: 15px;
    display: block;
}

.hidden {
    display: none !important;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    border-radius: 12px;
    transition: opacity 0.3s;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   STRIPE PAYMENT
   ======================================== */
#stripe-payment-element {
    margin: 20px 0;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    min-height: 50px;
}

.note {
    color: var(--danger-color);
    font-size: 0.9em;
    margin-top: 10px;
    padding: 10px;
    border: 1px dashed var(--danger-color);
    border-radius: 4px;
}

.security-note {
    font-size: 0.8em;
    text-align: right;
    color: var(--secondary-color);
    margin-top: 5px;
}

.error-message {
    color: var(--danger-color);
    font-weight: 700;
    margin-top: 10px;
    text-align: center;
}

/* ========================================
   MEDIA QUERIES - DESKTOP
   ======================================== */
@media (min-width: 900px) {
    .main-container {
        flex-direction: row;
        max-height: 85vh;
        overflow-y: hidden;
        background-color: white;
    }

    .gift-card-form-wrapper {
        overflow-y: auto;
    }

    .preview-wrapper {
        width: 650px;
        order: 2;
        padding-top: 40px;
        background-color: transparent !important;
    }
}

/* ========================================
   MEDIA QUERIES - TABLETTE ET MOBILE
   ======================================== */
@media (max-width: 899px) {
    .main-container {
        max-width: 95%;
        width: 95%;
        background-color: white;
        padding: 15px;
    }

    .gift-card-form-wrapper {
        min-width: auto;
        width: 100%;
        padding: 20px;
    }

    /* CRITIQUE : Garder la carte à 600x400px pour cohérence aperçu/PDF */
    .preview-wrapper {
        overflow-x: auto;
        display: flex;
        justify-content: center;
    }

    .preview-card {
        /* Dimensions fixes pour cohérence desktop/mobile/PDF */
        width: 600px !important;
        height: 400px !important;
        /* Zoom visuel seulement sur petits écrans */
        transform: scale(0.95);
        transform-origin: center center;
    }
}

@media (max-width: 768px) {
    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
    }

    .main-container {
        max-width: 95%;
        width: 95%;
        padding: 10px;
        margin-top: 0.5rem;
    }

    .gift-card-form-wrapper {
        min-width: auto;
        width: 100%;
        padding: 15px;
    }

    .close-button {
        width: 3rem;
        height: 3rem;
        font-size: 2rem;
        top: 0.5rem;
        right: 0.5rem;
        background: rgba(15, 23, 42, 0.85);
    }

    /* CRITIQUE : Zoom visuel pour adapter à l'écran mobile */
    .preview-card {
        width: 600px !important;
        height: 400px !important;
        transform: scale(0.75);
        transform-origin: center center;
    }
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        margin-bottom: 15px;
    }

    .half-width {
        width: 100%;
        margin-right: 0 !important;
        display: block;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0.25rem;
    }

    .main-container {
        max-width: 98%;
        width: 98%;
        padding: 8px;
        border-radius: 8px;
    }

    .gift-card-form-wrapper {
        min-width: auto;
        width: 100%;
        padding: 12px;
    }

    .close-button {
        width: 3.25rem;
        height: 3.25rem;
        font-size: 2.25rem;
    }

    /* CRITIQUE : Zoom plus important pour très petits écrans */
    .preview-card {
        width: 600px !important;
        height: 400px !important;
        transform: scale(0.6);
        transform-origin: center center;
    }
}
.lcgc-checkout-help {
    margin: 0;
    font-size: 0.95rem;
    color: #1f2937;
}

