/**
 * Styles pour le dashboard Fidélité - Design La Mémée
 * Couleurs: #142451 (bleu), #F0B9F0 (rose), #F2E2D0 (crème)
 */

/* ========================================
   WRAPPER PRINCIPAL
   ======================================== */
.lp-loyalty-dashboard {
    font-family: inherit;
    color: #142451;
}

.lp-loyalty-dashboard h2 {
    color: #142451;
    font-weight: 700;
    margin: 30px 0 20px;
    font-size: 22px;
}

.lp-loyalty-dashboard h2:first-child {
    margin-top: 0;
}

/* ========================================
   LIGNE DU HAUT : SOLDE + À NOTER CÔTE À CÔTE
   ======================================== */
.lp-loyalty-dashboard .lp-top-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 24px;
    margin-bottom: 30px;
}

.lp-loyalty-dashboard .lp-top-row .lp-balance-card {
    flex: 1 1 55%;
    min-width: 300px;
    margin-bottom: 0;
}

.lp-loyalty-dashboard .lp-top-row .lp-notice {
    flex: 1 1 35%;
    min-width: 260px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

/* ========================================
   CARTE DU SOLDE
   ======================================== */
.lp-loyalty-dashboard .lp-balance-card {
    background: #FCF7F2;
    border: 2px solid #F0B9F0;
    border-radius: 20px;
    padding: 35px 30px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(20, 36, 81, 0.1);
    animation: lpFadeInUp 0.5s ease-out;
}

.lp-loyalty-dashboard .lp-balance-card h2 {
    color: #142451;
    font-size: 20px;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
}

.lp-loyalty-dashboard .lp-balance-number {
    font-size: 3em;
    font-weight: 700;
    margin: 10px 0 20px;
    color: #142451;
    line-height: 1;
}

.lp-loyalty-dashboard .lp-balance-card p {
    color: #142451;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

.lp-loyalty-dashboard .lp-balance-card strong {
    color: #142451;
    font-weight: 700;
}

/* ========================================
   ENCART "À NOTER"
   ======================================== */
.lp-loyalty-dashboard .lp-notice {
    background: #F2E2D0;
    border: 2px solid #F0B9F0;
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 30px;
    color: #142451;
}

.lp-loyalty-dashboard .lp-notice p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.lp-loyalty-dashboard .lp-notice strong {
    color: #142451;
}

/* ========================================
   MESSAGES (succès / erreur)
   ======================================== */
.lp-loyalty-dashboard .woocommerce-message,
.lp-loyalty-dashboard .woocommerce-info {
    background: #F2E2D0 !important;
    border: 2px solid #F0B9F0 !important;
    color: #142451 !important;
    border-radius: 12px !important;
    padding: 15px 20px !important;
    margin-bottom: 20px !important;
}

.lp-loyalty-dashboard .woocommerce-message::before,
.lp-loyalty-dashboard .woocommerce-info::before {
    color: #142451 !important;
}

.lp-loyalty-dashboard .woocommerce-error {
    background: #fff5f5 !important;
    border: 2px solid #e74c3c !important;
    color: #142451 !important;
    border-radius: 12px !important;
    padding: 15px 20px !important;
    margin-bottom: 20px !important;
}

/* ========================================
   FORMULAIRE DE CONVERSION
   ======================================== */
.lp-loyalty-dashboard .lp-redeem-form {
    background: #fff;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(20, 36, 81, 0.08);
    margin: 20px 0 30px;
}

.lp-loyalty-dashboard .lp-redeem-form p {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.lp-loyalty-dashboard .lp-redeem-form label {
    color: #142451;
    font-weight: 600;
    font-size: 15px;
    margin: 0;
}

.lp-loyalty-dashboard .lp-redeem-form select {
    flex: 1;
    min-width: 220px;
    padding: 12px 16px;
    border: 2px solid #142451;
    border-radius: 12px;
    font-size: 15px;
    background: #fff;
    color: #142451;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lp-loyalty-dashboard .lp-redeem-form select:focus {
    outline: none;
    border-color: #F0B9F0;
    box-shadow: 0 0 0 4px rgba(240, 185, 240, 0.2);
}

.lp-loyalty-dashboard .lp-redeem-form button,
.lp-loyalty-dashboard .lp-redeem-form .button {
    background: #142451 !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 28px !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s ease !important;
}

.lp-loyalty-dashboard .lp-redeem-form button:hover,
.lp-loyalty-dashboard .lp-redeem-form .button:hover {
    background: #F0B9F0 !important;
    color: #142451 !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(240, 185, 240, 0.4) !important;
}

/* Message "il vous manque N points" */
.lp-loyalty-dashboard .lp-missing-points {
    background: #fff;
    border-radius: 15px;
    padding: 20px 25px;
    box-shadow: 0 5px 20px rgba(20, 36, 81, 0.08);
    color: #142451;
    font-size: 15px;
    margin: 20px 0 30px;
}

.lp-loyalty-dashboard .lp-missing-points strong {
    color: #142451;
    font-weight: 700;
}

/* ========================================
   HISTORIQUE — bloc repliable
   ======================================== */
.lp-loyalty-dashboard .lp-history-toggle {
    margin-top: 30px;
}

.lp-loyalty-dashboard .lp-history-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
    background: #fff;
    border: 2px solid #142451;
    border-radius: 12px;
    padding: 14px 20px;
    color: #142451;
    font-weight: 700;
    font-size: 16px;
    transition: background 0.15s ease;
    user-select: none;
}

/* Masquer le marqueur natif du <summary> (triangle) */
.lp-loyalty-dashboard .lp-history-summary::-webkit-details-marker { display: none; }
.lp-loyalty-dashboard .lp-history-summary::marker { content: ''; }

.lp-loyalty-dashboard .lp-history-summary:hover {
    background: rgba(242, 226, 208, 0.45);
}

.lp-loyalty-dashboard .lp-history-chevron {
    display: inline-flex;
    color: #142451;
    transition: transform 0.2s ease;
}

.lp-loyalty-dashboard .lp-history-toggle[open] .lp-history-chevron {
    transform: rotate(180deg);
}

.lp-loyalty-dashboard .lp-history-content {
    padding-top: 16px;
}

/* Animation de déroulement/enroulement pilotée en JS via max-height + opacity.
   Réversible et rejouée à chaque fois (contrairement à l'animation native).
   padding-top porté par le contenu (et non margin) pour que scrollHeight soit
   mesuré correctement et éviter tout saut au repli. */
.lp-loyalty-dashboard .lp-history-anim {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-6px);
    transition:
        max-height 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.35s ease,
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: max-height, opacity;
}

.lp-loyalty-dashboard .lp-history-anim.is-open {
    opacity: 1;
    transform: translateY(0);
}

.lp-loyalty-dashboard .lp-history-toggle[open] .lp-history-summary {
    background: rgba(242, 226, 208, 0.45);
}

@media (prefers-reduced-motion: reduce) {
    .lp-loyalty-dashboard .lp-history-anim {
        transition: none;
    }
    .lp-loyalty-dashboard .lp-history-chevron {
        transition: none;
    }
}

/* ========================================
   HISTORIQUE — tableau
   ======================================== */
.lp-loyalty-dashboard table.lp-history {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(20, 36, 81, 0.08);
}

.lp-loyalty-dashboard table.lp-history thead th {
    background: #F2E2D0;
    color: #142451;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lp-loyalty-dashboard table.lp-history td {
    padding: 15px;
    border-bottom: 1px solid rgba(20, 36, 81, 0.08);
    color: #142451;
    font-size: 14px;
}

.lp-loyalty-dashboard table.lp-history tbody tr:last-child td {
    border-bottom: none;
}

.lp-loyalty-dashboard table.lp-history tbody tr:hover td {
    background: rgba(242, 226, 208, 0.3);
}

.lp-loyalty-dashboard .lp-points-pos {
    color: #2e7d32;
    font-weight: 700;
}

.lp-loyalty-dashboard .lp-points-neg {
    color: #c62828;
    font-weight: 700;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes lpFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 600px) {
    .lp-loyalty-dashboard .lp-top-row {
        flex-direction: column;
        gap: 16px;
    }

    .lp-loyalty-dashboard .lp-top-row .lp-balance-card,
    .lp-loyalty-dashboard .lp-top-row .lp-notice {
        flex: 1 1 100%;
    }

    .lp-loyalty-dashboard .lp-balance-card {
        padding: 25px 20px;
    }

    .lp-loyalty-dashboard .lp-balance-number {
        font-size: 2.2em;
    }

    .lp-loyalty-dashboard .lp-redeem-form p {
        flex-direction: column;
        align-items: stretch;
    }

    .lp-loyalty-dashboard .lp-redeem-form select,
    .lp-loyalty-dashboard .lp-redeem-form button {
        width: 100%;
        min-width: 0;
    }

    .lp-loyalty-dashboard table.lp-history thead {
        display: none;
    }

    .lp-loyalty-dashboard table.lp-history,
    .lp-loyalty-dashboard table.lp-history tbody,
    .lp-loyalty-dashboard table.lp-history tr,
    .lp-loyalty-dashboard table.lp-history td {
        display: block;
        width: 100%;
    }

    .lp-loyalty-dashboard table.lp-history tr {
        border-bottom: 1px solid rgba(20, 36, 81, 0.1);
        padding: 10px 0;
    }

    .lp-loyalty-dashboard table.lp-history td {
        border: none;
        padding: 6px 15px;
        text-align: left !important;
    }

    .lp-loyalty-dashboard table.lp-history td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #142451;
        display: inline-block;
        width: 80px;
        margin-right: 10px;
        text-transform: uppercase;
        font-size: 12px;
    }
}

/* ========================================
   ENCART GÉNÉRATION AUTOMATIQUE
   ======================================== */
.lp-loyalty-dashboard .lp-auto-voucher-info {
    background: #FCF7F2;
    border: 1px solid rgba(240, 185, 240, 0.5);
    border-radius: 14px;
    padding: 18px 22px;
    margin-bottom: 25px;
    color: #142451;
}

.lp-loyalty-dashboard .lp-auto-voucher-info p {
    margin: 0 0 8px;
    font-size: 15px;
    line-height: 1.6;
}

.lp-loyalty-dashboard .lp-auto-voucher-info p:last-child {
    margin-bottom: 0;
}

.lp-loyalty-dashboard .lp-missing-points {
    color: #142451;
    font-size: 14px;
}

/* ========================================
   CARTES DE BONS DE RÉDUCTION
   ======================================== */
.lp-loyalty-dashboard h3 {
    color: #142451;
    font-weight: 700;
    font-size: 18px;
    margin: 24px 0 16px;
}

.lp-vouchers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 10px;
}

.lp-voucher-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #fff;
    border: 2px solid #142451;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 6px 18px rgba(20, 36, 81, 0.07);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lp-voucher-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(20, 36, 81, 0.14);
}

.lp-voucher-card.is-used {
    border-color: rgba(20, 36, 81, 0.15);
    background: #faf8f5;
    opacity: 0.8;
}

/* Ligne du haut : icône + montant + badge */
.lp-voucher-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lp-voucher-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #142451;
    color: #F0B9F0;
}

.lp-voucher-icon svg { display: block; }

.lp-voucher-card.is-used .lp-voucher-icon {
    background: rgba(20, 36, 81, 0.35);
    color: #fff;
}

.lp-voucher-amount {
    flex: 1;
    font-size: 22px;
    font-weight: 700;
    color: #142451 !important;
    line-height: 1.1;
}

.lp-voucher-amount .woocommerce-Price-amount,
.lp-voucher-amount bdi {
    color: #142451 !important;
}

.lp-voucher-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.lp-badge-available {
    background: rgba(76, 175, 80, 0.14);
    color: #2e7d32;
}

.lp-badge-available svg { color: #2e7d32; }

.lp-badge-used {
    background: rgba(20, 36, 81, 0.08);
    color: #888;
}

/* Code en pleine largeur, bien séparé.
   On neutralise tout style de bouton hérité du thème WooCommerce. */
.lp-loyalty-dashboard .lp-voucher-code,
.lp-loyalty-dashboard button.lp-voucher-code {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    background: rgba(242, 226, 208, 0.45) !important;
    border: 1px dashed #142451 !important;
    border-radius: 10px !important;
    cursor: pointer;
    transition: background 0.15s ease;
    box-shadow: none !important;
    text-transform: none !important;
    font-weight: 400;
    min-height: 0;
    line-height: 1.2;
}

.lp-loyalty-dashboard button.lp-voucher-code:hover {
    transform: none;
}

.lp-loyalty-dashboard .lp-voucher-code:hover {
    background: rgba(242, 226, 208, 0.85) !important;
}

.lp-voucher-code-text {
    font-family: monospace;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #142451 !important;
    text-transform: uppercase;
}

.lp-voucher-copy-hint {
    flex-shrink: 0;
    display: inline-flex;
    color: #142451;
    opacity: 0.55;
}

.lp-voucher-code:hover .lp-voucher-copy-hint { opacity: 1; }

.lp-voucher-card.is-used .lp-voucher-code {
    border-color: rgba(20, 36, 81, 0.2);
    cursor: default;
}
