/* ================================================================
   M-Pesa WooCommerce v8 — Frontend CSS
   Covers: checkout field, order-pay widget, thankyou page
   ================================================================ */

/* ── Checkout phone field ──────────────────────────────────────── */
#mpesa-checkout-wrap { margin-top: 8px; }
.mpesa-desc { font-size: 14px; color: #555; margin: 0 0 10px; }
.mpesa-sandbox-notice {
    background: #fff8e1; border: 1px solid #ffe082; border-radius: 6px;
    padding: 8px 14px; font-size: 12px; font-weight: 600; color: #e65100;
    margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.mpesa-badge-env {
    background: #e65100; color: #fff; padding: 1px 8px;
    border-radius: 3px; font-size: 10px; letter-spacing: .5px;
}
.mpesa-field-wrap { margin-bottom: 10px; }
.mpesa-field-wrap > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.mpesa-phone-row {
    display: flex; border: 1.5px solid #d0d0d0; border-radius: 7px;
    overflow: hidden; transition: border-color .2s, box-shadow .2s;
    background: #fff;
}
.mpesa-phone-row:focus-within { border-color: #4caf50; box-shadow: 0 0 0 3px rgba(76,175,80,.15); }
.mpesa-flag-prefix {
    padding: 11px 13px; background: #f7f7f7; border-right: 1.5px solid #e0e0e0;
    font-size: 14px; white-space: nowrap; color: #555; flex-shrink: 0; user-select: none;
}
.mpesa-phone-row input.input-text,
.mpesa-phone-row input[type="tel"] {
    flex: 1; border: none !important; box-shadow: none !important;
    outline: none !important; padding: 11px 13px !important;
    font-size: 16px !important; margin: 0 !important; min-width: 0;
    background: transparent;
}
.mpesa-field-hint { font-size: 12px; color: #999; display: block; margin-top: 5px; }

/* ── Order-pay / view-order widget (class-mpesa-stk-retry.php) ── */
.mpesa-widget {
    background: #fff; border: 1.5px solid #e0e0e0; border-radius: 12px;
    overflow: hidden; margin: 0 0 26px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.mpesa-widget-header {
    background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
    color: #fff; padding: 20px 22px; display: flex; align-items: center; gap: 16px;
}
.mpesa-widget-logo {
    height: 36px; width: auto; border-radius: 6px;
    background: rgba(255,255,255,.95); padding: 3px 8px; flex-shrink: 0;
}
.mpesa-widget-title  { margin: 0 0 3px; font-size: 17px; font-weight: 700; }
.mpesa-widget-subtitle { margin: 0; font-size: 13px; opacity: .88; }

.mpesa-widget .mpesa-status { margin: 14px 18px 0; }
.mpesa-widget-form { padding: 16px 18px 6px; }
.mpesa-phone-group { margin-bottom: 14px; }
.mpesa-phone-group > label {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 600; margin-bottom: 7px;
}
.mpesa-phone-group small { display: block; font-size: 12px; color: #999; margin-top: 5px; }
.mpesa-attempts-badge {
    font-size: 11px; font-weight: 700; background: #fff3e0; color: #e65100;
    padding: 2px 9px; border-radius: 12px; border: 1px solid #ffcc80;
}
.mpesa-attempts-hint { color: #e65100; font-weight: 600; }
.mpesa-phones-used {
    margin-top: 7px; font-size: 12px; color: #777;
    display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.mpesa-phones-used code {
    background: #f0f0f0; border: 1px solid #e0e0e0; border-radius: 4px;
    padding: 1px 7px; font-size: 12px; color: #333;
}
.mpesa-push-btn {
    width: 100%; padding: 13px 18px !important; font-size: 15px !important;
    font-weight: 700 !important; background: #4caf50 !important; color: #fff !important;
    border: none !important; border-radius: 8px !important; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 9px;
    transition: background .15s, box-shadow .15s !important;
    box-shadow: 0 2px 8px rgba(76,175,80,.35) !important;
}
.mpesa-push-btn:hover:not(:disabled) { background: #388e3c !important; box-shadow: 0 4px 16px rgba(76,175,80,.45) !important; }
.mpesa-push-btn:disabled { opacity: .6; cursor: not-allowed; box-shadow: none !important; }
.mpesa-btn-icon { font-size: 19px; }
.mpesa-widget-hint { font-size: 12px; color: #999; text-align: center; margin: 9px 0 0; }
.mpesa-return-cart-link { font-size: 12px; color: #bbb; text-decoration: none; transition: color .15s; }
.mpesa-return-cart-link:hover { color: #c62828; text-decoration: underline; }
.mpesa-widget-steps {
    display: flex; gap: 8px; padding: 14px 18px;
    background: #f9fffe; border-top: 1px solid #e0f2f1; flex-wrap: wrap; margin-top: 14px;
}
.mpesa-ws { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 120px; }
.mpesa-ws-n {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; border-radius: 50%;
    background: #4caf50; color: #fff; font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.mpesa-ws p { margin: 0; font-size: 12px; color: #555; line-height: 1.5; }
.mpesa-alert { padding: 11px 18px; font-size: 13px; border-top: 1px solid transparent; border-bottom: 1px solid transparent; }
.mpesa-alert-error { background: #ffebee; color: #c62828; border-color: #ef9a9a; }
.mpesa-alert-warn  { background: #fff8e1; color: #e65100; border-color: #ffe082; }
.mpesa-alert-info  { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }

/* Status bar (order-pay widget) */
.mpesa-status {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 8px; font-size: 14px;
    font-weight: 600; transition: all .35s; margin-bottom: 14px;
}
.mpesa-status.pending { background: #e3f2fd; color: #1565c0; border: 1.5px solid #90caf9; }
.mpesa-status.info    { background: #f5f5f5; color: #555;    border: 1.5px solid #e0e0e0; }
.mpesa-status.success { background: #e8f5e9; color: #2e7d32; border: 1.5px solid #a5d6a7; }
.mpesa-status.warning { background: #fff8e1; color: #e65100; border: 1.5px solid #ffe082; }
.mpesa-status.failed  { background: #ffebee; color: #c62828; border: 1.5px solid #ef9a9a; }
.mpesa-spinner {
    display: inline-block; width: 16px; height: 16px; flex-shrink: 0;
    border: 3px solid currentColor; border-top-color: transparent;
    border-radius: 50%; animation: mpspin .7s linear infinite; vertical-align: middle;
}
@keyframes mpspin { to { transform: rotate(360deg); } }

/* ================================================================
   THANK-YOU PAGE  —  full redesign for great UX
   ================================================================ */
.mpesa-ty {
    max-width: 580px; margin: 0 auto 40px;
    background: #fff; border-radius: 16px; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 8px 40px rgba(0,0,0,.10);
    border: 1px solid #e8e8e8;
}

/* Header */
.mpesa-ty-header {
    padding: 28px 28px 24px; color: #fff;
    display: flex; align-items: flex-start; gap: 18px;
}
.mpesa-ty-hdr-paid    { background: linear-gradient(135deg, #2e7d32 0%, #4caf50 100%); }
.mpesa-ty-hdr-pending { background: linear-gradient(135deg, #0d47a1 0%, #1976d2 100%); }
.mpesa-ty-hdr-warn    { background: linear-gradient(135deg, #bf360c 0%, #e64a19 100%); }

.mpesa-ty-logo-badge {
    flex-shrink: 0; background: rgba(255,255,255,.18);
    border-radius: 10px; padding: 6px 10px; display: flex; align-items: center;
}
.mpesa-ty-logo-badge img { height: 36px; width: auto; }
.mpesa-ty-hdr-text { flex: 1; }
.mpesa-ty-hdr-text h2 {
    margin: 0 0 8px; font-size: 20px; font-weight: 800;
    display: flex; align-items: center; gap: 8px;
}
.mpesa-ty-icon { font-style: normal; }
@keyframes mpulse { 0%,100%{transform:scale(1);} 50%{transform:scale(1.15);} }
.mpesa-pulse { display: inline-block; animation: mpulse 1.5s ease-in-out infinite; }
.mpesa-ty-hdr-text p { margin: 0; font-size: 14px; opacity: .92; }

/* Body */
.mpesa-ty-body { padding: 24px 28px 28px; }

/* Success banner */
.mpesa-ty-success-banner {
    display: flex; align-items: center; gap: 16px;
    background: #e8f5e9; border: 1.5px solid #a5d6a7;
    border-radius: 10px; padding: 16px 20px; margin-bottom: 20px;
}
.mpesa-ty-success-icon {
    font-size: 32px; color: #2e7d32; flex-shrink: 0;
    width: 52px; height: 52px; border-radius: 50%;
    background: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(46,125,50,.2);
}
.mpesa-ty-success-banner strong { display: block; font-size: 15px; color: #1b5e20; margin-bottom: 4px; }
.mpesa-ty-success-banner p { margin: 0; font-size: 13px; color: #388e3c; }

/* Alert boxes */
.mpesa-ty-alert {
    display: flex; align-items: flex-start; gap: 14px;
    border-radius: 10px; padding: 14px 18px; margin-bottom: 16px;
    border: 1.5px solid transparent;
}
.mpesa-ty-alert-warn  { background: #fff3e0; border-color: #ffcc80; color: #bf360c; }
.mpesa-ty-alert-info  { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }
.mpesa-ty-alert-error { background: #ffebee; border-color: #ef9a9a; color: #c62828; }
.mpesa-ty-alert-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.mpesa-ty-alert strong { display: block; font-size: 14px; margin-bottom: 4px; }
.mpesa-ty-alert p { margin: 0; font-size: 13px; opacity: .9; }

/* Live status bar */
.mpesa-ty-status {
    border-radius: 10px; padding: 14px 18px; margin-bottom: 20px;
    transition: background .4s, border-color .4s;
}
.mpesa-ty-status.is-polling { background: #e3f2fd; border: 1.5px solid #90caf9; }
.mpesa-ty-status.is-idle    { background: #f5f5f5; border: 1.5px solid #e0e0e0; }
.mpesa-ty-status.is-success { background: #e8f5e9; border: 1.5px solid #a5d6a7; }
.mpesa-ty-status.is-warn    { background: #fff8e1; border: 1.5px solid #ffe082; }
.mpesa-ty-status.is-error   { background: #ffebee; border: 1.5px solid #ef9a9a; }

.mpesa-ty-status-inner {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; font-weight: 600; color: #333;
}
.mpesa-ty-status.is-polling .mpesa-ty-status-inner { color: #1565c0; }
.mpesa-ty-status.is-success .mpesa-ty-status-inner { color: #2e7d32; }
.mpesa-ty-status.is-warn    .mpesa-ty-status-inner { color: #e65100; }
.mpesa-ty-status.is-error   .mpesa-ty-status-inner { color: #c62828; }

.mpesa-ty-spinner {
    display: none; width: 18px; height: 18px; flex-shrink: 0;
    border: 3px solid currentColor; border-top-color: transparent;
    border-radius: 50%; animation: mpspin .7s linear infinite;
}
.mpesa-ty-status.is-polling .mpesa-ty-spinner { display: inline-block; }

/* Progress steps inside status bar */
.mpesa-ty-status-steps {
    display: flex; align-items: center; margin-top: 12px;
    padding-top: 12px; border-top: 1px solid rgba(25,118,210,.15);
}
.mpesa-step { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #90a4ae; font-weight: 600; }
.mpesa-step-active { color: #1976d2; }
.mpesa-step-done   { color: #2e7d32; }
.mpesa-step-dot {
    width: 10px; height: 10px; border-radius: 50%; border: 2px solid #b0bec5; flex-shrink: 0;
}
.mpesa-step-active .mpesa-step-dot { border-color: #1976d2; background: #1976d2; animation: mpulse 1.2s ease-in-out infinite; }
.mpesa-step-done   .mpesa-step-dot { border-color: #4caf50; background: #4caf50; }
.mpesa-step-line   { flex: 1; height: 2px; background: #e0e0e0; margin: 0 8px; }

/* ── STK Push box ────────────────────────────────────────────── */
.mpesa-ty-push-box {
    border: 1.5px solid #e3f2fd; border-radius: 12px;
    overflow: hidden; margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(21,101,192,.08);
}
.mpesa-ty-push-header {
    background: #e3f2fd; padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-size: 14px; font-weight: 700; color: #1565c0;
    border-bottom: 1px solid #bbdefb; flex-wrap: wrap;
}
.mpesa-attempt-pill {
    font-size: 12px; font-weight: 700; background: #fff3e0; color: #e65100;
    padding: 3px 10px; border-radius: 12px; border: 1px solid #ffcc80; white-space: nowrap;
}
.mpesa-ty-push-body { padding: 20px 22px; }

/* Phone input inside push box */
.mpesa-ty-phone-wrap { margin-bottom: 16px; }
.mpesa-ty-phone-wrap > label {
    display: block; font-size: 13px; font-weight: 700; color: #333; margin-bottom: 8px;
}
.mpesa-ty-phone-row {
    display: flex; border: 1.5px solid #d0d0d0; border-radius: 8px;
    overflow: hidden; transition: border-color .2s, box-shadow .2s; background: #fff;
}
.mpesa-ty-phone-row:focus-within { border-color: #4caf50; box-shadow: 0 0 0 3px rgba(76,175,80,.15); }
.mpesa-ty-country {
    padding: 12px 14px; background: #f7f7f7; border-right: 1.5px solid #e0e0e0;
    font-size: 15px; white-space: nowrap; color: #444; flex-shrink: 0; user-select: none;
}
.mpesa-ty-phone-row input {
    flex: 1; border: none; outline: none; padding: 12px 14px;
    font-size: 17px; background: transparent; min-width: 0; color: #333;
}
.mpesa-ty-phone-wrap small { display: block; font-size: 12px; color: #999; margin-top: 6px; }
.mpesa-tried-phones {
    margin-top: 8px; font-size: 12px; color: #888;
    display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.mpesa-tried-phones code {
    background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: 4px;
    padding: 1px 7px; font-size: 12px; color: #555;
}

/* Push button */
.mpesa-ty-push-btn {
    width: 100%; padding: 16px 20px; font-size: 16px; font-weight: 800;
    background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%);
    color: #fff; border: none; border-radius: 10px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    box-shadow: 0 4px 16px rgba(46,125,50,.35);
    transition: transform .15s, box-shadow .15s, background .15s;
    margin-bottom: 0;
}
.mpesa-ty-push-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #388e3c 0%, #1b5e20 100%);
    box-shadow: 0 6px 24px rgba(46,125,50,.45); transform: translateY(-1px);
}
.mpesa-ty-push-btn:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 8px rgba(46,125,50,.3); }
.mpesa-ty-push-btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.mpesa-ty-push-btn-icon { font-size: 22px; line-height: 1; }
.mpesa-ty-push-btn-label { font-size: 16px; font-weight: 800; line-height: 1; }
.mpesa-ty-push-btn-sub { font-size: 12px; opacity: .8; font-weight: 500; }

/* How it works */
.mpesa-ty-how {
    display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap;
    padding: 14px 0; border-top: 1px solid #f0f0f0;
}
.mpesa-ty-step-item {
    flex: 1; min-width: 110px; display: flex; align-items: flex-start; gap: 9px;
}
.mpesa-ty-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; border-radius: 50%;
    background: #e8f5e9; color: #2e7d32; font-size: 11px; font-weight: 800; flex-shrink: 0;
    border: 2px solid #a5d6a7;
}
.mpesa-ty-step-item p { margin: 0; font-size: 12px; color: #555; line-height: 1.5; }

/* Footer links */
.mpesa-ty-footer-links {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px;
    border-top: 1px solid #f0f0f0;
}
.mpesa-ty-footer-note { font-size: 12px; color: #aaa; }
.mpesa-ty-footer-note a { color: #aaa; text-decoration: underline; }
.mpesa-return-cart-link {
    font-size: 12px; color: #bbb; text-decoration: none;
    transition: color .15s; white-space: nowrap;
}
.mpesa-return-cart-link:hover { color: #c62828; text-decoration: underline; }

/* Order summary */
.mpesa-ty-summary {
    border: 1px solid #f0f0f0; border-radius: 10px; overflow: hidden; margin-bottom: 18px;
}
.mpesa-ty-summary-hdr {
    background: #fafafa; padding: 10px 18px; font-size: 12px;
    font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid #f0f0f0;
}
.mpesa-ty-summary-rows { padding: 4px 0; }
.mpesa-ty-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 18px; border-bottom: 1px solid #fafafa; font-size: 13px;
}
.mpesa-ty-row:last-child { border-bottom: none; }
.mpesa-ty-row > span { color: #888; }
.mpesa-ty-row > strong { color: #1a1a1a; }

/* Status chips */
.mpesa-status-chip {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
}
.mpesa-s-paid    { background: #e8f5e9; color: #2e7d32; }
.mpesa-s-pending { background: #fff8e1; color: #e65100; }
.mpesa-s-warn    { background: #ffebee; color: #c62828; }

/* Bottom actions */
.mpesa-ty-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
}
.mpesa-ty-action-btn {
    flex: 1; min-width: 130px; padding: 12px 16px; border-radius: 8px;
    font-size: 14px; font-weight: 600; text-align: center; text-decoration: none;
    cursor: pointer; transition: background .15s, box-shadow .15s; display: block;
}
.mpesa-ty-action-sec {
    background: #1976d2; color: #fff !important;
    box-shadow: 0 2px 8px rgba(25,118,210,.25);
}
.mpesa-ty-action-sec:hover { background: #1565c0; box-shadow: 0 4px 16px rgba(25,118,210,.35); }
.mpesa-ty-action-ghost {
    background: #f5f5f5; color: #555 !important; border: 1px solid #e0e0e0;
}
.mpesa-ty-action-ghost:hover { background: #eeeeee; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 520px) {
    .mpesa-ty-body { padding: 18px; }
    .mpesa-ty-header { flex-direction: column; gap: 12px; }
    .mpesa-ty-hdr-text h2 { font-size: 17px; }
    .mpesa-ty-how { flex-direction: column; }
    .mpesa-ty-push-header { flex-direction: column; align-items: flex-start; }
    .mpesa-ty-status-steps { flex-direction: column; align-items: flex-start; gap: 6px; }
    .mpesa-step-line { display: none; }
    .mpesa-ty-footer-links { flex-direction: column; gap: 10px; }
    .mpesa-ty-actions { flex-direction: column; }
    .mpesa-widget-header { flex-direction: column; text-align: center; }
    .mpesa-widget-steps { flex-direction: column; }
    .mpesa-phone-group label { flex-direction: column; align-items: flex-start; }
}

/* ── Countdown inside status bar ───────────────────────────────── */
#mpesa-countdown {
    font-size: 12px; opacity: .72; margin-top: 4px;
    color: inherit; letter-spacing: .2px;
}

/* stk_timeout pulse on resend button */
@keyframes mp-resend-pulse {
    0%,100% { box-shadow: 0 4px 16px rgba(76,175,80,.35); }
    50%      { box-shadow: 0 6px 28px rgba(76,175,80,.65); }
}
.mpesa-ty-push-btn:not(:disabled) { animation: mp-resend-pulse 2s ease-in-out infinite; }
.mpesa-ty-push-btn:disabled       { animation: none; }
