/*
 * OQ Print — Component Library
 * Version: 1.0.0 · March 2026
 *
 * Подключение:
 *   <link rel="stylesheet" href="../../shared/components.css">
 *
 * Зависимости:
 *   - shared/base.css (CSS-переменные --bg, --surface, --border, --text, --muted, --accent)
 *   - Google Fonts: Roboto (для UI-компонентов)
 *
 * Содержимое:
 *   1. Токены компонентов
 *   2. Button
 *   3. Badge
 *   4. Card
 *   5. Form (Input, Select)
 *   6. Custom Dropdown — Basic
 *   7. Custom Dropdown — With Description
 *   8. Custom Dropdown — Table 3-col
 *   9. Custom Dropdown — Table 2-col
 *  10. Custom Dropdown — Space-between (v12)
 *  11. Date Card + Date Grid
 *  12. Stepper
 *  13. Addon Toggle
 */


/* ─────────────────────────────────────────
   1. ТОКЕНЫ КОМПОНЕНТОВ
   ───────────────────────────────────────── */

:root {
  /* Палитра — Grey */
  --grey-50:  #f5f5f5;
  --grey-100: #edeeee;
  --grey-200: #c3c7c9;
  --grey-300: #9ba0a3;
  --grey-400: #777b7d;
  --grey-500: #555859;
  --grey-600: #343637;
  --grey-700: #171819;

  /* Палитра — Primary */
  --primary-50:  #f0f7ff;
  --primary-100: #e2efff;
  --primary-200: #93cbff;
  --primary-300: #00a8f4;
  --primary-400: #0081bd;
  --primary-500: #005c89;
  --primary-600: #003957;
  --primary-700: #001a2b;

  /* Motion */
  --duration-fast:   100ms;
  --duration-base:   150ms;
  --duration-slow:   250ms;
  --easing-default:  ease;
  --easing-in-out:   ease-in-out;
}


/* ─────────────────────────────────────────
   2. BUTTON
   ───────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Raleway', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  padding: 10px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: .01em;
  transition:
    background var(--duration-base) var(--easing-default),
    color      var(--duration-base) var(--easing-default),
    border-color var(--duration-base) var(--easing-default);
  user-select: none;
  white-space: nowrap;
}

/* Variants */
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--primary-500); border-color: var(--primary-500); }

.btn--secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn--secondary:hover { background: var(--accent); color: #fff; }

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

.btn--danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Sizes */
.btn--sm { font-size: 0.8rem;  padding: 7px 14px; }
.btn--lg { font-size: 1rem;    padding: 14px 28px; }
.btn--full { width: 100%; }

/* Disabled */
.btn:disabled,
.btn--disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}


/* ─────────────────────────────────────────
   3. BADGE
   ───────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  white-space: nowrap;
}

.badge--production { background: #dcfce7; color: #166534; }
.badge--prototype  { background: #e2efff; color: #005c89; }
.badge--concept    { background: #edeeee; color: #555859; }
.badge--wip        { background: #fff3cd; color: #856404; }
.badge--error      { background: #fee2e2; color: #991b1b; }
.badge--stable     { background: #dcfce7; color: #166534; }
.badge--beta       { background: #fff3cd; color: #856404; }
.badge--deprecated { background: #fee2e2; color: #991b1b; }

@media (prefers-color-scheme: dark) {
  .badge--production,
  .badge--stable     { background: #14532d; color: #86efac; }
  .badge--prototype  { background: #001a2b; color: #93cbff; }
  .badge--concept    { background: #343637; color: #9ba0a3; }
  .badge--wip,
  .badge--beta       { background: #3d2e00; color: #ffd666; }
  .badge--error,
  .badge--deprecated { background: #450a0a; color: #fca5a5; }
}


/* ─────────────────────────────────────────
   4. CARD
   ───────────────────────────────────────── */

.card {
  padding: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.card__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.card__desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.card:hover {
  border-color: var(--accent);
}


/* ─────────────────────────────────────────
   5. FORM — Input, Select
   ───────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.field__label--muted { color: var(--muted); font-weight: 400; }

.field__hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.field__hint--error { color: #dc2626; }

.input {
  width: 100%;
  font-family: 'Raleway', system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--duration-base);
}
.input:focus       { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
.input--error      { border-color: #dc2626; }

.select {
  width: 100%;
  font-family: 'Raleway', system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 9px 12px;
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--duration-base);
}
.select:focus { border-color: var(--accent); }


/* ─────────────────────────────────────────
   6. CUSTOM DROPDOWN — Basic
   Atom: .cd__trigger, .cd__option
   Molecule: .cd
   ───────────────────────────────────────── */

.cd, .cd * {
  font-family: 'Roboto', system-ui, sans-serif;
  box-sizing: border-box;
}

.cd {
  position: relative;
  width: 100%;
}

.cd__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--grey-200);
  padding: 8px 36px 8px 12px;
  font-size: 14px;
  color: var(--grey-700);
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--duration-base);
  position: relative;
  min-height: 40px;
}

.cd__trigger:hover,
.cd.open .cd__trigger { border-color: var(--primary-400); }

/* Chevron */
.cd__trigger::after {
  content: '';
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23777b7d' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
  transition: transform var(--duration-base);
}

.cd.open .cd__trigger::after {
  transform: translateY(-50%) rotate(180deg);
}

.cd__label {
  flex: none;
  line-height: 1;
  white-space: nowrap;
}

.cd__list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 100;
  max-height: 360px;
  overflow-y: auto;
}

.cd.open .cd__list { display: block; }

.cd__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 40px;
  font-size: 14px;
  color: var(--grey-700);
  cursor: pointer;
  border-top: 1px solid var(--grey-100);
  transition: background var(--duration-fast);
}

.cd__option:first-child { border-top: none; }
.cd__option:hover       { background: var(--primary-100); }
.cd__option.selected    { background: var(--primary-50); }

.cd__option-label { flex: none; white-space: nowrap; }

/* Badge внутри опции */
.cd__badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
  flex-shrink: 0;
  background: #22c55e;
  color: #fff;
}


/* ─────────────────────────────────────────
   7. CUSTOM DROPDOWN — With Description
   ───────────────────────────────────────── */

.cd--desc .cd__trigger,
.cd--desc .cd__option {
  align-items: flex-start;
  padding-top: 0;
  padding-bottom: 0;
  min-height: 64px;
}

.cd__thumb {
  width: 56px;
  align-self: stretch;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--grey-100);
  margin: 0 12px 0 -12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--grey-400);
}

.cd__option-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
}

.cd__option-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-700);
  line-height: 1.3;
}

.cd__option-desc {
  font-size: 12px;
  color: var(--grey-400);
  line-height: 1.4;
}

.cd__price-addon {
  margin-left: auto;
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-500);
  white-space: nowrap;
  align-self: center;
  padding-left: 8px;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────
   8. CUSTOM DROPDOWN — Table 3-col
   Колонки: Тираж / Единица / Цена
   ───────────────────────────────────────── */

.cd--table .cd__trigger,
.cd--table .cd__option {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  column-gap: 16px;
  align-items: start;
  justify-items: start;
  min-height: auto;
}

.cd--table .cd__trigger { padding: 10px 36px 10px 16px; }
.cd--table .cd__option  { padding: 14px 16px; }

.cd-tbl-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  column-gap: 16px;
  padding: 4px 36px 6px 16px;
  font-size: 12px;
  color: var(--grey-300);
  font-family: 'Roboto', system-ui, sans-serif;
}

.cd__tbl-qty   { font-size: 14px; font-weight: 500; color: var(--grey-700); white-space: nowrap; }
.cd__tbl-unit  { font-size: 13px; color: var(--grey-400); white-space: nowrap; }

.cd__tbl-price { display: flex; flex-direction: column; gap: 2px; }

.cd__tbl-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.cd__tbl-total {
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-700);
  white-space: nowrap;
}

.cd__tbl-cross {
  font-size: 12px;
  color: var(--grey-300);
  text-decoration: line-through;
  position: relative;
  top: 1px;
  white-space: nowrap;
}

.cd--table .cd__option.selected { background: var(--primary-50); }


/* ─────────────────────────────────────────
   9. CUSTOM DROPDOWN — Table 2-col
   Колонки: Тираж / Цена (grid 70px + 1fr)
   ───────────────────────────────────────── */

.cd--tbl2 .cd__trigger,
.cd--tbl2 .cd__option {
  display: grid;
  grid-template-columns: 70px 1fr;
  column-gap: 16px;
  align-items: center;
  justify-items: start;
  min-height: auto;
}

.cd--tbl2 .cd__trigger { padding: 12px 36px 12px 16px; }
.cd--tbl2 .cd__option  { padding: 14px 16px; }

.cd-tbl2-head {
  display: grid;
  grid-template-columns: 70px 1fr;
  column-gap: 16px;
  padding: 4px 36px 6px 16px;
  font-size: 12px;
  color: var(--grey-300);
  font-family: 'Roboto', system-ui, sans-serif;
}

.cd__tbl2-qty   { font-size: 14px; font-weight: 500; color: var(--grey-700); white-space: nowrap; }
.cd__tbl2-price { font-size: 14px; color: var(--grey-500); white-space: nowrap; }
.cd__tbl2-curr  { font-size: 11px; }

.cd--tbl2 .cd__option.selected { background: var(--primary-50); }


/* ─────────────────────────────────────────
   10. CUSTOM DROPDOWN — Space-between (v12)
   Тираж и цена по разным краям (flex)
   ───────────────────────────────────────── */

.cd--v12 .cd__trigger,
.cd--v12 .cd__option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: auto;
}

.cd--v12 .cd__trigger { padding: 12px 36px 12px 16px; }
.cd--v12 .cd__option  { padding: 14px 16px; }

.cd--v12 .cd__option.selected { background: var(--primary-50); }

/* Шапка v12 — inline flex (не grid) */
.cd--v12 .cd-v12-head {
  display: flex;
  justify-content: space-between;
  padding: 4px 36px 6px 16px;
  font-size: 12px;
  color: var(--grey-300);
  font-family: 'Roboto', system-ui, sans-serif;
}

.cd--v12 .cd-v12-head__left {
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-700);
}


/* ─────────────────────────────────────────
   11. DATE CARD + DATE GRID
   Atom: .date-card
   Organism: .dates-grid
   ───────────────────────────────────────── */

.dates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dates-grid--2 { grid-template-columns: repeat(2, 1fr); }

.date-card,
.date-card * {
  font-family: 'Roboto', system-ui, sans-serif;
  box-sizing: border-box;
}

.date-card {
  border: 1px solid var(--grey-200);
  padding: 10px 12px;
  cursor: pointer;
  transition:
    border-color var(--duration-base) var(--easing-default),
    background   var(--duration-base) var(--easing-default);
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  user-select: none;
  background: #fff;
}

.date-card:hover    { border-color: var(--primary-200); }
.date-card.selected { border-color: var(--primary-400); }

.date-card__price {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-700);
}

.date-card__price-curr { font-size: 11px; }

.date-card__when {
  font-size: 11px;
  color: var(--grey-400);
}

.date-card__badge {
  position: absolute;
  right: 6px;
  top: 6px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  padding: 2px 5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}


/* ─────────────────────────────────────────
   12. STEPPER
   Счётчик для ручного ввода тиража
   ───────────────────────────────────────── */

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--grey-200);
  font-family: 'Roboto', system-ui, sans-serif;
}

.stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--grey-500);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  flex-shrink: 0;
}

.stepper__btn:hover { background: var(--primary-100); color: var(--primary-400); }

.stepper__val {
  width: 56px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-700);
  border: none;
  border-left: 1px solid var(--grey-200);
  border-right: 1px solid var(--grey-200);
  padding: 8px 4px;
  outline: none;
  background: #fff;
  -moz-appearance: textfield;
}

.stepper__val::-webkit-outer-spin-button,
.stepper__val::-webkit-inner-spin-button { -webkit-appearance: none; }


/* ─────────────────────────────────────────
   13. ADDON TOGGLE
   Добавление опциональных услуг к заказу
   Состояния: empty → add → active → remove
   ───────────────────────────────────────── */

.addon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--grey-200);
  cursor: pointer;
  font-family: 'Roboto', system-ui, sans-serif;
  font-size: 13px;
  transition: border-color var(--duration-base), background var(--duration-base);
  user-select: none;
}

/* Empty — серый, опция недоступна или не выбрана */
.addon--empty {
  color: var(--grey-300);
  background: var(--grey-50);
  cursor: default;
}

/* Add — доступна, не добавлена */
.addon--add {
  color: var(--grey-500);
  background: #fff;
}

.addon--add:hover { border-color: var(--primary-400); color: var(--grey-700); }

/* Active — добавлена */
.addon--active {
  border-color: var(--primary-400);
  color: var(--grey-700);
  background: var(--primary-50);
}

/* Remove — показывает кнопку удаления при hover */
.addon--active:hover {
  border-color: #ef4444;
  background: #fff5f5;
}

.addon__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.addon__label {
  flex: 1;
  line-height: 1.3;
}

.addon__price {
  font-size: 12px;
  color: var(--grey-400);
  white-space: nowrap;
}

.addon--active .addon__price {
  color: var(--primary-400);
  font-weight: 500;
}
