/* ═══════════════════════════════════════════════════════════════════════════
   ZiulHub — Components
   Classes utilitárias de componente (btn, card, modal, toast, check-item).
   Depende de tokens.css + base.css.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Botão ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  padding: 0 var(--space-5);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  cursor: pointer;
  transition: background var(--motion-base) var(--ease-standard),
              border-color var(--motion-base) var(--ease-standard),
              color var(--motion-base) var(--ease-standard),
              opacity var(--motion-base) var(--ease-standard);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Variants */
.btn-primary {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-primary:active { background: var(--color-accent-pressed); border-color: var(--color-accent-pressed); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-background); }
.btn-secondary:active { background: var(--color-surface-alt); }

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

.btn-destructive {
  background: var(--color-error);
  color: var(--color-text-on-accent);
  border-color: var(--color-error);
}
.btn-destructive:hover { opacity: 0.92; }

/* Sizes */
.btn-sm { height: 36px; padding: 0 var(--space-4); font-size: var(--font-size-sm); }
.btn-lg { height: var(--touch-target-lg); padding: 0 var(--space-6); font-size: var(--font-size-lg); }
.btn-block { width: 100%; }

/* Inline (dentro de tabelas legais) */
.btn-inline {
  height: 32px;
  min-width: auto;
  padding: 0 var(--space-3);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-xs);
}

/* ── Card / Surface ────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

.card-elevated {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.card-inline {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
}

/* ── Modal / Overlay ───────────────────────────────────────────────────── */
.zh-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-standard);
}

.zh-modal-overlay[aria-hidden="false"],
.zh-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.zh-modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - var(--space-8));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform var(--motion-medium) var(--ease-emphasized),
              opacity var(--motion-medium) var(--ease-emphasized);
}

.zh-modal-overlay.open .zh-modal-box { transform: translateY(0) scale(1); opacity: 1; }

.zh-modal-sm .zh-modal-box { max-width: 380px; }
.zh-modal-lg .zh-modal-box { max-width: 800px; }
.zh-modal-xl .zh-modal-box { max-width: 1024px; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.zh-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--color-surface);
  color: var(--color-text-primary);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  z-index: var(--z-toast);
  transition: transform var(--motion-medium) var(--ease-emphasized);
  max-width: calc(100vw - var(--space-8));
}

.zh-toast.show { transform: translateX(-50%) translateY(0); }

.zh-toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.zh-toast-success svg { stroke: var(--color-success); }
.zh-toast-error svg   { stroke: var(--color-error); }
.zh-toast-info svg    { stroke: var(--color-accent); }

/* ── Checklist / Check-item (iPad-friendly) ────────────────────────────── */
.zh-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-target-min);
  padding: var(--space-1) 0;
  cursor: pointer;
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  user-select: none;
}

.zh-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.zh-check-box {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  transition: all var(--motion-fast) var(--ease-standard);
  flex-shrink: 0;
  position: relative;
}

.zh-check input:checked ~ .zh-check-box {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.zh-check input:checked ~ .zh-check-box::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 12px;
  border: solid var(--color-text-on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.zh-check input:focus-visible ~ .zh-check-box {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Badge ─────────────────────────────────────────────────────────────── */
.zh-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-wide);
  background: var(--color-background);
  color: var(--color-text-secondary);
  line-height: 1.4;
}
.zh-badge-accent  { background: var(--color-accent-soft);  color: var(--color-accent); }
.zh-badge-success { background: var(--color-success-soft); color: var(--color-success); }
.zh-badge-error   { background: var(--color-error-soft);   color: var(--color-error); }
.zh-badge-warning { background: var(--color-warning-soft); color: #b85d00; }

/* ── Input field (wrapper genérico para novos forms) ───────────────────── */
.zh-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.zh-field-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.zh-input,
.zh-select,
.zh-textarea {
  height: var(--touch-target-min);
  padding: 0 var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  transition: border-color var(--motion-fast) var(--ease-standard);
  outline: none;
}

.zh-textarea {
  height: auto;
  min-height: 96px;
  padding: var(--space-3);
  resize: vertical;
}

.zh-input::placeholder,
.zh-textarea::placeholder {
  color: var(--color-text-tertiary);
}

.zh-input:focus,
.zh-select:focus,
.zh-textarea:focus {
  border-color: var(--color-accent);
}

.zh-input:disabled,
.zh-select:disabled,
.zh-textarea:disabled {
  background: var(--color-background);
  color: var(--color-text-secondary);
  cursor: not-allowed;
}

.zh-input-error { border-color: var(--color-error) !important; }
.zh-input-ok    { border-color: var(--color-success) !important; }

/* ── Divider ───────────────────────────────────────────────────────────── */
.zh-divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: var(--space-4) 0;
}

/* ── Helper: stack e cluster (layout inline simples) ───────────────────── */
.zh-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.zh-stack-lg { gap: var(--space-6); }
.zh-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
