/**
 * M-Pesa Live Gateway - Checkout & Modal Styles
 *
 * @package Mpesa_Live_Gateway
 * @since   2.0.0
 */

/* ─── Payment Form ──────────────────────────────────────────────────── */

.mpesa-stk-form {
    margin: 1.25em 0;
}

.mpesa-phone-field {
    margin-bottom: 0.5em;
}

.mpesa-phone-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5em;
    color: #333;
}

.mpesa-phone-field label .required {
    color: #e74c3c;
    margin-left: 2px;
}

.mpesa-phone-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.mpesa-phone-input-wrapper:focus-within {
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.15);
}

.mpesa-phone-prefix {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    height: 42px;
    white-space: nowrap;
    user-select: none;
}

.mpesa-phone-input-wrapper .input-text {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 8px 12px !important;
    font-size: 16px !important;
    height: 42px;
    flex: 1;
    width: 100%;
    letter-spacing: 0.5px;
}

.mpesa-phone-help {
    display: block;
    margin-top: 0.35em;
    font-size: 12px;
    color: #777;
}

/* ─── MODAL OVERLAY ─────────────────────────────────────────────────── */

.mpesa-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.mpesa-modal {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    padding: 40px 32px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: mpesa-modal-in 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes mpesa-modal-in {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mpesa-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    z-index: 10;
}

.mpesa-modal-close:hover {
    color: #333;
    background: #f0f0f0;
}

/* ─── Modal States ──────────────────────────────────────────────────── */

.mpesa-modal-state {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─── Spinner ───────────────────────────────────────────────────────── */

.mpesa-modal-spinner {
    width: 52px;
    height: 52px;
    border: 4px solid #e8f5e9;
    border-top-color: #4CAF50;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: mpesa-spin 0.8s linear infinite;
}

@keyframes mpesa-spin { to { transform: rotate(360deg); } }

/* ─── Icons ─────────────────────────────────────────────────────────── */

.mpesa-modal-icon {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mpesa-icon-phone svg {
    color: #4CAF50;
    animation: mpesa-ring 1.5s ease-in-out infinite;
}

@keyframes mpesa-ring {
    0%, 100% { transform: rotate(0deg); }
    5%  { transform: rotate(12deg); }
    10% { transform: rotate(-10deg); }
    15% { transform: rotate(8deg); }
    20% { transform: rotate(-6deg); }
    25% { transform: rotate(0deg); }
}

.mpesa-icon-success svg {
    color: #4CAF50;
    animation: mpesa-pop 0.4s ease-out;
}

@keyframes mpesa-pop {
    0%  { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100%{ transform: scale(1); opacity: 1; }
}

.mpesa-icon-error svg {
    color: #f44336;
    animation: mpesa-shake 0.4s ease;
}

@keyframes mpesa-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.mpesa-icon-timeout svg {
    color: #FF9800;
    animation: mpesa-pulse 1.5s ease-in-out infinite;
}

@keyframes mpesa-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50%      { opacity: 1; transform: scale(1.05); }
}

/* ─── Typography ────────────────────────────────────────────────────── */

.mpesa-modal-title {
    font-size: 1.25em;
    font-weight: 700;
    color: #333;
    margin: 0 0 8px;
    line-height: 1.3;
}

.mpesa-title-success { color: #2e7d32 !important; }
.mpesa-title-error   { color: #c62828 !important; }
.mpesa-title-timeout  { color: #e65100 !important; }

.mpesa-modal-subtitle {
    font-size: 0.9em;
    color: #777;
    margin: 0 0 20px;
    line-height: 1.5;
}

#mpesa-fail-reason {
    color: #c62828;
    font-weight: 500;
}

/* ─── Details ───────────────────────────────────────────────────────── */

.mpesa-modal-details {
    width: 100%;
    background: #f9fafb;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: left;
}

.mpesa-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.mpesa-detail-row + .mpesa-detail-row {
    border-top: 1px solid #f0f0f0;
}

.mpesa-detail-label {
    font-size: 0.82em;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mpesa-detail-value {
    font-size: 0.95em;
    font-weight: 600;
    color: #333;
}

/* ─── Progress Bar ──────────────────────────────────────────────────── */

.mpesa-modal-progress {
    width: 100%;
    margin-bottom: 16px;
}

.mpesa-progress-bar {
    width: 100%;
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.mpesa-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
    border-radius: 2px;
    width: 0%;
    transition: width 1s linear;
}

.mpesa-countdown {
    font-size: 0.8em;
    color: #999;
    font-variant-numeric: tabular-nums;
}

/* ─── Polling Indicator ─────────────────────────────────────────────── */

.mpesa-modal-polling-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.82em;
    color: #888;
    margin-top: 4px;
}

.mpesa-polling-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: mpesa-dot 1.5s ease-in-out infinite;
}

@keyframes mpesa-dot {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50%      { opacity: 1; transform: scale(1.2); }
}

/* ─── Buttons ───────────────────────────────────────────────────────── */

.mpesa-modal-btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    margin: 4px;
    min-width: 140px;
}

.mpesa-btn-primary,
.mpesa-btn-secondary {
    background: #4CAF50;
    color: #fff;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.mpesa-btn-primary:hover,
.mpesa-btn-secondary:hover {
    background: #43a047;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transform: translateY(-1px);
}

.mpesa-btn-outline {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
}

.mpesa-btn-outline:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #ccc;
}

.mpesa-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ─── Order Receipt ─────────────────────────────────────────────────── */

.mpesa-order-receipt { margin-top: 2em; }
.mpesa-receipt-title { font-size: 1.1em; margin-bottom: 0.75em; color: #333; }
.mpesa-receipt-table { margin-top: 0; }
.mpesa-receipt-table th { width: 40%; }

/* ─── Admin ──────────────────────────────────────────────────────────── */

.mpesa-success { color: #4CAF50 !important; font-weight: 600; }
.mpesa-error   { color: #f44336 !important; font-weight: 600; }

/* ─── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .mpesa-modal {
        padding: 32px 20px 24px;
        border-radius: 12px;
        margin: 10px;
        max-height: 95vh;
    }
    .mpesa-modal-icon svg { width: 44px; height: 44px; }
    .mpesa-modal-title { font-size: 1.1em; }
    .mpesa-modal-actions { flex-direction: column; }
    .mpesa-modal-btn { width: 100%; min-width: auto; }
    .mpesa-phone-prefix { padding: 0 8px; font-size: 13px; }
    .mpesa-phone-input-wrapper .input-text { font-size: 14px !important; }
}
