/* ============================================
   MathPay v3.1 — Styles Frontend
   ============================================ */

/* ---- Formulaire de validation (shortcode) ---- */
.mathpay-validation-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}
.mathpay-validation-container h2 {
    margin: 0 0 0.5rem;
    color: #1a1a2e;
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
}
.mathpay-description {
    text-align: center;
    color: #6b7280;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}
.mathpay-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.mathpay-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.mathpay-form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}
.mathpay-form-group .required { color: #ef4444; }
.mathpay-form-group input {
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #fafafa;
}
.mathpay-form-group input:focus {
    outline: none;
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.mathpay-btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.mathpay-btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
}
.mathpay-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.mathpay-btn-primary:active { transform: translateY(0); }
.mathpay-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}
.mathpay-result {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: mathpaySlideIn 0.3s ease;
}
@keyframes mathpaySlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.mathpay-result.mathpay-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.mathpay-result.mathpay-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.mathpay-result .mathpay-result-title { font-weight: 700; margin-bottom: 0.25rem; }
.mathpay-result .mathpay-result-details { font-size: 0.85rem; opacity: 0.9; }
.mathpay-alert { padding: 1rem 1.25rem; border-radius: 8px; font-size: 0.95rem; }
.mathpay-alert-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}
.mathpay-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: mathpaySpin 0.8s linear infinite;
}
@keyframes mathpaySpin { to { transform: rotate(360deg); } }

/* ============================================
   PASSERELLE WOOCOMMERCE — Checkout
   ============================================ */

/* Description */
.mathpay-gateway-desc {
    margin-bottom: 1.25rem;
    color: #4b5563;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ---- Grille d'opérateurs (multi-opérateurs) ---- */
.mathpay-operators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.mathpay-operator-card {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.25s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}
.mathpay-operator-card:hover {
    border-color: #a5b4fc;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

/* Carte sélectionnée */
.mathpay-operator-card.mathpay-op-selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 6px 20px rgba(99, 102, 241, 0.15);
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}

/* Titre opérateur */
.mathpay-op-card-title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}

/* Image opérateur */
.mathpay-op-card-image {
    display: block;
    max-width: 120px;
    max-height: 80px;
    margin: 0 auto 0.75rem;
    border-radius: 8px;
    object-fit: contain;
}

/* Description opérateur */
.mathpay-op-card-desc {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* Instructions opérateur (cachées par défaut, affichées à la sélection) */
.mathpay-op-card-instructions {
    display: none;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #c7d2fe;
}
.mathpay-op-card-instructions .mathpay-instructions {
    margin-bottom: 0.75rem;
}
.mathpay-op-card-instructions .mathpay-instructions-list li {
    font-size: 0.82rem;
}

/* USSD opérateur (caché par défaut, affiché à la sélection) */
.mathpay-op-card-ussd {
    display: none;
    margin-top: 0.5rem;
}
.mathpay-op-card-ussd .mathpay-ussd-block {
    margin-bottom: 0;
}
.mathpay-op-card-ussd .mathpay-ussd-code {
    font-size: 1.5rem;
}

/* Bouton "Utiliser cette méthode" */
.mathpay-op-select-btn {
    display: block;
    width: 100%;
    padding: 0.65rem 1rem;
    margin-top: 0.75rem;
    border: 2px solid #6366f1;
    border-radius: 8px;
    background: #ffffff;
    color: #6366f1;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.mathpay-op-select-btn:hover {
    background: #6366f1;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Bouton sélectionné */
.mathpay-op-select-btn.mathpay-op-btn-selected {
    background: #6366f1;
    color: #ffffff;
    border-color: #4f46e5;
    cursor: default;
}

/* Conteneur du champ transaction (affiché après sélection) */
#mathpay-txn-field-operator {
    display: none;
    margin-top: 1rem;
}

/* ---- Layout classique (sans opérateurs) ---- */

/* Bloc instructions */
.mathpay-instructions {
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.mathpay-instructions-title {
    margin: 0 0 0.75rem;
    color: #1e40af;
    font-size: 1rem;
    font-weight: 700;
}
.mathpay-instructions-list {
    margin: 0;
    padding-left: 1.5rem;
    counter-reset: mathpay-step;
    list-style: none;
}
.mathpay-instructions-list li {
    position: relative;
    padding: 0.5rem 0 0.5rem 0.75rem;
    color: #1e3a5f;
    font-size: 0.88rem;
    line-height: 1.5;
    border-left: 3px solid #93c5fd;
    margin-bottom: 0.5rem;
}
.mathpay-instructions-list li:last-child { margin-bottom: 0; }
.mathpay-instructions-list li::before {
    counter-increment: mathpay-step;
    content: counter(mathpay-step);
    position: absolute;
    left: -1.75rem;
    top: 0.45rem;
    width: 1.25rem;
    height: 1.25rem;
    background: #3b82f6;
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Code USSD */
.mathpay-ussd-block {
    text-align: center;
    padding: 1rem;
    background: #fef3c7;
    border: 2px dashed #f59e0b;
    border-radius: 10px;
    margin-bottom: 1.25rem;
}
.mathpay-ussd-label {
    display: block;
    font-size: 0.8rem;
    color: #92400e;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}
.mathpay-ussd-code {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: #78350f;
    letter-spacing: 0.08em;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
    transition: transform 0.15s ease;
}

/* Champ ID de transaction */
.mathpay-txn-field {
    margin-bottom: 0.75rem;
}
.mathpay-txn-field label {
    display: block;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}
.mathpay-txn-field label .required { color: #ef4444; }
.mathpay-txn-field input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 1.05rem;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    background: #fafafa;
    box-sizing: border-box;
}
.mathpay-txn-field input[type="text"]:focus {
    outline: none;
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.mathpay-field-hint {
    display: block;
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 0.3rem;
    font-style: italic;
}
.mathpay-txn-field-active {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border-radius: 8px;
    padding: 0.5rem;
    margin: -0.5rem;
}

/* ============================================
   THANK YOU PAGE — Polling
   ============================================ */
.mathpay-thankyou {
    text-align: center;
    padding: 2rem 1.5rem;
    border-radius: 12px;
    margin: 1.5rem 0;
}
.mathpay-thankyou-icon {
    font-size: 2.5rem;
    width: auto;
    height: auto;
    display: block;
    margin: 0 auto 0.75rem;
}
.mathpay-thankyou h3 {
    margin: 0 0 0.5rem;
    font-size: 1.3rem;
}
.mathpay-thankyou p {
    margin: 0 0 0.25rem;
    color: #4b5563;
    font-size: 0.9rem;
}

/* En attente */
.mathpay-thankyou-pending {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
}
.mathpay-thankyou-pending .mathpay-thankyou-icon {
    color: #f59e0b;
    animation: mathpaySpin 2s linear infinite;
}
.mathpay-thankyou-pending h3 { color: #92400e; }
.mathpay-poll-hint {
    font-size: 0.8rem !important;
    color: #9ca3af !important;
    margin-top: 0.75rem !important;
}

/* Validé */
.mathpay-thankyou-success {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
}
.mathpay-thankyou-success .mathpay-thankyou-icon { color: #10b981; }
.mathpay-thankyou-success h3 { color: #065f46; }

/* ---- Polling container ---- */
.mathpay-polling-container {
    text-align: center;
    padding: 1rem;
}
.mathpay-polling-status {
    font-size: 0.9rem;
    color: #6b7280;
}
.mathpay-polling-success {
    color: #059669;
    font-weight: 700;
}
.mathpay-polling-timeout {
    color: #d97706;
}
.mathpay-polling-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    border-top-color: #6366f1;
    margin-right: 0.5rem;
    vertical-align: middle;
}
.mathpay-spin {
    animation: mathpaySpin 0.8s linear infinite;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .mathpay-operators-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .mathpay-operator-card {
        padding: 1rem;
    }
    .mathpay-op-card-image {
        max-width: 80px;
        max-height: 60px;
    }
}

@media (max-width: 640px) {
    .mathpay-validation-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    .mathpay-validation-container h2 { font-size: 1.4rem; }
    .mathpay-ussd-code { font-size: 1.5rem; }
    .mathpay-instructions { padding: 1rem; }
    .mathpay-thankyou { padding: 1.5rem 1rem; }
    .mathpay-op-select-btn {
        font-size: 0.85rem;
        padding: 0.55rem 0.75rem;
    }
}

@media (min-width: 1024px) {
    .mathpay-operators-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}