/* ═══════════════════════════════════════════════════
   MWAKENYA — modal.css
   Payment modal, STK push states, phone input
   ═══════════════════════════════════════════════════ */

/* ── Overlay ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: overlay-in .2s ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Modal shell ──────────────────────────────────── */
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: modal-up .22s cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}

@keyframes modal-up {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ───────────────────────────────────────── */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.35;
}

.modal-subtitle {
  font-size: .82rem;
  color: var(--color-text-muted);
  margin-top: .2rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: .1rem;
  line-height: 1;
  flex-shrink: 0;
  font-size: 1.2rem;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--color-text); }

/* ── Body ─────────────────────────────────────────── */
.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Price display */
.modal-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--color-surface2);
  border-radius: var(--radius-sm);
}

.modal-price-label { font-size: .85rem; color: var(--color-text-muted); }

.modal-price-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--color-accent);
  line-height: 1;
}

.modal-price-value small {
  font-family: var(--font-body);
  font-size: .75rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

/* ── Phone input ──────────────────────────────────── */
.phone-group { display: flex; flex-direction: column; gap: .4rem; }

.phone-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.phone-input-wrap {
  display: flex;
  align-items: center;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.phone-input-wrap:focus-within {
  border-color: rgba(201,168,76,.5);
}

.phone-prefix {
  padding: .65rem .85rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  background: rgba(255,255,255,.03);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.phone-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: .65rem .85rem;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: .95rem;
  min-width: 0;
}

.phone-input::placeholder { color: var(--color-text-subtle); }

.phone-hint {
  font-size: .75rem;
  color: var(--color-text-subtle);
}

.phone-hint.error { color: #e57373; }

/* ── STK states ───────────────────────────────────── */
.stk-state { display: none; }
.stk-state.active { display: flex; flex-direction: column; gap: 1rem; align-items: center; text-align: center; }

/* Waiting */
.stk-waiting .stk-icon {
  width: 64px;
  height: 64px;
  background: var(--color-accent-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 1.75rem;
  animation: pulse-ring 1.8s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(201,168,76,.35); }
  70%  { box-shadow: 0 0 0 16px rgba(201,168,76,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
}

.stk-waiting .stk-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.stk-waiting .stk-sub {
  font-size: .85rem;
  color: var(--color-text-muted);
  max-width: 300px;
}

/* Spinner dots for polling */
.dot-row {
  display: flex;
  gap: .4rem;
  justify-content: center;
  padding: .25rem 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-accent);
  opacity: .3;
  animation: dot-bounce .9s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .30s; }

@keyframes dot-bounce {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40%            { opacity: 1;  transform: scale(1.1); }
}

/* Poll counter */
.poll-counter {
  font-size: .78rem;
  color: var(--color-text-subtle);
}

/* ── Success state ────────────────────────────────── */
.stk-success .stk-icon {
  width: 64px;
  height: 64px;
  background: rgba(46,125,50,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #66bb6a;
  font-size: 1.75rem;
}

.stk-success .stk-title { font-size: 1.1rem; font-weight: 700; color: #66bb6a; }
.stk-success .stk-sub   { font-size: .85rem; color: var(--color-text-muted); }

/* ── Error state ──────────────────────────────────── */
.stk-error .stk-icon {
  width: 64px;
  height: 64px;
  background: rgba(198,40,40,.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ef5350;
  font-size: 1.75rem;
}

.stk-error .stk-title { font-size: 1rem; font-weight: 700; color: #ef5350; }
.stk-error .stk-sub   { font-size: .85rem; color: var(--color-text-muted); }

/* ── Timeout overlay ──────────────────────────────── */
.timeout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(6px);
}

.timeout-box {
  background: var(--color-surface);
  border: 1px solid rgba(201,168,76,.25);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.timeout-icon {
  font-size: 2.5rem;
}

.timeout-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: .06em;
  color: var(--color-text);
}

.timeout-sub {
  font-size: .9rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* ── Timer bar ─────────────────────────────────────── */
.timer-bar-wrap {
  background: var(--color-surface2);
  border-radius: 99px;
  height: 4px;
  overflow: hidden;
  width: 100%;
  margin-top: -.5rem;
}

.timer-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 99px;
  transition: width 1s linear, background .5s ease;
}

.timer-bar-fill.warning { background: #ff9800; }
.timer-bar-fill.critical { background: #f44336; }

/* ── Submit button states ─────────────────────────── */
.btn-pay { position: relative; overflow: hidden; }

.btn-pay .btn-text { transition: opacity var(--transition); }
.btn-pay .btn-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.btn-pay.loading .btn-text { opacity: 0; }
.btn-pay.loading .btn-loading { opacity: 1; }
