/* ══════════════════════════════════════════════════════════════
   HW QUOTES — INDUSTRIAL DESIGN SYSTEM
   ──────────────────────────────────────────────────────────────
   Shared tokens & component styles for dashboard + admin.
   Aesthetic: Industrial / Utilitarian — Slate & Zinc monotone,
   engineering-tool feel, data-dense, no-nonsense.
   ══════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* ─ Color: Primary (Steel) ─ */
  --c-primary: #3b4f6b;
  --c-primary-hover: #2d3e55;
  --c-primary-light: #e8edf3;

  /* ─ Color: Neutral (Zinc/Slate) ─ */
  --c-bg: #f0f1f3;
  --c-surface: #ffffff;
  --c-surface-alt: #f7f8f9;
  --c-header: #1c1c1f;
  --c-text: #18181b;
  --c-text-secondary: #52525b;
  --c-text-muted: #8b8b94;
  --c-border: #d4d4d8;
  --c-border-light: #ececee;

  /* ─ Color: Semantic ─ */
  --c-success: #3d7a5f;
  --c-success-bg: #edf5f0;
  --c-danger: #b03a3a;
  --c-danger-bg: #faf0f0;
  --c-warning: #a07728;
  --c-warning-bg: #faf5e8;
  --c-link: #3b4f6b;

  /* ─ Color: Categories (desaturated industrial) ─ */
  --c-cat-total: #3b4f6b;
  --c-cat-robot-arm: #5b7fa6;
  --c-cat-robot-hand: #b85c5c;
  --c-cat-robot-body: #7e6ba4;
  --c-cat-robot-glove: #a66585;
  --c-cat-camera: #4d8f9a;
  --c-cat-pc: #b8923d;
  --c-cat-others: #71717a;
  --c-cat-workstation: #5b7fa6;
  --c-cat-inference: #b8923d;
  --c-cat-control: #4d8f6e;

  /* ─ Typography (Pretendard) ─ */
  --font-sans: 'Pretendard', -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 26px;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ─ Spacing (4px grid) ─ */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* ─ Radius (tighter for industrial feel) ─ */
  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 8px;
  --r-xl: 10px;
  --r-2xl: 12px;
  --r-full: 999px;

  /* ─ Shadows (subtle, structural) ─ */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.18);

  /* ─ Transitions ─ */
  --tr-fast: 0.12s ease;
  --tr-normal: 0.2s ease;
  --tr-slow: 0.3s ease;
}

/* ── RESET & BASE ──────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* ── UTILITY ───────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-muted { color: var(--c-text-muted); }
.text-nowrap { white-space: nowrap; }
.price { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--c-text-muted); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border: none;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--tr-fast);
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
}
.btn-sm { padding: 3px 10px; font-size: var(--fs-xs); }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #2f6049; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #8f2e2e; }
.btn-outline {
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text-secondary);
}
.btn-outline:hover {
  background: var(--c-surface-alt);
  border-color: var(--c-text-muted);
}

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
/* Category badges — desaturated tints */
.badge.robot-arm     { background: #dce5ef; color: #3a5a7a; }
.badge.robot-hand    { background: #f0dada; color: #8a3c3c; }
.badge.robot-body    { background: #e4ddf0; color: #5a4a7a; }
.badge.robot-glove   { background: #edddea; color: #7a4a65; }
.badge.camera        { background: #d8ebee; color: #3a6a72; }
.badge.pc            { background: #f0e8d4; color: #7a6430; }
.badge.workstation   { background: #dce5ef; color: #3a5a7a; }
.badge.control       { background: #d8ebe0; color: #3a6a50; }
.badge.inference     { background: #f0e8d4; color: #7a6430; }
.badge.others        { background: #e4e4e7; color: #52525b; }

/* Status badges */
.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-pending   { background: var(--c-warning-bg); color: #6b5020; }
.status-confirmed { background: var(--c-success-bg); color: #2a5c40; }
.status-rejected  { background: var(--c-danger-bg); color: #7a2a2a; }

/* Role badges */
.role-badge {
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-admin  { background: #f0e8d4; color: #6b5020; }
.role-editor { background: #dce5ef; color: #3a5a7a; }
.role-viewer { background: #e4e4e7; color: #52525b; }

/* Category badges (pill style, reusable) */
.cat-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ── TABLES ────────────────────────────────────────────────── */
.table-wrap {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  border: 1px solid var(--c-border-light);
}
.table-wrap h3 {
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  border-bottom: 1px solid var(--c-border-light);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
  font-variant-numeric: tabular-nums;
}
th {
  background: var(--c-surface-alt);
  padding: var(--sp-3);
  text-align: left;
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  white-space: nowrap;
  position: sticky;
  top: 0;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--c-border);
}
td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--c-border-light);
  overflow: hidden;
  text-overflow: ellipsis;
}
tr:hover td {
  background: var(--c-surface-alt);
}

/* Resizable columns */
th.resizable { position: relative; }
th .resize-handle {
  position: absolute;
  right: 0; top: 0;
  width: 4px; height: 100%;
  cursor: col-resize;
  background: transparent;
}
th .resize-handle:hover,
th .resize-handle.dragging {
  background: var(--c-primary);
}

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border-light);
}
.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}
.card-body {
  padding: var(--sp-5);
}

/* ── FILTER BAR ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-4);
}
.filter-bar input,
.filter-bar select {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  background: var(--c-surface);
  font-family: var(--font-sans);
  transition: border-color var(--tr-fast);
  color: var(--c-text);
}
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(59, 79, 107, 0.12);
}
.filter-bar .count {
  margin-left: auto;
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

/* ── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 31, 0.5);
  z-index: 1000;
  padding: 40px 20px;
  overflow-y: auto;
  backdrop-filter: blur(3px);
}
.modal-overlay.active {
  display: block;
  animation: ds-fadeIn var(--tr-slow);
}
.modal {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  max-width: 1000px;
  margin: 0 auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--c-border);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--c-border-light);
}
.modal-head h2 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--c-text-muted);
  line-height: 1;
  padding: 0 var(--sp-2);
  transition: color var(--tr-fast);
}
.modal-close:hover { color: var(--c-text); }
.modal-body {
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
}

/* ── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--c-success); }
.toast-error { background: var(--c-danger); }

/* ── INLINE EDITING ────────────────────────────────────────── */
.inline-edit-input,
.inline-edit-select {
  width: 100%;
  padding: 2px 4px;
  border: 2px solid var(--c-primary);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  outline: none;
  background: var(--c-surface);
}
td[data-editable] { cursor: pointer; border-bottom: 1px dashed var(--c-border); }
td[data-editable]:hover { background: var(--c-primary-light); }

/* ── LINKS ─────────────────────────────────────────────────── */
.source-link,
a.pdf-link {
  color: var(--c-link);
  text-decoration: none;
  font-size: var(--fs-sm);
  white-space: nowrap;
  transition: color var(--tr-fast);
  border-bottom: 1px solid transparent;
}
.source-link:hover,
a.pdf-link:hover {
  border-bottom-color: var(--c-link);
}

/* ── TOOLTIPS ──────────────────────────────────────────────── */
.col-tip { position: relative; cursor: help; border-bottom: 1px dashed var(--c-text-muted); }
.col-tip::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: 100%; margin-bottom: 4px;
  background: var(--c-header); color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-normal);
  padding: 4px 8px; border-radius: var(--r-sm); white-space: normal; width: max-content; max-width: 240px;
  opacity: 0; pointer-events: none; transition: opacity var(--tr-fast); z-index: 10;
}
.col-tip:hover::after { opacity: 1; }

/* ── ANIMATIONS ────────────────────────────────────────────── */
@keyframes ds-fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
