/* =========================================================================
   components.css — definições CANÔNICAS dos componentes compartilhados.
   Resolve as colisões que existiam entre style.css e flipbook-viewer.css:
   .btn, .loading-spinner e @keyframes spin agora existem UMA vez só.
   Keyframes são globais e não têm escopo: duplicá-los faz o último arquivo
   carregado vencer silenciosamente. Variações usam nome próprio (fb-*).
   ========================================================================= */

/* O atributo `hidden` precisa vencer qualquer `display` de componente.
   Sem isto, esconder um `.control-btn` (que é `inline-flex`) não surte efeito
   nenhum — o UA define `[hidden]{display:none}` com especificidade zero. */
[hidden] { display: none !important; }

/* ---- Botão ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  color: var(--c-text);
  font: 500 var(--fs-sm)/1 var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:hover  { background: var(--c-surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--c-brand-600); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn--primary   { background: var(--c-brand-600); color: var(--c-text-on-brand); }
.btn--primary:hover { background: var(--c-brand-700); }
.btn--secondary { background: var(--c-surface); border-color: var(--c-border); }
.btn--danger    { background: var(--c-danger); color: #fff; }
.btn--danger:hover { background: var(--c-danger-700); }
.btn--ghost     { background: transparent; }
.btn--ghost:hover { background: var(--c-surface-2); }
.btn--sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn--lg { min-height: 48px; padding: 0 var(--sp-5); font-size: var(--fs-md); }
.btn--icon { width: 40px; min-height: 40px; padding: 0; }

/* Compatibilidade com o markup legado (btn-primary, btn-sm, …).
   Novo código deve usar os modificadores com duplo hífen. */
.btn-primary   { background: var(--c-brand-600); color: var(--c-text-on-brand); }
.btn-secondary { background: var(--c-surface); border-color: var(--c-border); }
.btn-danger    { background: var(--c-danger); color: #fff; }
.btn-success   { background: var(--c-success); color: #fff; }
.btn-sm        { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }

/* ---- Botão de controle (toolbar) -------------------------------------- */
.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--c-text-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.control-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.control-btn:focus-visible { outline: 2px solid var(--c-brand-600); outline-offset: 2px; }
.control-btn[disabled] { opacity: .35; pointer-events: none; }
.control-btn.is-active { background: var(--c-brand-50); color: var(--c-brand-600); }

/* ---- Spinner ---------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }

.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-brand-600);
  border-radius: var(--r-full);
  animation: spin .8s linear infinite;
}
.loading-spinner--sm { width: 18px; height: 18px; border-width: 2px; }
.loading-spinner--on-dark { border-color: rgba(255,255,255,.25); border-top-color: #fff; }

/* ---- Campos ----------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.field__label { font: 500 var(--fs-xs)/1.3 var(--font-sans); color: var(--c-text-2); }
.field__hint  { font: 400 var(--fs-xs)/1.3 var(--font-sans); color: var(--c-text-3); }

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  font: 400 var(--fs-sm)/1.4 var(--font-sans);
  box-sizing: border-box;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-brand-600);
  box-shadow: 0 0 0 3px var(--c-brand-100);
}
.textarea { min-height: 80px; resize: vertical; }

/* ---- Alerta / toast ---------------------------------------------------- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  font: 400 var(--fs-sm)/1.4 var(--font-sans);
}
.alert--success { border-color: #bbf7d0; background: #f0fdf4; color: #14532d; }
.alert--error   { border-color: #fecaca; background: #fef2f2; color: #7f1d1d; }
.alert--warning { border-color: #fde68a; background: #fffbeb; color: #78350f; }
.alert--info    { border-color: var(--c-brand-100); background: var(--c-brand-50); color: #1e3a8a; }

/* ---- Modal ------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
  z-index: var(--z-modal);
}
.modal.is-open, .modal.active { display: flex; }
.modal__panel {
  width: min(560px, 92vw);
  max-height: 88vh; overflow: auto;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--sh-4);
}
.modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.modal__title  { margin: 0; font: 600 var(--fs-lg)/1.3 var(--font-sans); color: var(--c-text); }

/* ---- Progresso --------------------------------------------------------- */
.progress { height: 4px; background: var(--c-surface-3); border-radius: var(--r-full); overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--c-brand-600); transition: width var(--t-base) var(--ease); }

/* ---- Área de soltar ----------------------------------------------------- */
.dropzone {
  display: grid; place-items: center; gap: var(--sp-2);
  padding: var(--sp-6);
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  color: var(--c-text-2);
  text-align: center;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.dropzone.is-over { border-color: var(--c-brand-600); background: var(--c-brand-50); }
