/* ═══════════════════════════════════════════════
   components.css — Componentes reutilizáveis
   Botões, cards, inputs, modais, toast, badges,
   tabelas, empty states, loading
   ═══════════════════════════════════════════════ */

/* ========== ÍCONES LUCIDE ========== */
.lucide { width: 18px; height: 18px; stroke-width: 2; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }
.icon-stat { width: 28px; height: 28px; color: var(--primary); }
.icon-empty { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }

/* ========== BOTÕES ========== */
.btn-add {
    padding: 12px 24px;
    background: var(--gradient);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    height: 46px;
}
.btn-add:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-add:active { transform: translateY(0); }
.btn-add:focus-visible { box-shadow: var(--focus-ring); }

.btn-icon {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition);
}
.btn-icon:focus-visible { box-shadow: var(--focus-ring); }
.btn-edit { background: var(--secondary-light); color: var(--secondary); }
.btn-edit:hover { background: var(--secondary); color: #fff; transform: scale(1.05); }
.btn-toggle { background: var(--success-light); color: var(--success); }
.btn-toggle.off { background: var(--danger-light); color: var(--danger); }
.btn-toggle:hover { opacity: 0.8; transform: scale(1.05); }
.btn-approve { background: var(--success-light); color: var(--success); }
.btn-approve:hover { background: var(--success); color: #fff; transform: scale(1.05); }
.btn-delete { background: var(--danger-light); color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: #fff; transform: scale(1.05); }
.btn-delete:focus-visible { box-shadow: var(--focus-ring-danger); }
.actions-cell { display: flex; gap: 6px; }

/* ========== CARDS ========== */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
    transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card h3 { font-size: 18px; color: var(--secondary); margin-bottom: 4px; }
.card .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.config-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
    transition: box-shadow var(--transition);
}
.config-card:hover { box-shadow: var(--shadow-sm); }
.config-card h2 { font-size: 18px; color: var(--secondary); margin-bottom: 4px; }
.config-card .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--secondary); }
.stat-card .stat-label {
    font-size: 12px; color: var(--text-muted);
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}

.welcome-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 32px;
    color: var(--text-primary);
    margin-bottom: 24px;
}
.welcome-card h2 { font-size: 22px; margin-bottom: 4px; color: var(--text-primary); }
.welcome-card p { font-size: 14px; color: var(--text-secondary); }

/* ========== FORMULÁRIO ========== */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex; align-items: center; gap: 4px;
}
.field-edit-btn {
    background: none; border: none; cursor: pointer; font-size: 12px;
    padding: 0 2px; line-height: 1; opacity: 0.5; transition: opacity 0.15s;
}
.field-edit-btn:hover { opacity: 1;
}
.form-group input, .form-group select, .form-group textarea {
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    position: relative;
    z-index: 1;
    user-select: text;
    -webkit-user-select: text;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    background: var(--bg-input);
    color: var(--text-primary, var(--text));
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: var(--text-muted); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); box-shadow: var(--focus-ring); background: var(--bg-input); }
.form-group.pct { max-width: 100px; }

/* ========== BADGES ========== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.status-badge.aprovado { background: var(--success-light); color: var(--success); }
.status-badge.pendente { background: var(--warning-light); color: var(--warning); }
.status-badge.bloqueado { background: var(--danger-light); color: var(--danger); }
.status-badge.inativo { background: var(--bg-input); color: var(--text-muted); }
.status-badge.ativo { background: var(--success-light); color: var(--success); }

/* ========== TABELAS ========== */
.table-wrapper { overflow-x: auto; margin-top: 20px; }

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    z-index: 9999;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    opacity: 0;
    backdrop-filter: blur(8px);
    max-width: calc(100vw - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: rgba(16, 185, 129, 0.95); }
.toast.error { background: rgba(239, 68, 68, 0.95); }
.toast.warning { background: rgba(180, 83, 9, 0.95); }
.toast.info { background: rgba(59, 130, 246, 0.95); }

/* ========== MODAL (base) ========== */
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: none; }
}
@keyframes modalOut {
    from { opacity: 1; transform: none; }
    to { opacity: 0; transform: scale(0.95) translateY(10px); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    animation: fadeIn 0.4s ease-out;
}
.empty-state .empty-icon {
    font-size: 48px; margin-bottom: 16px;
    opacity: 0.5;
}
.empty-state .lucide.icon-empty {
    width: 56px; height: 56px; stroke-width: 1.5;
    color: var(--text-muted); opacity: 0.4; margin-bottom: 16px;
}
.empty-state h3 {
    font-size: 16px; font-weight: 700; color: var(--text-secondary);
    margin-bottom: 6px;
}
.empty-state p { font-size: 14px; max-width: 320px; margin: 0 auto; line-height: 1.5; }
.empty-state .empty-cta {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 20px; padding: 10px 20px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 10px;
    font-size: 13px; font-weight: 700; font-family: inherit;
    cursor: pointer; transition: opacity var(--transition), transform var(--transition);
    text-decoration: none;
}
.empty-state .empty-cta:hover { opacity: 0.9; transform: translateY(-1px); }

/* ========== LOADING ========== */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(248,250,252,0.92);
    display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
    z-index: 9998; font-size: 15px; color: var(--text-muted);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}
.loading-overlay.hidden { display: none; }

/* Skeleton placeholder for async loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 6px; }
.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-card { height: 120px; border-radius: var(--radius-md); margin-bottom: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Inline spinner for buttons */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    position: absolute; top: 50%; left: 50%;
    width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ========== AUTH OVERLAY (spinner) ========== */
.auth-overlay {
    position: fixed; inset: 0;
    background: var(--bg-light);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s, visibility 0.5s;
}
.auth-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.auth-spinner-wrap { text-align: center; }
.auth-spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}
.auth-spinner-wrap p { color: var(--text-muted); font-size: 14px; font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== LOGIN (painel) ========== */
.login-overlay {
    position: fixed; inset: 0;
    background: var(--gradient-blue);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s, visibility 0.4s;
}
.login-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-box {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%; max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}
.login-box .login-icon { font-size: 48px; margin-bottom: 16px; }
.login-box h1 { font-size: 24px; color: var(--secondary); margin-bottom: 6px; }
.login-box h1 span { color: var(--primary); }
.login-box .login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 12px;
    background: var(--bg-input);
    color: var(--text-primary, var(--text));
}
.login-input:hover { border-color: var(--text-muted); }
.login-input:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
.login-btn {
    width: 100%; padding: 14px;
    background: var(--gradient); color: #fff;
    border: none; border-radius: 12px;
    font-size: 15px; font-weight: 700;
    font-family: inherit; cursor: pointer;
    transition: opacity 0.2s; margin-bottom: 12px;
}
.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 16px 0; color: var(--text-muted); font-size: 13px;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.login-btn-google {
    width: 100%; padding: 14px;
    background: var(--bg-card); color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 12px; font-size: 15px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.login-btn-google:hover { border-color: var(--primary); background: var(--bg-light); }
.login-btn-google svg { width: 20px; height: 20px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; display: none; }
.login-error.show { display: block; }
.login-loading { display: none; color: var(--text-muted); font-size: 13px; margin-top: 8px; }
.login-loading.show { display: block; }

/* ========== LOG / INDICAÇÕES ========== */
.log-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.log-item:last-child { border-bottom: none; }
.log-icon { font-size: 20px; }
.log-info { flex: 1; }
.log-info .log-title { font-weight: 600; font-size: 14px; }
.log-info .log-detail { font-size: 12px; color: var(--text-muted); }
.log-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ========== DADOS PESSOAIS ========== */
.dados-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.dado-item {
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: 10px;
}
.dado-item .dado-label {
    font-size: 11px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.dado-item .dado-value {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary); margin-top: 2px;
}

/* ========== BARRA DE PERCENTUAL ========== */
.pct-bar {
    margin-top: 20px;
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
}
.pct-bar.ok { background: var(--success-light); color: var(--success); }
.pct-bar.warn { background: var(--warning-light); color: var(--warning); }
.pct-bar.error { background: var(--danger-light); color: var(--danger); }
.pct-visual {
    height: 8px; border-radius: 4px; background: var(--border);
    flex: 1; margin: 0 16px; overflow: hidden;
}
.pct-visual-fill { height: 100%; border-radius: 4px; transition: width 0.3s, background 0.3s; }
.pct-bar.ok .pct-visual-fill { background: var(--success); }
.pct-bar.warn .pct-visual-fill { background: var(--warning); }
.pct-bar.error .pct-visual-fill { background: var(--danger); }

/* ========== DISTRIBUIÇÃO ========== */
.dist-options { display: flex; gap: 8px; margin-top: 10px; }
.dist-option {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.dist-option:hover { border-color: var(--primary); background: rgba(235,107,15,0.03); }
.dist-option.active { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(235,107,15,0.08); }
.dist-option .dist-icon { font-size: 20px; flex-shrink: 0; }
.dist-option .dist-info { display: flex; flex-direction: column; }
.dist-option .dist-name { font-weight: 700; font-size: 13px; color: var(--secondary); line-height: 1.2; }
.dist-option .dist-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; line-height: 1.3; }

/* ========== PIPELINES ========== */
.pipe-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 8px; background: var(--bg-white); cursor: grab;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.pipe-item:hover { border-color: var(--border-focus); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.pipe-item.dragging { opacity: 0.5; }
.pipe-item .pipe-drag { font-size: 14px; color: var(--text-muted); cursor: grab; user-select: none; }
.pipe-item .pipe-emoji { font-size: 20px; min-width: 28px; text-align: center; }
.pipe-item .pipe-color { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.pipe-item .pipe-nome {
    flex: 1; font-size: 14px; font-weight: 600; color: var(--text-primary);
    border: none; background: transparent; outline: none; padding: 4px 8px; border-radius: 6px;
}
.pipe-item .pipe-nome:focus { background: var(--bg-input); border: 1px solid var(--border-focus); }
.pipe-item .pipe-btn {
    border: none; background: none; cursor: pointer; font-size: 14px; padding: 4px 8px;
    border-radius: 6px; transition: all 0.15s;
}
.pipe-item .pipe-btn:hover { background: var(--danger-light); }
.pipe-item .pipe-btn-save { color: var(--success); }
.pipe-item .pipe-btn-save:hover { background: var(--success-light); }
.pipe-item .pipe-btn-del { color: var(--danger); }

/* ========== RESPONSIVO GLOBAL ========== */
@media (max-width: 768px) {
    .form-row { flex-direction: column; }
    .form-group.pct { max-width: 100%; }
    .btn-add { width: 100%; }
    .login-box { margin: 20px; padding: 32px 24px; }
    .dados-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .form-group input,
    .form-group select,
    .form-group textarea { font-size: 16px; min-height: 44px; }
    .btn, .btn-add, .btn-sm { min-height: 44px; font-size: 14px; }
    .login-box { margin: 12px; padding: 24px 16px; border-radius: 16px; }
    .dados-grid { gap: 10px; }
    .pipe-item { flex-wrap: wrap; gap: 8px; }
    .pipe-item .pipe-nome { min-width: 0; flex-basis: 100%; }
}

/* ════════════════════════════════════════════════════════════
   TEMA "SNEAT" — Fase 3 do re-skin: CARÁTER dos componentes
   O que a cor (tokens da Fase 1) não cobre: cards sem borda com a
   sombra-assinatura, botões flat com sombra colorida (sem gradiente),
   inputs de borda fina. Tudo escopado em [data-theme="sneat"] —
   o Clássico permanece byte a byte intacto.
   ════════════════════════════════════════════════════════════ */

/* Cards: SEM borda, só a sombra-assinatura do Sneat, cantos 8px */
[data-theme="sneat"] .card,
[data-theme="sneat"] .stat-card,
[data-theme="sneat"] .config-card,
[data-theme="sneat"] .welcome-card,
[data-theme="sneat"] .login-box {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 2px 6px 0 rgba(67, 89, 113, 0.12);
}

/* Botões primários: FLAT índigo + sombra colorida (assinatura do Sneat),
   no lugar do gradiente do Clássico */
[data-theme="sneat"] .btn-add,
[data-theme="sneat"] .login-btn {
    background: var(--primary);
    border-radius: 6px;
    box-shadow: 0 0.125rem 0.25rem 0 rgba(105, 108, 255, 0.4);
}
[data-theme="sneat"] .btn-add:hover,
[data-theme="sneat"] .login-btn:hover {
    background: var(--primary-hover);
    opacity: 1;
    box-shadow: 0 0.25rem 0.5rem 0 rgba(105, 108, 255, 0.5);
}

/* Inputs: borda fina 1px do Sneat (padding +1px compensa — a caixa
   mantém exatamente o mesmo tamanho externo; nada se move no layout) */
[data-theme="sneat"] .form-group input,
[data-theme="sneat"] .form-group select,
[data-theme="sneat"] .form-group textarea {
    border-width: 1px;
    padding: 13px 15px;
    border-radius: 6px;
}

/* Toast nos cantos do tema */
[data-theme="sneat"] .toast { border-radius: 8px; }

/* ════ TEMA "SNEAT" — Pente fino: toast nas cores do template ════ */
[data-theme="sneat"] .toast.success { background: rgba(63, 165, 28, 0.96); }
[data-theme="sneat"] .toast.warning { background: rgba(185, 137, 0, 0.96); }
[data-theme="sneat"] .toast.error { background: rgba(232, 57, 26, 0.96); }
