/* ==========================================================================
   BrandPalette AI — style.css
   Shell de aplicação (sidebar + topbar + views), inspirado em Vercel/Linear/
   Stripe/Delphi. Tokens em CSS Variables, layout em Grid/Flexbox, tema
   claro/escuro via [data-theme], responsivo mobile-first.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================================================
   1. DESIGN TOKENS — CSS VARIABLES
   ========================================================================== */

:root {
  /* --- Tipografia --- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.5rem;

  --lh-tight: 1.15;
  --lh-normal: 1.5;
  --tracking-tight: -0.03em;
  --tracking-tighter: -0.045em;

  /* --- Espaçamento --- */
  --space-3xs: 2px;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 72px;

  /* --- Raios --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* --- Transições --- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 120ms var(--ease-out);
  --t-base: 200ms var(--ease-out);
  --t-slow: 420ms var(--ease-out);

  /* --- Camadas --- */
  --z-sidebar: 100;
  --z-sidebar-overlay: 90;
  --z-toast: 400;

  /* --- Dimensões do shell --- */
  --sidebar-width: 248px;
  --topbar-height: 64px;
  --container-max: 1280px;

  /* --- Acento de marca (chrome da aplicação, fixo) --- */
  --accent-hue: 251;
  --accent: hsl(var(--accent-hue) 78% 66%);
  --accent-hover: hsl(var(--accent-hue) 85% 72%);
  --accent-active: hsl(var(--accent-hue) 70% 58%);
  --accent-contrast: #ffffff;

  --success: #2fd699;
  --danger: #f66a6a;
  --warning: #f5b955;

  /* --- Tokens de marca (editáveis via view Configurações) --- */
  --brand-radius: var(--radius-md);
  --brand-button-radius: var(--radius-md);
  --brand-border-width: 1px;
  --brand-columns: 3;
  --brand-container-max: 960px;
  --brand-font-title: var(--font-sans);
  --brand-font-body: var(--font-sans);
}

/* --- Tema escuro (padrão) --- */
:root,
[data-theme='dark'] {
  --bg: #08080a;
  --bg-elevated: #0d0d10;
  --surface: #111114;
  --surface-2: #17171b;
  --surface-3: #1e1e23;
  --border: #232329;
  --border-strong: #2f2f36;

  --text-primary: #f4f4f6;
  --text-secondary: #9a9aa6;
  --text-tertiary: #6b6b76;

  --accent-soft: hsl(var(--accent-hue) 78% 66% / 0.14);
  --accent-border: hsl(var(--accent-hue) 78% 66% / 0.35);

  --shadow-color: 240 15% 2%;
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.4);
  --shadow-md: 0 8px 24px -8px hsl(var(--shadow-color) / 0.55);
  --shadow-lg: 0 24px 48px -16px hsl(var(--shadow-color) / 0.65);
  --shadow-glow: 0 0 0 1px var(--accent-border), 0 8px 32px -8px hsl(var(--accent-hue) 78% 60% / 0.35);

  --grid-line: rgba(255, 255, 255, 0.05);
  --scrim: rgba(4, 4, 6, 0.72);
}

/* --- Tema claro --- */
[data-theme='light'] {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f6;
  --surface-3: #ececef;
  --border: #e6e6ea;
  --border-strong: #d8d8df;

  --text-primary: #0b0b0f;
  --text-secondary: #61616b;
  --text-tertiary: #8a8a92;

  --accent-soft: hsl(var(--accent-hue) 70% 55% / 0.08);
  --accent-border: hsl(var(--accent-hue) 70% 55% / 0.3);

  --shadow-color: 240 15% 60%;
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.12);
  --shadow-md: 0 8px 24px -8px hsl(var(--shadow-color) / 0.22);
  --shadow-lg: 0 24px 48px -16px hsl(var(--shadow-color) / 0.28);
  --shadow-glow: 0 0 0 1px var(--accent-border), 0 8px 32px -8px hsl(var(--accent-hue) 70% 55% / 0.22);

  --grid-line: rgba(10, 10, 15, 0.05);
  --scrim: rgba(20, 20, 25, 0.4);
}

/* --- Densidade de espaçamento (ajustável na view Configurações) --- */
.density-compacto {
  --space-md: 12px;
  --space-lg: 18px;
}

.density-espacoso {
  --space-md: 20px;
  --space-lg: 32px;
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

[data-theme='light'] {
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background-color: var(--bg);
  transition: background-color var(--t-base), color var(--t-base);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
select {
  font-family: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

fieldset {
  border: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  flex-shrink: 0;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   3. BOTÕES (primitivos)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: 40px;
  padding: 0 var(--space-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background-color var(--t-fast), border-color var(--t-fast),
    color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-glow);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn--text {
  height: auto;
  padding: 0;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.btn--text:hover {
  color: var(--text-secondary);
}

.btn--icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.btn--icon:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.btn--full {
  width: 100%;
}

/* ==========================================================================
   4. APP SHELL (grid principal: sidebar + conteúdo)
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.app-shell__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

@media (min-width: 960px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }
}

/* ==========================================================================
   5. SIDEBAR
   ========================================================================== */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(280px, 84vw);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: var(--space-md);
  transform: translateX(-100%);
  transition: transform var(--t-base);
}

.sidebar--open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-sidebar-overlay);
  background: var(--scrim);
  backdrop-filter: blur(2px);
}

@media (min-width: 960px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    transform: none;
  }

  .sidebar-overlay {
    display: none;
  }
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-xs) var(--space-lg);
}

.sidebar__logo {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
}

.sidebar__title {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
}

.sidebar__nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.sidebar__nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color var(--t-fast), color var(--t-fast);
}

.sidebar__nav-icon {
  color: var(--text-tertiary);
  transition: color var(--t-fast);
}

.sidebar__nav-link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar__nav-link:hover .sidebar__nav-icon {
  color: var(--text-primary);
}

.sidebar__nav-link--active {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.sidebar__nav-link--active .sidebar__nav-icon {
  color: var(--accent);
}

.sidebar__footer {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.sidebar__theme-toggle {
  width: 100%;
  height: auto;
  justify-content: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  position: relative;
}

.sidebar__theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.theme-toggle__icon {
  position: relative;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.theme-toggle__icon--sun,
.theme-toggle__icon--moon {
  display: none;
}

[data-theme='light'] .theme-toggle__icon--sun,
[data-theme='dark'] .theme-toggle__icon--moon {
  display: block;
}

/* ==========================================================================
   6. TOPBAR
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  height: var(--topbar-height);
  padding-inline: var(--space-md);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.topbar__menu-toggle {
  flex-shrink: 0;
}

.topbar__heading {
  flex: 1;
  min-width: 0;
}

.topbar__title {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__subtitle {
  display: none;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.topbar__cta {
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .topbar__subtitle {
    display: block;
  }
}

@media (min-width: 960px) {
  .topbar {
    padding-inline: var(--space-lg);
  }

  .topbar__menu-toggle {
    display: none;
  }
}

/* ==========================================================================
   7. VIEW CONTAINER / VIEWS
   ========================================================================== */

.view-container {
  flex: 1;
  padding: var(--space-lg) var(--space-md) var(--space-3xl);
  max-width: var(--container-max);
  width: 100%;
  margin-inline: auto;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  animation: view-fade-in var(--t-slow);
}

.view--active {
  display: flex;
}

@keyframes view-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 960px) {
  .view-container {
    padding: var(--space-xl) var(--space-lg) var(--space-3xl);
  }
}

/* ==========================================================================
   8. FORM FIELDS (compartilhado por várias views)
   ========================================================================== */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.form-field__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-secondary);
}

.form-field__input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

select.form-field__input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--text-primary);
}

.form-field__input::placeholder {
  color: var(--text-tertiary);
}

.form-field__input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.form-field__hint {
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
}

.form-field__range {
  width: 100%;
  accent-color: var(--accent);
  height: 4px;
  margin-top: var(--space-xs);
}

.form-field__range-output {
  display: inline-block;
  margin-top: var(--space-2xs);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
}

/* ==========================================================================
   9. DASHBOARD
   ========================================================================== */

.identity-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.identity-form-card__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

.identity-form-card__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-top: var(--space-3xs);
}

.identity-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

.identity-form__submit {
  align-self: start;
}

@media (min-width: 640px) {
  .identity-form {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .identity-form__submit {
    grid-column: 1 / -1;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-card--wide {
    grid-column: span 3;
  }
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.summary-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.summary-card__title {
  font-size: var(--fs-sm);
  font-weight: 700;
}

.summary-card__link {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--accent);
}

.summary-card__link:hover {
  color: var(--accent-hover);
}

.summary-card__body {
  min-height: 40px;
}

.summary-card__empty {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.summary-card__row {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-normal);
}

.summary-card__row + .summary-card__row {
  margin-top: var(--space-2xs);
}

.summary-card__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.summary-card__swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin-top: var(--space-xs);
}

.tag {
  padding: var(--space-3xs) var(--space-xs);
  font-size: var(--fs-2xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   10. LAYOUT DA VIEW PALETA (sidebar de input + conteúdo)
   ========================================================================== */

.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.app-layout__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

@media (min-width: 960px) {
  .app-layout {
    grid-template-columns: 320px minmax(0, 1fr);
    gap: var(--space-xl);
  }

  .input-panel {
    position: sticky;
    top: calc(var(--topbar-height) + var(--space-lg));
  }
}

.input-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.input-panel__container {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.input-panel__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

.input-panel__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.input-panel__tabs {
  display: flex;
  gap: var(--space-3xs);
  padding: var(--space-3xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.input-panel__tab {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  transition: background-color var(--t-fast), color var(--t-fast);
}

.input-panel__tab:hover {
  color: var(--text-secondary);
}

.input-panel__tab--active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.input-panel__tabpanel {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.input-panel__options {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

/* --- Upload dropzone --- */

.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

.upload-dropzone:hover,
.upload-dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-dropzone__icon {
  width: 22px;
  height: 22px;
  color: var(--text-tertiary);
}

.upload-dropzone__text {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.upload-dropzone__browse {
  color: var(--accent);
  font-weight: 600;
}

.upload-preview {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.upload-preview__image {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.upload-preview__remove {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  background: var(--scrim);
  color: #fff;
}

/* --- Style options --- */

.style-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xs);
}

.style-option {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), color var(--t-fast), background-color var(--t-fast);
}

.style-option:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.style-option.is-active {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-soft);
}

.style-option__swatch {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.style-option__swatch--moderno { background: linear-gradient(135deg, #6e6fef, #b06ff0); }
.style-option__swatch--minimalista { background: #d9d9de; }
.style-option__swatch--vibrante { background: linear-gradient(135deg, #ff6b6b, #ffd166); }
.style-option__swatch--corporativo { background: #2b4c7e; }
.style-option__swatch--organico { background: linear-gradient(135deg, #6fbf73, #a7d97e); }
.style-option__swatch--luxuoso { background: linear-gradient(135deg, #2b2b2f, #b8974e); }

/* ==========================================================================
   11. LOADING / EMPTY STATES
   ========================================================================== */

.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
  min-height: 260px;
}

.loading-state__spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.loading-state__text,
.empty-state__text {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

.empty-state__icon {
  width: 34px;
  height: 34px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 1.5;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-state__spinner {
    animation-duration: 1.6s;
  }
}

/* ==========================================================================
   12. PALETTE PREVIEW
   ========================================================================== */

.palette-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.palette-preview__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.palette-preview__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

.palette-preview__actions {
  display: flex;
  gap: var(--space-xs);
}

.palette-preview__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

@media (min-width: 480px) {
  .palette-preview__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 960px) {
  .palette-preview__grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

.palette-swatch {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}

.palette-swatch:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.palette-swatch__color {
  position: relative;
  height: 96px;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: var(--space-xs);
}

.palette-swatch__copy-icon {
  width: 16px;
  height: 16px;
  padding: var(--space-2xs);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  box-sizing: content-box;
}

.palette-swatch__color:hover .palette-swatch__copy-icon,
.palette-swatch__color:focus-visible .palette-swatch__copy-icon {
  opacity: 1;
  transform: translateY(0);
}

.palette-swatch__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  padding: var(--space-sm);
}

.palette-swatch__name {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-primary);
}

.palette-swatch__hex {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
}

/* ==========================================================================
   13. FONTES (view)
   ========================================================================== */

.font-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .font-preview {
    grid-template-columns: 1fr 1fr;
  }

  .font-card--scale {
    grid-column: 1 / -1;
  }
}

.font-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  box-shadow: var(--shadow-sm);
}

.font-card__label {
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.font-card__name {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--accent);
}

.font-card__sample {
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text-secondary);
}

.font-card__sample--display {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.type-scale {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.type-scale__row {
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

/* ==========================================================================
   14. COMPONENTES (galeria)
   ========================================================================== */

.component-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.component-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.component-block__title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-secondary);
}

.component-block__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.component-block__row--stack {
  max-width: 360px;
}

/* ==========================================================================
   15. MOCKUP DE UI (Componentes + Landing Page)
   ========================================================================== */

.ui-mockup__frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.mockup-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  transition: background-color var(--t-fast), box-shadow var(--t-fast);
}

.mockup-navbar--fixed {
  box-shadow: var(--shadow-sm);
}

.mockup-navbar--transparent {
  background: transparent;
  border-bottom-color: transparent;
}

.mockup-navbar__logo {
  font-size: var(--fs-sm);
  font-weight: 700;
  font-family: var(--brand-font-title);
}

.mockup-navbar__links {
  display: none;
  align-items: center;
  gap: var(--space-md);
}

.mockup-navbar__link {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-family: var(--brand-font-body);
}

.mockup-navbar__cta {
  padding: var(--space-2xs) var(--space-sm);
  font-size: var(--fs-2xs);
  font-weight: 600;
  border-radius: var(--brand-button-radius);
  background: var(--accent);
  color: var(--accent-contrast);
  border: var(--brand-border-width) solid transparent;
}

@media (min-width: 480px) {
  .mockup-navbar__links {
    display: flex;
  }
}

.mockup-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-2xl) var(--space-lg);
  text-align: left;
}

.mockup-hero__title {
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
  max-width: 22ch;
  font-family: var(--brand-font-title);
}

.mockup-hero__text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  max-width: 44ch;
  font-family: var(--brand-font-body);
}

.mockup-hero__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.mockup-btn {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--brand-button-radius);
  border: var(--brand-border-width) solid transparent;
}

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

.mockup-btn--secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.mockup-btn--outline {
  background: transparent !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.mockup-btn--ghost {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-primary) !important;
}

.mockup-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.mockup-cards--standalone {
  padding: 0;
}

.mockup-cards--list {
  grid-template-columns: 1fr !important;
}

@media (min-width: 560px) {
  .mockup-cards {
    grid-template-columns: repeat(var(--brand-columns), 1fr);
  }
}

.mockup-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-md);
  border: var(--brand-border-width) solid var(--border);
  border-radius: var(--brand-radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-fast), border-radius var(--t-fast);
}

.mockup-card--shadow-none {
  box-shadow: none;
}

.mockup-card--shadow-strong {
  box-shadow: var(--shadow-lg);
}

.mockup-card__badge {
  align-self: flex-start;
  padding: 2px var(--space-xs);
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: var(--space-2xs);
}

.mockup-card__title {
  font-size: var(--fs-sm);
  font-weight: 700;
  font-family: var(--brand-font-title);
}

.mockup-card__text {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-family: var(--brand-font-body);
}

.mockup-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  text-align: center;
}

.mockup-footer--center {
  align-items: center;
}

.mockup-footer__text {
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
}

.mockup-footer__links {
  display: flex;
  gap: var(--space-md);
}

.mockup-footer__link {
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
}

@media (min-width: 480px) {
  .mockup-footer {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ==========================================================================
   16. LANDING PAGE (view)
   ========================================================================== */

.landing-preview {
  max-width: var(--brand-container-max);
  margin-inline: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.landing-preview__browser-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.landing-preview__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
}

.landing-preview__url {
  margin-left: var(--space-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
}

/* ==========================================================================
   17. HISTÓRICO DE PALETAS
   ========================================================================== */

.history {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

.history__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

.history-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.history-item__colors {
  display: flex;
}

.history-item__color {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  border: 2px solid var(--surface);
  margin-left: -8px;
}

.history-item__color:first-child {
  margin-left: 0;
}

.history-item__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-item__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__date {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
}

.history-item__actions {
  display: flex;
  gap: var(--space-3xs);
}

.history__empty {
  padding: var(--space-lg);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   18. CONFIGURAÇÕES (view)
   ========================================================================== */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.settings-group__title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-group__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .settings-group__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.settings-group__empty {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.form-field--color {
  gap: var(--space-2xs);
}

.color-token-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.color-token-row__picker {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}

.color-token-row__hex {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.settings-form__submit {
  align-self: flex-start;
}

/* ==========================================================================
   19. EXPORTAR (view)
   ========================================================================== */

.export-page {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.export-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

@media (min-width: 480px) {
  .export-options {
    grid-template-columns: repeat(4, 1fr);
  }
}

.export-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), color var(--t-fast), background-color var(--t-fast);
}

.export-option:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.export-option.is-active {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.export-preview {
  padding: var(--space-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-secondary);
  overflow-x: auto;
  max-height: 260px;
}

/* ==========================================================================
   20. FOOTER DA APLICAÇÃO
   ========================================================================== */

.app-footer {
  border-top: 1px solid var(--border);
}

.app-footer__container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  text-align: center;
}

.app-footer__text {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.app-footer__links {
  display: flex;
  gap: var(--space-md);
}

.app-footer__link {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  transition: color var(--t-fast);
}

.app-footer__link:hover {
  color: var(--text-primary);
}

@media (min-width: 640px) {
  .app-footer__container {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ==========================================================================
   21. TOASTS
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  pointer-events: none;
  width: min(360px, calc(100vw - var(--space-lg) * 2));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  width: 100%;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--t-slow);
}

.toast[data-type='success'] {
  border-color: color-mix(in srgb, var(--success) 50%, var(--border-strong));
}

.toast[data-type='error'] {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border-strong));
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   22. ACESSIBILIDADE — MOVIMENTO REDUZIDO
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
