/* ===== TrainSkills Checkout — Mobile-First ===== */

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --primary-light: #a29bfe;
  --success: #00b894;
  --success-light: #55efc4;
  --danger: #e17055;
  --warning: #fdcb6e;
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #2d3436;
  --text-muted: #636e72;
  --border: #dfe6e9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Container ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 20px 0 4px;
}
.app-header h1 {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 700;
}
.app-header p {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Progress Bar ===== */
.progress-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  margin: 20px 0 24px;
  padding: 0 8px;
}
.progress-wrap::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--border);
  transform: translateY(-50%);
  z-index: 0;
  border-radius: 2px;
}
.progress-fill {
  position: absolute;
  top: 50%;
  left: 20px;
  height: 3px;
  background: var(--primary);
  transform: translateY(-50%);
  z-index: 1;
  border-radius: 2px;
  transition: width .4s ease;
}
.step-dot {
  position: relative;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all .3s ease;
  cursor: default;
}
.step-dot.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.step-dot.done {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

/* ===== Step Label ===== */
.step-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  margin-top: -8px;
  margin-bottom: 16px;
}
.step-labels span {
  font-size: .65rem;
  color: var(--text-muted);
  text-align: center;
  flex: 1;
}
.step-labels span.active-label {
  color: var(--primary);
  font-weight: 600;
}
.step-labels span.done-label {
  color: var(--success);
}

/* ===== Step Panels ===== */
.panel {
  display: none;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: fadeIn .3s ease;
}
.panel.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text);
}
.panel h2 span {
  color: var(--primary);
}

/* ===== Products ===== */
.products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.product-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
  position: relative;
}
.product-card:hover {
  border-color: var(--primary-light);
}
.product-card.selected {
  border-color: var(--primary);
  background: #f0edff;
}
.product-card .product-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 6px;
}
.product-card .product-name {
  font-weight: 600;
  font-size: .9rem;
}
.product-card .product-price {
  font-size: .85rem;
  color: var(--primary);
  font-weight: 700;
  margin-top: 4px;
}
.product-card .qty-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.product-card .qty-controls button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  line-height: 1;
}
.product-card .qty-controls button:hover {
  border-color: var(--primary);
  background: #f0edff;
}
.product-card .qty-controls .qty-val {
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}
.product-card .badge-popular {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ===== Form Fields ===== */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  transition: border .2s;
  background: var(--card);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group textarea {
  resize: vertical;
  min-height: 60px;
}
.form-group .field-error {
  font-size: .75rem;
  color: var(--danger);
  margin-top: 3px;
  display: none;
}
.form-group.invalid input,
.form-group.invalid textarea {
  border-color: var(--danger);
}
.form-group.invalid .field-error {
  display: block;
}

/* ===== Radio Cards (Delivery & Payment) ===== */
.radio-group {
  display: grid;
  gap: 10px;
}
.radio-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.radio-card:hover {
  border-color: var(--primary-light);
}
.radio-card.selected {
  border-color: var(--primary);
  background: #f0edff;
}
.radio-card input {
  display: none;
}
.radio-card .radio-icon {
  font-size: 1.5rem;
  width: 36px;
  text-align: center;
}
.radio-card .radio-info {
  flex: 1;
}
.radio-card .radio-info .radio-title {
  font-weight: 600;
  font-size: .9rem;
}
.radio-card .radio-info .radio-desc {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.radio-card .radio-info .radio-price {
  font-weight: 700;
  color: var(--primary);
  font-size: .85rem;
  margin-top: 2px;
}

/* ===== Review Step ===== */
.review-section {
  margin-bottom: 16px;
}
.review-section h3 {
  font-size: .95rem;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}
.review-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: .85rem;
}
.review-row .label {
  color: var(--text-muted);
}
.review-row .value {
  font-weight: 600;
  text-align: right;
}
.review-items {
  margin-bottom: 8px;
}
.review-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: .85rem;
}
.review-total {
  border-top: 2px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.review-total .review-row .value {
  font-size: 1.1rem;
  color: var(--primary);
}

/* ===== Success Page ===== */
.success-page {
  text-align: center;
  padding: 24px 0;
}
.success-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  0% { transform: scale(0); }
  80% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.success-check svg {
  width: 40px;
  height: 40px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
}
.success-page h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}
.success-page p {
  color: var(--text-muted);
  font-size: .9rem;
}
.success-order-id {
  background: var(--bg);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  font-size: .9rem;
}
.success-order-id strong {
  color: var(--primary);
}
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  width: 100%;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #00a381;
}
.btn-wa {
  background: #25D366;
  color: #fff;
}
.btn-wa:hover {
  background: #1da851;
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ===== Sticky Nav Footer ===== */
.nav-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding: 12px 0;
}
.nav-footer .btn {
  flex: 1;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--danger);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  opacity: 0;
  transition: all .3s ease;
  z-index: 999;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  background: var(--success);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255,255,255,.92);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.loading-overlay.active {
  display: flex;
  animation: fadeIn .2s ease;
}
.loading-overlay p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.loading-overlay small {
  font-size: .8rem;
  color: var(--text-muted);
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .container { padding: 24px; }
  .products-grid { grid-template-columns: 1fr 1fr 1fr; }
  .radio-group { grid-template-columns: 1fr 1fr; }
  .btn { width: auto; }
  .nav-footer { justify-content: flex-end; }
  .nav-footer .btn { flex: 0 0 auto; min-width: 140px; }
  .app-header h1 { font-size: 1.5rem; }
  .btn-group { flex-direction: row; justify-content: center; }
}

@media (min-width: 900px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}
