/* НаШ Brand Design System — Reusable Components
 * All color values MUST use var(--token) — no hardcoded hex.
 * Depends on: tokens.css (must be imported first)
 * Updated: 2026-05-05 — aligned to warm-paper tokens v5
 */

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 12px;
  font-family: var(--f-sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border: none;
  text-decoration: none;
  min-height: 44px; /* WCAG AA touch target */
  min-width: 44px;
  transition: opacity .1s ease, box-shadow .1s ease, transform .08s ease;
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active {
  transform: scale(.97);
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

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

.btn-primary:hover:not(:disabled) {
  opacity: .88;
  box-shadow: 0 4px 14px rgba(226, 59, 28, .35);
}

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--paper-2);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--line);
}

/* ── Chip / Badge ────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--f-sans);
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  line-height: 1.4;
}

.chip-accent {
  background: var(--accent);
  color: var(--white);
  border-color: transparent;
}

/* ── Card ────────────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  border: 1px solid var(--line);
}

.card-warm {
  background: var(--paper-2);
}

/* ── Input ───────────────────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px; /* min 16px — prevents iOS zoom-on-focus */
  font-family: var(--f-sans);
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
  min-height: 44px; /* WCAG AA touch target */
}

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

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 59, 28, .12);
}

.input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

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

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 900;
  padding: 16px;
}

@media (min-width: 480px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal {
  position: relative;
  background: var(--paper);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .18);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 16px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--paper-2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-2);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--f-sans);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .22);
  z-index: 1000;
  max-width: calc(100vw - 32px);
  text-align: center;
  pointer-events: none;
}

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

/* ── Security Footer (Phase 29 invariant — permanent in shell) ───────── */
.security-footer {
  background: var(--ink);
  color: var(--white);
  padding: 32px 16px;
  text-align: center;
}

.security-footer h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--white);
}

.security-footer p {
  font-size: 13px;
  color: rgba(255, 255, 255, .65);
  margin: 4px 0;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Utility ─────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

/* Label for form fields */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

/* Page wrapper */
.page {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

/* Section heading */
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 16px;
}

/* Phase 20-26 — Role switcher in app-header (visible & impersonates any test user) */
.role-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;   /* push to right side of header */
}
.role-switcher__label {
  font-size: 13px;
  color: var(--muted, #6b6557);
  font-weight: 500;
  white-space: nowrap;
}
.role-switcher__select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--accent, #e23b1c);
  background: var(--paper-2, #fff);
  color: var(--ink, #1a1410);
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-width: 160px;
  max-width: 240px;
}
.role-switcher__select:hover { background: var(--paper, #fbf6ee); }
.role-switcher__select:focus { outline: 2px solid var(--accent, #e23b1c); outline-offset: 2px; }
.role-switcher__select:disabled { opacity: 0.5; cursor: wait; }
.role-switcher__logout {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line, #e5dfcd);
  background: var(--paper-2, #fff);
  color: var(--ink-muted, #6b6258);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  margin-left: 6px;
}
.role-switcher__logout:hover { color: var(--accent, #e23b1c); border-color: var(--accent, #e23b1c); }
.role-switcher__msg {
  font-size: 13px;
  color: var(--muted, #6b6557);
  font-style: italic;
}
@media (max-width: 600px) {
  .role-switcher__label { display: none; }
  .role-switcher__select { min-width: 140px; font-size: 13px; padding: 6px 10px; }
}
