/* Commerce Design System - Prototype Styles */
/* Based on: Figma Commerce Design System (xH60NHQrj8SBKUJYcrYQ2V) */

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

/* ===== CSS Variables (Design Tokens) ===== */
:root {
  /* Base */
  --background: #f7f7f8;
  --surface: #ffffff;
  --foreground: #181d29;
  --muted-foreground: #6b7280;
  --foreground-tertiary: #8b8e94;
  --border-surface: #e5e5e5;
  --border-separator: #e5e5e5;
  --muted: #f4f6f9;

  /* Primary */
  --primary: #172e5e;
  --primary-foreground: #fafafa;
  --secondary: #f4f6f9;
  --secondary-foreground: #2f394e;
  --accent: #eff3ff;
  --accent-foreground: #051f6a;

  /* Status */
  --destructive: #dc2626;
  --destructive-muted: #fee2e2;
  --warning: #fb923c;
  --warning-muted: #ffedd5;
  --pending: #fcd34d;
  --pending-muted: #fef3c7;
  --pending-foreground: #181d29;
  --success: #047857;
  --success-muted: #d1fae5;

  /* Corporate */
  --policy-in: #155c3b;
  --policy-in-muted: #eaf4ef;
  --policy-out: #3f4750;
  --policy-out-muted: #f2f3f5;

  /* Components */
  --input-bg: #ffffff;
  --input-border: #e5e5e5;
  --card-bg: #ffffff;
  --badge-default: #f4f6f9;
  --badge-default-fg: #181d29;

  /* 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;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Font */
  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 20px;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
.text-display    { font-size: 32px; line-height: 40px; font-weight: 700; }
.text-headline-lg { font-size: 24px; line-height: 28px; font-weight: 700; }
.text-headline-md { font-size: 20px; line-height: 24px; font-weight: 700; }
.text-title-lg   { font-size: 18px; line-height: 24px; font-weight: 700; }
.text-title-md   { font-size: 16px; line-height: 20px; font-weight: 700; }
.text-title-sm   { font-size: 14px; line-height: 16px; font-weight: 700; }
.text-body-md    { font-size: 14px; line-height: 20px; font-weight: 400; }
.text-body-md-em { font-size: 14px; line-height: 20px; font-weight: 600; }
.text-body-sm    { font-size: 12px; line-height: 16px; font-weight: 400; }
.text-body-sm-em { font-size: 12px; line-height: 16px; font-weight: 600; }
.text-body-xs    { font-size: 10px; line-height: 14px; font-weight: 400; }

.text-muted { color: var(--muted-foreground); }
.text-tertiary { color: var(--foreground-tertiary); }
.text-primary { color: var(--primary); }
.text-destructive { color: var(--destructive); }
.text-success { color: var(--success); }

/* ===== Layout ===== */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-separator);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.page-header-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.page-header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.page-content {
  flex: 1;
  padding: var(--space-8);
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.page-content--narrow {
  max-width: 640px;
}

.page-content--wide {
  max-width: 1200px;
}

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.card--flat {
  border: none;
  box-shadow: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn--secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border-surface);
}

.btn--outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--border-surface);
}

.btn--ghost {
  background: transparent;
  color: var(--foreground);
  border-color: transparent;
}

.btn--destructive {
  background: var(--destructive);
  color: #ffffff;
}

.btn--link {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 0;
  font-weight: 600;
  text-decoration: underline;
}

.btn--lg {
  padding: 10px 24px;
  font-weight: 700;
}

.btn--sm {
  padding: 4px 12px;
  font-size: 12px;
  line-height: 16px;
}

.btn--icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

/* ===== Inputs ===== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.input-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--foreground);
}

.input-description {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted-foreground);
}

.input {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 20px;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--foreground);
  outline: none;
  transition: border-color 0.15s;
}

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

.input:focus {
  border-color: var(--primary);
}

.input--error {
  border-color: var(--destructive);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--default {
  background: var(--badge-default);
  color: var(--badge-default-fg);
}

.badge--success {
  background: var(--success-muted);
  color: var(--success);
}

.badge--destructive {
  background: var(--destructive-muted);
  color: var(--destructive);
}

.badge--warning {
  background: var(--warning-muted);
  color: #92400e;
}

.badge--pending {
  background: var(--pending-muted);
  color: #92400e;
}

.badge--primary {
  background: var(--accent);
  color: var(--accent-foreground);
}

.badge--deactivated {
  background: #f3f4f6;
  color: #9ca3af;
}

.badge--policy-in {
  background: var(--policy-in-muted);
  color: var(--policy-in);
}

/* ===== Table ===== */
.table-container {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--muted-foreground);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-separator);
  background: var(--muted);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 20px;
  border-bottom: 1px solid var(--border-separator);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--muted);
}

tbody tr.row--error {
  background: var(--destructive-muted);
}

tbody tr.row--error:hover {
  background: #fdd;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-separator);
  margin-bottom: var(--space-6);
}

.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-family);
}

.tab:hover {
  background: var(--muted);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tab--active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* ===== Dialog / Modal ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--border-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
}

.dropzone:hover,
.dropzone--active {
  border-color: var(--primary);
  background: var(--accent);
}

.dropzone-icon {
  font-size: 40px;
  margin-bottom: var(--space-4);
  color: var(--muted-foreground);
}

.dropzone-text {
  font-size: 14px;
  color: var(--muted-foreground);
  margin-bottom: var(--space-2);
}

/* ===== Expandable / Collapsible ===== */
.expandable {
  border: 1px solid var(--border-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.expandable-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  border: none;
  font-family: var(--font-family);
  color: var(--foreground);
}

.expandable-trigger:hover {
  background: var(--muted);
}

.expandable-trigger .chevron {
  transition: transform 0.2s;
  font-size: 12px;
  color: var(--muted-foreground);
}

.expandable.open .chevron {
  transform: rotate(180deg);
}

.expandable-content {
  display: none;
  padding: 0 var(--space-5) var(--space-5);
  background: var(--surface);
}

.expandable.open .expandable-content {
  display: block;
}

/* ===== Summary Bar ===== */
.summary-bar {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: var(--muted);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.summary-item-value {
  font-weight: 700;
  font-size: 16px;
}

.summary-item-label {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ===== Progress / Loading ===== */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-surface);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--space-6);
}

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

/* ===== Result States ===== */
.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto var(--space-5);
}

.result-icon--success {
  background: var(--success-muted);
  color: var(--success);
}

.result-icon--error {
  background: var(--destructive-muted);
  color: var(--destructive);
}

/* ===== Quick Tips ===== */
.tips {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 12px;
  line-height: 16px;
  color: var(--muted-foreground);
}

.tip-icon {
  color: var(--primary);
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== Utility ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none; }

/* ===== Proto Navigation (bottom bar) ===== */
.proto-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-separator);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 200;
  font-size: 12px;
  color: var(--muted-foreground);
}

.proto-nav-steps {
  display: flex;
  gap: var(--space-2);
}

.proto-nav-step {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-surface);
}

.proto-nav-step--active {
  background: var(--primary);
  width: 24px;
  border-radius: 4px;
}

.proto-nav-step--done {
  background: var(--success);
}

.proto-nav-actions {
  display: flex;
  gap: var(--space-3);
}

/* Add padding to body to account for proto-nav */
body { padding-bottom: 60px; }
