@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ============================================
   Design Tokens / CSS Variables
   ============================================ */
:root {
  /* Primary — UOB Brand */
  --color-primary:        #003865;
  --color-primary-light:  #005BAC;
  --color-accent:         #E85D04;

  /* Status Colors */
  --color-confirmed:      #2563EB;
  --color-packing:        #D97706;
  --color-shipped:        #16A34A;
  --color-error:          #DC2626;
  --color-disabled:       #9CA3AF;

  /* Neutrals */
  --color-bg:             #F8F9FA;
  --color-surface:        #FFFFFF;
  --color-border:         #E2E8F0;
  --color-text-primary:   #1A202C;
  --color-text-secondary: #64748B;
  --color-text-muted:     #94A3B8;

  /* Input */
  --color-input-bg:       #FFFDE7;
  --color-input-border:   #D4AC0D;

  /* Typography */
  --font-primary: 'Sarabun', 'IBM Plex Sans Thai', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;

  --font-normal: 400;
  --font-medium: 500;
  --font-bold:   700;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ============================================
   Global Reset
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Layout Components
   ============================================ */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-4);
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: var(--space-4);
}

.header {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  background: var(--color-primary);
  color: white;
}

.header-logo {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-2);
}

.header-title {
  font-size: var(--text-lg);
  font-weight: var(--font-normal);
  opacity: 0.9;
}

.footer {
  text-align: center;
  padding: var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ============================================
   Form Components
   ============================================ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--font-medium);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
}

.form-label .required {
  color: var(--color-error);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-input-bg);
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 56, 101, 0.1);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-error {
  display: block;
  margin-top: var(--space-2);
  color: var(--color-error);
  font-size: var(--text-sm);
}

.form-hint {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.5;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #D04F03;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232, 93, 4, 0.3);
}

.btn-secondary {
  background: white;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary);
  color: white;
}

.btn-full {
  width: 100%;
}

.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ============================================
   Product Display
   ============================================ */
.product-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.product-image {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.product-info {
  flex: 1;
}

.product-name {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.product-description {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.product-spec {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: pre-line;
  line-height: 1.8;
}

/* ============================================
   Progress Tracker
   ============================================ */
.progress-tracker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) 0;
  position: relative;
}

.progress-tracker::before {
  content: '';
  position: absolute;
  top: 28px;
  left: 15%;
  right: 15%;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

.progress-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.progress-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
  transition: all 0.3s;
}

.progress-step.active .progress-circle {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.progress-step.completed .progress-circle {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.progress-circle::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
}

.progress-step.active .progress-circle::after,
.progress-step.completed .progress-circle::after {
  background: white;
}

.progress-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.progress-step.active .progress-label {
  color: var(--color-primary);
  font-weight: var(--font-bold);
}

.progress-step.completed .progress-label {
  color: var(--color-text-secondary);
  font-weight: var(--font-medium);
}

/* ============================================
   Delivery Status
   ============================================ */
.status-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}

.status-label {
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

.status-value {
  color: var(--color-text-primary);
  font-size: var(--text-sm);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-confirmed {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-confirmed);
}

.badge-packing {
  background: rgba(217, 119, 6, 0.1);
  color: var(--color-packing);
}

.badge-shipped {
  background: rgba(22, 163, 74, 0.1);
  color: var(--color-shipped);
}

/* ============================================
   Alert / Error Messages
   ============================================ */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

.alert-error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.alert-success {
  background: rgba(22, 163, 74, 0.1);
  color: var(--color-shipped);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.alert-info {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-confirmed);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* ============================================
   Modal Dialog
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

.modal-content {
  margin-bottom: var(--space-6);
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ============================================
   Sorry Page
   ============================================ */
.sorry-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.sorry-card {
  text-align: center;
  max-width: 500px;
}

.sorry-icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
}

.sorry-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-3);
}

.sorry-message {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  line-height: 1.8;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-error {
  color: var(--color-error);
}

.text-primary {
  color: var(--color-primary);
}

.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 640px) {
  .container {
    padding: var(--space-3);
  }

  .card {
    padding: var(--space-4);
  }

  .product-card {
    flex-direction: column;
    text-align: center;
  }

  .product-image {
    width: 100%;
    height: 200px;
  }

  .progress-tracker {
    padding: var(--space-4) 0;
  }

  .progress-circle {
    width: 32px;
    height: 32px;
  }

  .progress-label {
    font-size: var(--text-xs);
  }
}

/* ============================================
   Loading State
   ============================================ */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================
   Section Divider
   ============================================ */
.section-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-border);
}

/* ============================================
   Info Grid
   ============================================ */
.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.info-label {
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

.info-value {
  color: var(--color-text-primary);
}
