/*
 * ═══════════════════════════════════════════════════════════════════
 *  PILOTO STUDIO — COMPONENTES BASE v2.0
 *  Botão · Input · Textarea · Select · Card · Badge · Toggle · Toast
 *
 *  Todos os componentes têm:
 *  — default, hover, focus, active, disabled, loading (quando aplica)
 *  — Microinterações e feedback visual
 *  — Construídos sobre os tokens de ds-tokens.css
 * ═══════════════════════════════════════════════════════════════════
 */


/* ═══════════════════════════════════════════════════════════════════
 *  1. BOTÕES
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Base do Botão ────────────────────────────────────────────── */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.01em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    overflow: hidden;
    isolation: isolate;
    transition:
        transform var(--dur-fast) var(--ease-smooth),
        background var(--dur-normal) var(--ease-smooth),
        border-color var(--dur-normal) var(--ease-smooth),
        box-shadow var(--dur-normal) var(--ease-smooth),
        color var(--dur-fast) var(--ease-smooth),
        opacity var(--dur-fast) var(--ease-smooth);
}

/* Ícone dentro do botão */
.btn svg,
.btn [data-icon] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    transition: transform var(--dur-fast) var(--ease-spring);
}

/* Hover dos ícones — leve movimento */
.btn:not(:disabled):not(.btn--loading):hover svg {
    transform: scale(1.08);
}

/* Click — pressão física */
.btn:not(:disabled):not(.btn--loading):active {
    transform: translateY(1px) scale(0.985);
}

/* Focus ring acessível */
.btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ─── Estado: Disabled ──────────────────────────────────────────── */
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Estado: Loading ───────────────────────────────────────────── */
.btn--loading {
    cursor: wait;
    pointer-events: none;
}

.btn--loading .btn__text {
    opacity: 0;
}

.btn--loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: currentColor;
    animation: ds-spin 640ms linear infinite;
}

/* ─── Tamanhos ──────────────────────────────────────────────────── */
.btn--xs {
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: var(--text-2xs);
    gap: 5px;
}
.btn--xs svg { width: 12px; height: 12px; }

.btn--sm {
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    gap: 6px;
}
.btn--sm svg { width: 13px; height: 13px; }

.btn--md {
    /* default — já definido no .btn */
}

.btn--lg {
    height: 48px;
    padding: 0 24px;
    border-radius: var(--radius-lg);
    font-size: var(--text-md);
    gap: 10px;
}
.btn--lg svg { width: 17px; height: 17px; }

.btn--xl {
    height: 56px;
    padding: 0 32px;
    border-radius: var(--radius-xl);
    font-size: var(--text-lg);
    font-weight: var(--fw-bold);
    gap: 12px;
}
.btn--xl svg { width: 20px; height: 20px; }

/* Botão de largura total */
.btn--full { width: 100%; }

/* Botão somente ícone (quadrado) */
.btn--icon {
    padding: 0;
    width: 40px;
}
.btn--icon.btn--sm { width: 34px; }
.btn--icon.btn--lg { width: 48px; }


/* ─── Variante: Primary ─────────────────────────────────────────── */
.btn--primary {
    color: #ffffff;
    background: var(--gradient-btn-primary);
    border-color: rgba(79, 124, 255, 0.40);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 4px 16px rgba(79, 124, 255, 0.20);
}

/* Shine animado em hover */
.btn--primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.10) 50%, transparent 60%);
    background-size: 200% 100%;
    background-position: 200% center;
    transition: background-position 0.5s var(--ease-smooth);
    border-radius: inherit;
    pointer-events: none;
}

.btn--primary:not(:disabled):not(.btn--loading):hover {
    background: linear-gradient(135deg, #7fa3ff 0%, #5a8aff 40%, #3d66d9 100%);
    border-color: rgba(79, 124, 255, 0.55);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.10) inset,
        var(--shadow-glow-md);
    transform: translateY(-1px);
}

.btn--primary:not(:disabled):not(.btn--loading):hover::before {
    background-position: -200% center;
}

.btn--primary:not(:disabled):not(.btn--loading):active {
    background: linear-gradient(135deg, #4f7cff 0%, #3451b2 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 2px 8px rgba(79, 124, 255, 0.16);
    transform: translateY(1px) scale(0.985);
}


/* ─── Variante: Secondary ───────────────────────────────────────── */
.btn--secondary {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-color: var(--border-medium);
    box-shadow: var(--inset-top);
}

.btn--secondary:not(:disabled):not(.btn--loading):hover {
    background: rgba(255, 255, 255, 0.065);
    border-color: var(--border-accent);
    color: var(--text-primary);
    box-shadow:
        var(--inset-top),
        0 0 0 1px var(--border-accent) inset;
    transform: translateY(-1px);
}

.btn--secondary:not(:disabled):not(.btn--loading):active {
    background: var(--surface-active);
    border-color: var(--border-medium);
    transform: translateY(1px) scale(0.985);
}


/* ─── Variante: Ghost ───────────────────────────────────────────── */
.btn--ghost {
    color: var(--text-secondary);
    background: transparent;
    border-color: transparent;
}

.btn--ghost:not(:disabled):not(.btn--loading):hover {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-color: var(--border);
    transform: translateY(-1px);
}

.btn--ghost:not(:disabled):not(.btn--loading):active {
    background: var(--surface-active);
    transform: translateY(0);
}


/* ─── Variante: Danger ──────────────────────────────────────────── */
.btn--danger {
    color: var(--danger-light);
    background: var(--danger-soft);
    border-color: var(--border-danger);
    box-shadow: var(--inset-top);
}

.btn--danger:not(:disabled):not(.btn--loading):hover {
    color: #ffffff;
    background: rgba(241, 74, 74, 0.22);
    border-color: rgba(241, 74, 74, 0.44);
    box-shadow:
        var(--inset-top),
        0 4px 16px var(--danger-glow);
    transform: translateY(-1px);
}

.btn--danger:not(:disabled):not(.btn--loading):active {
    background: var(--danger-soft);
    transform: translateY(1px) scale(0.985);
}


/* ─── Variante: Brand ───────────────────────────────────────────── */
.btn--brand {
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand) 100%);
    border-color: var(--border-brand);
    box-shadow:
        var(--inset-top),
        0 4px 20px var(--brand-glow);
}

.btn--brand:not(:disabled):not(.btn--loading):hover {
    background: linear-gradient(135deg, var(--brand-bright) 0%, var(--brand-light) 100%);
    box-shadow:
        var(--inset-top),
        0 8px 28px var(--brand-glow);
    transform: translateY(-1px);
}


/* ─── Legado (compatibilidade com painel.css existente) ─────────── */
.btn-primary   { } /* override via .btn--primary acima */
.btn-secondary { }
.btn-ghost     { }
.btn-danger    { }
.btn-sm        { }
.btn-icon      { }
.is-busy       { }
.btn-spinner   {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.24);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: ds-spin 700ms linear infinite;
}


/* ═══════════════════════════════════════════════════════════════════
 *  2. INPUTS — TEXT, EMAIL, PASSWORD, NUMBER, URL, DATETIME
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Wrapper do Campo ──────────────────────────────────────────── */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Label do campo */
.field__label {
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-widest);
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color var(--dur-fast) var(--ease-out);
}

/* Foco no campo → label acende */
.field:focus-within .field__label {
    color: var(--text-accent);
}

/* Hint / descrição abaixo */
.field__hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--lh-relaxed);
}

/* Mensagem de erro */
.field__error {
    font-size: var(--text-xs);
    font-weight: var(--fw-medium);
    color: var(--danger-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ─── Input Base: Wrapper com ícone opcional ────────────────────── */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap [data-icon-left],
.input-wrap .input-icon-left {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--dur-fast) var(--ease-out);
    z-index: 1;
}

.input-wrap [data-icon-right],
.input-wrap .input-icon-right {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}

.input-wrap:focus-within [data-icon-left],
.input-wrap:focus-within .input-icon-left {
    color: var(--accent);
}

/* Padding-left quando tem ícone */
.input-wrap [data-icon-left] ~ input,
.input-wrap .input-icon-left ~ input { padding-left: 40px; }

/* ─── Input Base ────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="datetime-local"],
input[type="date"],
.input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(9, 13, 22, 0.80);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--fw-normal);
    line-height: 1;
    transition:
        border-color var(--dur-fast) var(--ease-out),
        background var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-normal) var(--ease-smooth),
        transform var(--dur-fast) var(--ease-spring);
    -webkit-appearance: none;
    appearance: none;
}

/* Placeholder */
input::placeholder,
.input::placeholder {
    color: var(--text-disabled);
    font-weight: var(--fw-normal);
}

/* Hover */
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="url"]:hover,
input[type="search"]:hover,
input[type="datetime-local"]:hover,
.input:hover {
    border-color: var(--border-strong);
    background: rgba(11, 16, 27, 0.88);
}

/* Focus */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="datetime-local"]:focus,
.input:focus {
    outline: none;
    border-color: var(--border-accent);
    background: rgba(9, 13, 22, 0.95);
    box-shadow: var(--shadow-focus);
    transform: none;
}

/* Estado de erro */
input.input--error,
.field--error input {
    border-color: var(--border-danger);
    background: rgba(241, 74, 74, 0.04);
}

input.input--error:focus,
.field--error input:focus {
    box-shadow: 0 0 0 3px rgba(241, 74, 74, 0.14), 0 0 0 1px var(--border-danger);
}

/* Estado de sucesso */
input.input--success,
.field--success input {
    border-color: var(--border-success);
}

/* Disabled */
input:disabled,
.input:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Input de Busca Especial ────────────────────────────────────── */
.search-input {
    height: 38px;
    padding: 0 14px 0 40px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-light);
    font-size: var(--text-sm);
}

.search-input:focus {
    background: rgba(9, 13, 22, 0.90);
    border-radius: var(--radius-md);
    min-width: 220px;
}


/* ═══════════════════════════════════════════════════════════════════
 *  3. TEXTAREA
 * ═══════════════════════════════════════════════════════════════════ */

textarea,
.textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(9, 13, 22, 0.80);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--lh-relaxed);
    resize: vertical;
    transition:
        border-color var(--dur-fast) var(--ease-out),
        background var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-normal) var(--ease-smooth);
    -webkit-appearance: none;
    appearance: none;
}

textarea::placeholder { color: var(--text-disabled); }

textarea:hover { border-color: var(--border-strong); }

textarea:focus {
    outline: none;
    border-color: var(--border-accent);
    background: rgba(9, 13, 22, 0.95);
    box-shadow: var(--shadow-focus);
}

textarea:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}


/* ═══════════════════════════════════════════════════════════════════
 *  4. SELECT
 * ═══════════════════════════════════════════════════════════════════ */

select,
.select {
    width: 100%;
    height: 40px;
    padding: 0 38px 0 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background-color: rgba(9, 13, 22, 0.80);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    cursor: pointer;
    transition:
        border-color var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-normal) var(--ease-smooth),
        background var(--dur-fast) var(--ease-out);
    /* Seta customizada SVG inline */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    -webkit-appearance: none;
    appearance: none;
}

select:hover { border-color: var(--border-strong); }

select:focus {
    outline: none;
    border-color: var(--border-accent);
    box-shadow: var(--shadow-focus);
    background-color: rgba(9, 13, 22, 0.95);
}

select:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

/* Opções dentro do select (dark) */
select option {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}


/* ═══════════════════════════════════════════════════════════════════
 *  5. CARD
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Card Base ─────────────────────────────────────────────────── */
.card {
    position: relative;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: var(--gradient-surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    isolation: isolate;
    transition:
        border-color var(--dur-normal) var(--ease-smooth),
        box-shadow var(--dur-normal) var(--ease-smooth),
        transform var(--dur-normal) var(--ease-smooth);
}

/* Top edge highlight — sensação de profundidade */
.card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.07) 30%,
        rgba(255,255,255,0.07) 70%,
        transparent 100%);
    pointer-events: none;
    z-index: 1;
}

/* ─── Card Interativo (clicável) ────────────────────────────────── */
.card--interactive {
    cursor: pointer;
}

.card--interactive:hover {
    border-color: var(--border-accent);
    box-shadow:
        var(--shadow-md),
        0 0 0 1px var(--accent-subtle);
    transform: translateY(-2px);
}

.card--interactive:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* ─── Card com Glow ─────────────────────────────────────────────── */
.card--glow {
    border-color: var(--border-accent);
    box-shadow:
        var(--shadow-sm),
        0 0 24px rgba(79, 124, 255, 0.06),
        inset 0 0 24px rgba(79, 124, 255, 0.03);
}

/* ─── Card Surface (mais escuro) ────────────────────────────────── */
.card--surface {
    background: rgba(13, 17, 30, 0.88);
    border-color: var(--border-light);
}

/* ─── Padding padrão ────────────────────────────────────────────── */
.card__body {
    padding: var(--space-6);
}

.card__body--sm  { padding: var(--space-4); }
.card__body--lg  { padding: var(--space-8); }
.card__body--xl  { padding: var(--space-10); }

/* ─── Header do card ────────────────────────────────────────────── */
.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-light);
}

.card__title {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-normal);
    color: var(--text-primary);
    margin: 0;
}

.card__subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ─── Footer do card ────────────────────────────────────────────── */
.card__footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ─── Card Stat ─────────────────────────────────────────────────── */
.card--stat {
    padding: var(--space-5) var(--space-6);
}

.card--stat::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 60% at -10% -10%, var(--accent-subtle) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.card--stat > * { position: relative; z-index: 1; }


/* ═══════════════════════════════════════════════════════════════════
 *  6. BADGE
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Badge Base ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    font-size: var(--text-2xs);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    vertical-align: middle;
    transition:
        background var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out),
        color var(--dur-fast) var(--ease-out);
}

/* Dot indicator */
.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Badge sem dot */
.badge--nodot::before { display: none; }

/* ─── Badge Medium (um pouco maior) ─────────────────────────────── */
.badge--md {
    height: 26px;
    padding: 0 10px;
    font-size: var(--text-xs);
    gap: 6px;
}
.badge--md::before { width: 6px; height: 6px; }

/* ─── Badge Large ────────────────────────────────────────────────── */
.badge--lg {
    height: 32px;
    padding: 0 14px;
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    letter-spacing: 0;
    text-transform: none;
    gap: 7px;
}
.badge--lg::before { width: 7px; height: 7px; }

/* ─── Variantes Semânticas ───────────────────────────────────────── */
.badge--success,
.badge--published,
.badge--active {
    color: var(--success);
    background: var(--success-soft);
    border-color: rgba(34, 196, 116, 0.20);
}

.badge--warning,
.badge--featured {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: rgba(245, 166, 35, 0.22);
}

.badge--danger,
.badge--error {
    color: var(--danger-light);
    background: var(--danger-soft);
    border-color: rgba(241, 74, 74, 0.20);
}

.badge--info {
    color: var(--info);
    background: var(--info-soft);
    border-color: rgba(56, 178, 245, 0.22);
}

.badge--accent,
.badge--new {
    color: var(--accent-light);
    background: var(--accent-subtle);
    border-color: rgba(79, 124, 255, 0.20);
}

.badge--brand {
    color: #a5b8ff;
    background: var(--brand-subtle);
    border-color: var(--border-brand);
}

.badge--draft,
.badge--inactive {
    color: var(--text-muted);
    background: var(--surface-subtle);
    border-color: var(--border-light);
}

/* Badge pulsante (ativo/ao vivo) */
.badge--pulse::before {
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50%       { opacity: 1; transform: scale(1.5); }
}


/* ═══════════════════════════════════════════════════════════════════
 *  7. TOGGLE (Switch)
 * ═══════════════════════════════════════════════════════════════════ */

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

/* Input escondido */
.toggle__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

/* Track (trilho) */
.toggle__track {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition:
        background var(--dur-normal) var(--ease-smooth),
        border-color var(--dur-normal) var(--ease-smooth),
        box-shadow var(--dur-normal) var(--ease-smooth);
}

/* Thumb (bolinha) */
.toggle__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(220, 228, 255, 0.70);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.40);
    transition:
        transform var(--dur-normal) var(--ease-spring),
        background var(--dur-normal) var(--ease-smooth),
        box-shadow var(--dur-normal) var(--ease-smooth);
}

/* Hover estado OFF */
.toggle:hover .toggle__track {
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.10);
}

/* Checked (ON) */
.toggle__input:checked + .toggle__track {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-muted) 100%);
    border-color: rgba(79, 124, 255, 0.50);
    box-shadow: 0 0 12px rgba(79, 124, 255, 0.25);
}

.toggle__input:checked + .toggle__track::after {
    transform: translateX(20px);
    background: #ffffff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.50), 0 0 6px rgba(79, 124, 255, 0.30);
}

/* Focus */
.toggle__input:focus-visible + .toggle__track {
    box-shadow: var(--shadow-focus);
}

/* Disabled */
.toggle--disabled {
    opacity: 0.38;
    cursor: not-allowed;
}
.toggle--disabled .toggle__input { pointer-events: none; }

/* Label do toggle */
.toggle__label {
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    transition: color var(--dur-fast) var(--ease-out);
}

.toggle:hover .toggle__label { color: var(--text-primary); }

/* Toggle tamanho menor */
.toggle--sm .toggle__track { width: 36px; height: 20px; }
.toggle--sm .toggle__track::after { width: 13px; height: 13px; top: 3px; left: 3px; }
.toggle--sm .toggle__input:checked + .toggle__track::after { transform: translateX(16px); }


/* ═══════════════════════════════════════════════════════════════════
 *  8. TOAST
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Contêiner de toasts ────────────────────────────────────────── */
#toast-container,
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    z-index: var(--z-toast);
    pointer-events: none;
    max-width: 380px;
    width: calc(100% - 48px);
}

/* ─── Toast Individual ───────────────────────────────────────────── */
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-glass-dark);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow:
        var(--shadow-lg),
        inset 0 1px 0 rgba(255,255,255,0.05);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    pointer-events: auto;
    /* Entrada animada */
    opacity: 0;
    transform: translateX(12px) scale(0.96);
    transition:
        opacity var(--dur-normal) var(--ease-smooth),
        transform var(--dur-normal) var(--ease-spring),
        box-shadow var(--dur-normal) var(--ease-smooth);
}

/* Visível */
.toast.show,
.toast--show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* Saída */
.toast--hiding {
    opacity: 0;
    transform: translateX(20px) scale(0.94);
    pointer-events: none;
}

/* ─── Ícone do Toast ─────────────────────────────────────────────── */
.toast__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    opacity: 0.90;
}

/* ─── Conteúdo do Toast ──────────────────────────────────────────── */
.toast__content {
    flex: 1;
    min-width: 0;
}

.toast__title {
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    line-height: var(--lh-snug);
}

.toast__desc {
    margin-top: 2px;
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--lh-relaxed);
}

/* ─── Botão fechar Toast ─────────────────────────────────────────── */
.toast__close {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
    cursor: pointer;
    margin-top: -1px;
}

.toast__close:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

/* ─── Barra de progresso do Toast ────────────────────────────────── */
.toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: currentColor;
    opacity: 0.35;
    transform-origin: left;
    animation: toast-progress linear forwards;
}

@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ─── Variantes de Toast ─────────────────────────────────────────── */
.toast--success {
    border-color: rgba(34, 196, 116, 0.28);
    color: var(--success);
}
.toast--success .toast__title { color: var(--text-primary); }
.toast--success .toast__progress { background: var(--success); }
.toast--success::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 80% at 0% 0%, rgba(34, 196, 116, 0.06) 0%, transparent 70%);
    border-radius: inherit;
    pointer-events: none;
}

.toast--error,
.toast--danger {
    border-color: rgba(241, 74, 74, 0.30);
    color: var(--danger-light);
}
.toast--error .toast__title { color: var(--text-primary); }
.toast--error .toast__progress { background: var(--danger); }
.toast--error::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 80% at 0% 0%, rgba(241, 74, 74, 0.06) 0%, transparent 70%);
    border-radius: inherit;
    pointer-events: none;
}

.toast--warning {
    border-color: rgba(245, 166, 35, 0.28);
    color: var(--warning);
}
.toast--warning .toast__title { color: var(--text-primary); }
.toast--warning .toast__progress { background: var(--warning); }

.toast--info {
    border-color: rgba(79, 124, 255, 0.28);
    color: var(--accent-light);
}
.toast--info .toast__title { color: var(--text-primary); }
.toast--info .toast__progress { background: var(--accent); }


/* ═══════════════════════════════════════════════════════════════════
 *  9. COMPONENTES AUXILIARES
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Spinner de Loading ─────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    animation: ds-spin 700ms linear infinite;
    flex-shrink: 0;
}

.spinner--sm { width: 14px; height: 14px; border-width: 2px; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }
.spinner--xl { width: 40px; height: 40px; border-width: 3px; }

/* ─── Empty State ────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-16) var(--space-6);
    border-radius: var(--radius-xl);
    border: 1px dashed var(--border);
    background: radial-gradient(ellipse 70% 50% at 50% 0%, var(--accent-subtle) 0%, transparent 70%);
}

.empty-state__icon {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
    color: var(--text-muted);
    opacity: 0.6;
}

.empty-state__title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state__desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    max-width: 320px;
    line-height: var(--lh-relaxed);
    margin-bottom: var(--space-6);
}

/* ─── Avatar ─────────────────────────────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    color: #ffffff;
    font-weight: var(--fw-bold);
    font-size: var(--text-xs);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    flex-shrink: 0;
    border: 2px solid var(--border);
    overflow: hidden;
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-normal) var(--ease-smooth);
}

.avatar:hover {
    border-color: var(--border-accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.avatar--sm  { width: 28px; height: 28px; font-size: var(--text-2xs); }
.avatar--md  { width: 36px; height: 36px; font-size: var(--text-xs); }
.avatar--lg  { width: 44px; height: 44px; font-size: var(--text-sm); }
.avatar--xl  { width: 56px; height: 56px; font-size: var(--text-md); }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ─── Divider / Separador ────────────────────────────────────────── */
.divider {
    border: none;
    height: 1px;
    background: var(--gradient-separator);
    margin: var(--space-5) 0;
}

/* ─── Chip / Tag clicável ────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition:
        border-color var(--dur-fast) var(--ease-out),
        background var(--dur-fast) var(--ease-out),
        color var(--dur-fast) var(--ease-out),
        transform var(--dur-fast) var(--ease-spring);
}

.chip:hover {
    border-color: var(--border-accent);
    background: var(--accent-subtle);
    color: var(--accent-light);
    transform: translateY(-1px);
}

.chip--active {
    border-color: var(--border-accent);
    background: var(--accent-soft);
    color: var(--accent-light);
}


/* ═══════════════════════════════════════════════════════════════════
 *  10. JS HELPER — Toast Global Function
 *      Inclua este script no footer ou em um JS dedicado
 *
 *  Uso:
 *    toast('Salvo com sucesso!', 'success')
 *    toast('Algo deu errado', 'error', { desc: 'Tente novamente' })
 *    toast('Atenção', 'warning', { duration: 6000 })
 * ═══════════════════════════════════════════════════════════════════

  window.toast = function(title, type = 'info', opts = {}) {
    const container = document.getElementById('toast-container')
      || (() => {
        const c = document.createElement('div');
        c.id = 'toast-container';
        document.body.appendChild(c);
        return c;
      })();

    const icons = {
      success: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,
      error: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>`,
      warning: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><line x1="12" x2="12" y1="9" y2="13"/><line x1="12" x2="12.01" y1="17" y2="17"/></svg>`,
      info: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="8"/><line x1="12" x2="12" y1="12" y2="16"/></svg>`,
    };

    const duration = opts.duration ?? 4000;
    const t = document.createElement('div');
    t.className = `toast toast--${type}`;
    t.style.position = 'relative';
    t.innerHTML = `
      <span class="toast__icon">${icons[type] || icons.info}</span>
      <div class="toast__content">
        <div class="toast__title">${title}</div>
        ${opts.desc ? `<div class="toast__desc">${opts.desc}</div>` : ''}
      </div>
      <button class="toast__close" aria-label="Fechar">
        <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
      </button>
      <div class="toast__progress" style="animation-duration: ${duration}ms"></div>
    `;
    container.appendChild(t);
    requestAnimationFrame(() => t.classList.add('show'));

    const remove = () => {
      t.classList.add('toast--hiding');
      setTimeout(() => t.remove(), 400);
    };
    t.querySelector('.toast__close').addEventListener('click', remove);
    setTimeout(remove, duration);
    return t;
  };

 * ═══════════════════════════════════════════════════════════════════ */
