/* Componente reutilizabile: butoane, câmpuri, carduri, chips, sheet, toast, etc. */

/* Butoane */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch);
  padding: 0 var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: var(--on-brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-outline { background: transparent; border-color: var(--border-strong); }
.btn-sm { min-height: 38px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-icon { width: var(--touch); padding: 0; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
}
.card.pad-0 { padding: 0; }
a.card, button.card { display: block; text-align: left; width: 100%; cursor: pointer; color: inherit; text-decoration: none; }
a.card:hover, button.card:hover { box-shadow: var(--shadow-2); }

/* Listă de rânduri */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--touch);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none;
  background: var(--surface);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: var(--fs-sm); color: var(--text-muted); }
.list-item .li-chevron { color: var(--text-faint); }

/* Câmpuri de formular */
.field { display: block; margin-bottom: var(--sp-4); }
.field > label, .field-label {
  display: block; font-weight: 600; font-size: var(--fs-sm);
  margin-bottom: var(--sp-1);
}
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-1); }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  min-height: var(--touch);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
}
.textarea { min-height: 96px; resize: vertical; padding-top: var(--sp-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.input-invalid { border-color: var(--danger); }
.input-suffix { display: flex; align-items: center; }
.input-suffix .suffix { padding: 0 var(--sp-3); color: var(--text-muted); }

/* Segmented control (ex. temă, unități) */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 3px; flex-wrap: wrap; }
.segmented button {
  border: none; background: transparent; color: var(--text-muted);
  padding: var(--sp-2) var(--sp-3); border-radius: calc(var(--radius) - 3px);
  font-weight: 600; cursor: pointer; min-height: 40px;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* Switch */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: var(--radius-full); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: var(--shadow-1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(22px); }

/* Chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 4px var(--sp-2); border-radius: var(--radius-full);
  background: var(--surface-2); font-size: var(--fs-sm); font-weight: 600;
  border: 1px solid var(--border);
}
.chip-check { cursor: pointer; user-select: none; }
.chip-check[aria-pressed="true"] { background: var(--brand-100); border-color: var(--brand-300); color: var(--brand-800); }
:root[data-theme="dark"] .chip-check[aria-pressed="true"] { background: var(--brand-800); border-color: var(--brand-600); color: var(--brand-100); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--danger); color: #fff; font-size: var(--fs-xs); font-weight: 700; }
.badge-muted { background: var(--surface-sunken); color: var(--text-muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Bottom sheet / modal */
.scrim { position: fixed; inset: 0; background: rgba(8,14,22,0.5); z-index: var(--z-sheet); opacity: 0; animation: fade .15s forwards; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-3);
  max-height: 92dvh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%); animation: slide-up .2s forwards;
}
.sheet-header { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.sheet-header h2 { font-size: var(--fs-lg); flex: 1; }
.sheet-body { padding: var(--sp-4); overflow-y: auto; }
.sheet-footer { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); display: flex; gap: var(--sp-3); }
.sheet-footer .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; transform: translate(-50%, 0); width: min(560px, 96vw); bottom: 50%; border-radius: var(--radius-lg); animation: pop .2s forwards; }
}
@keyframes fade { to { opacity: 1; } }
@keyframes slide-up { to { transform: translateY(0); } }
@keyframes pop { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 50%); opacity: 1; } }

/* Toast */
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-3)); z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); pointer-events: none; padding: 0 var(--sp-4); }
.toast {
  pointer-events: auto;
  background: var(--text); color: var(--surface);
  border-radius: var(--radius-full); padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3); box-shadow: var(--shadow-3);
  max-width: 560px; width: fit-content; font-size: var(--fs-sm);
}
.toast button { background: transparent; border: none; color: var(--brand-200); font-weight: 700; cursor: pointer; padding: var(--sp-1) var(--sp-2); }
.toast.toast-success { background: var(--success); color: #fff; }
.toast.toast-error { background: var(--danger); color: #fff; }

/* Empty state */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--text-muted); }
.empty-state .ico { width: 56px; height: 56px; margin: 0 auto var(--sp-3); opacity: 0.5; }
.empty-state h3 { color: var(--text); margin-bottom: var(--sp-2); }

/* Disclaimer (dozaj etc.) */
.disclaimer {
  background: var(--warning-bg); color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: var(--radius); padding: var(--sp-3); font-size: var(--fs-sm);
  display: flex; gap: var(--sp-2);
}
.disclaimer .ico { flex: none; width: 20px; height: 20px; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-sunken), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Grid de carduri */
.grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Stat tile */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); }
.tile .val { font-size: var(--fs-2xl); font-weight: 800; }
.tile .lbl { font-size: var(--fs-sm); color: var(--text-muted); }
