/* ============================================================
   VENDEDORES — ESTILOS GERAIS E MODAL
   ============================================================ */
.form-modal {
    max-width: 720px;
    width: 90%;
    height: 85vh; /* Tamanho fixo para o modal não pular */
    max-height: 90vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* O scroll será feito dentro das abas */
}

.form-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 10; 
    background: var(--bg-card);
    padding: 30px 30px 0;
    margin-bottom: 0;
    flex-shrink: 0;
}

/* ✅ CORREÇÃO: Respiro na direita para a barra de rolagem não bater no texto */
.form-modal .modal-scroll-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 15px 30px;
    padding-right: 20px; /* Dá espaço para a barra de rolagem */
    margin-bottom: 0;
    overflow: visible; /* Importante para a aba de cidades funcionar */
    min-height: 0;
}

.form-modal .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--bg-card);
    padding: 15px 30px 30px;
    margin-top: 0;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ✅ CORREÇÃO: Botão de fechar acima da barra de rolagem */
/* ✅ CORREÇÃO: Botão de fechar acima da barra de rolagem E COM ANIMAÇÃO */
.form-modal .close-modal {
    position: absolute;
    top: 15px;
    right: 25px; 
    z-index: 9999; 
    background: var(--bg-card); 
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: color 0.25s ease, background 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* ✅ Restaurando o hover vermelho e a animação */
.form-modal .close-modal:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #ef4444 !important;
    animation: closeSpin 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

.form-modal .close-modal:active {
    transform: rotate(90deg) scale(0.9) !important;
}

/* ✅ A keyframe que faz a animação de girar */
@keyframes closeSpin {
    0%   { transform: rotate(0)     scale(1); }
    100% { transform: rotate(90deg) scale(1.15); }
}

/* ============================================================
   LISTA DE SUGESTÕES (EXPANDE O CONTEÚDO PARA NÃO SER CORTADA)
   ============================================================ */
.form-modal .autocomplete-list {
    position: relative !important; /* Fica no fluxo, empurrando o conteúdo */
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    width: 100% !important;
    
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: 6px;
    max-height: 200px;
    padding: 6px;
    overflow-y: auto;
    z-index: 99;
}

.form-modal .autocomplete-list .autocomplete-item {
    border-bottom: none;
    border-radius: 8px;
    margin-bottom: 2px;
    padding: 10px 14px;
}
.form-modal .autocomplete-list .autocomplete-item:last-child {
    margin-bottom: 0;
}

/* ============================================================
   ABAS DO MODAL DE VENDEDOR
   ============================================================ */
.vmodal-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    padding-bottom: 0;
    flex-shrink: 0;
}

.vmodal-tab {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -2px;
    font-family: inherit;
}

.vmodal-tab:hover {
    color: #2463eb;
    background: var(--bg-hover);
    border-radius: 8px 8px 0 0;
}

.vmodal-tab.active {
    color: #2463eb;
    border-bottom-color: #2463eb;
}

body.dark-mode .vmodal-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

.vmodal-panel {
    display: none;
    animation: fadeInUp 0.3s ease-out;
}

.vmodal-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ✅ CORREÇÃO DO LAYOUT DA ABA DE CIDADES */
#vpanel-cidades.active {
    overflow: hidden;
}

#vpanel-cidades .form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

#vpanel-cidades .cidade-search-wrapper {
    flex-shrink: 0;
    margin-bottom: 15px;
}

#vpanel-cidades #vend-cidades-list {
    flex: 1;
    min-height: 0;
    max-height: none !important;
    height: auto !important;
    overflow-y: auto !important;
    align-content: flex-start;
    margin-top: 0;
}

/* ============================================================
   INPUTS E FORMULÁRIOS
   ============================================================ */
.form-row { display: flex; gap: 16px; }
.form-row .form-group { margin-bottom: 1.5rem; }

.form-group textarea {
    padding: .75rem 1rem;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-input);
    width: 100%;
    resize: vertical;
    font-family: inherit;
}
.form-group textarea:focus {
    outline: none;
    border-color: #2463eb;
    box-shadow: 0 0 0 4px rgba(36, 99, 235, .15);
}

/* ============================================================
   AVATAR MINI E BADGES DA TABELA
   ============================================================ */
.avatar-mini {
    width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 700;
    border: 2px solid var(--bg-card);
    flex-shrink: 0;
}

.vendedor-ativo-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
}
.vendedor-ativo-badge.on  { background: #e1f8ee; color: #079c68; }
.vendedor-ativo-badge.off { background: #fee2e2; color: #b91c1c; }
body.dark-mode .vendedor-ativo-badge.on  { background: #1e3a5f; color: #34d399; }
body.dark-mode .vendedor-ativo-badge.off { background: #3a1e1e; color: #f87171; }

/* ============================================================
   BOTÕES DA TABELA
   ============================================================ */
#vendedoresTable .btn-table {
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.25s ease, color 0.25s ease,
                border-color 0.25s ease, box-shadow 0.3s ease;
    will-change: transform; position: relative;
    border-radius: 8px; font-weight: 600;
    padding: 7px 11px; cursor: pointer;
    border: 1px solid transparent; font-size: 12px;
    margin-right: 4px;
}
#vendedoresTable .btn-table:hover { transform: translateY(-3px); }
#vendedoresTable .btn-table:active { transform: translateY(-1px) scale(0.95); transition-duration: 0.08s; }
#vendedoresTable .btn-table i { display: inline-block; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
#vendedoresTable .btn-table:hover i { animation: iconWiggle 0.5s ease-in-out; }

.btn-edit   { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0 !important; }
.btn-edit:hover   { background: #16a34a; color: #fff; border-color: #16a34a !important; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3); }
.btn-remove { background: #fef2f2; color: #dc2626; border-color: #fecaca !important; }
.btn-remove:hover { background: #dc2626; color: #fff; border-color: #dc2626 !important; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(220, 38, 38, 0.3); }

@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
    .avatar-mini { width: 22px; height: 22px; font-size: 10px; }
}

/* ============================================================
   CAIXA DE CIDADES VINCULADAS
   ============================================================ */
.cidades-list {
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px;
    margin-top: 12px; 
    padding: 16px; 
    min-height: 56px;
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    background: var(--bg-body); 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    align-content: flex-start;
}

body.dark-mode .cidades-list {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.1); 
}

.cidades-empty {
    display: inline-block; width: 100%; text-align: center;
    color: var(--text-secondary);
    font-size: 13px; font-style: italic;
    padding: 4px 0;
}

/* ============================================================
   CHIPS DE CIDADE
   ============================================================ */
.cidade-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 8px 6px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    border-radius: 20px;
    font-size: 13px; font-weight: 500; line-height: 1;
    transition: all 0.2s ease;
}
.cidade-chip:hover { background: #dbeafe; }

.cidade-chip .chip-nome { font-weight: 600; color: inherit; }

.cidade-chip .chip-uf {
    color: inherit; 
    opacity: 0.85;
    font-size: 11px; 
    font-weight: 600;
    margin-left: 2px;
    background: transparent;
    padding: 0;
}

.cidade-chip button.chip-remove {
    background: transparent; border: none;
    color: #ef4444; cursor: pointer;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; padding: 0;
    transition: background 0.15s ease;
    margin-left: 4px;
}
.cidade-chip button.chip-remove:hover { background: #fee2e2; }

body.dark-mode .cidade-chip {
    background: #1e3a5f; 
    border-color: #3b82f6; 
    color: #93c5fd; 
}
body.dark-mode .cidade-chip:hover { background: #1e40af; }

body.dark-mode .cidade-chip button.chip-remove { color: #f87171; }
body.dark-mode .cidade-chip button.chip-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ============================================================
   USUÁRIO DO SISTEMA
   ============================================================ */
.usuario-selected-card {
    display: flex; align-items: center; gap: 12px;
    margin-top: 10px; padding: 12px 14px;
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
    border: 1px solid #bfdbfe; border-radius: 12px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
    transition: all 0.2s ease;
}
.usuario-selected-card:hover { border-color: #93c5fd; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12); }
body.dark-mode .usuario-selected-card { background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%); border-color: #334155; }

.usuario-selected-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #2463eb, #1a4fc4);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(36, 99, 235, 0.25);
}
.usuario-selected-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.usuario-selected-info strong { font-size: 14px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-selected-info small { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-selected-remove {
    width: 30px; height: 30px; border-radius: 50%;
    border: none; background: transparent; color: #ef4444;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 13px; transition: background 0.15s ease; flex-shrink: 0;
}
.usuario-selected-remove:hover { background: rgba(239, 68, 68, 0.15); }
body.dark-mode .usuario-selected-remove { color: #f87171; }
body.dark-mode .usuario-selected-remove:hover { background: rgba(248, 113, 113, 0.2); }

.usuario-sugg-item { display: flex !important; align-items: center !important; gap: 10px !important; padding: 10px 14px !important; }
.usuario-sugg-item.disabled { opacity: 0.55; cursor: not-allowed !important; background: var(--bg-body) !important; }
.usuario-sugg-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #2463eb, #1a4fc4);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; flex-shrink: 0;
}
.usuario-sugg-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.usuario-sugg-info .code { font-weight: 600; color: var(--text-main); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-sugg-info .desc { color: var(--text-secondary); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-sugg-empty { padding: 14px; text-align: center; color: var(--text-secondary); font-size: 13px; font-style: italic; }

/* ============================================================
   DROPDOWN DE CORES
   ============================================================ */
.color-select { position: relative; width: 100%; }
.color-select-trigger {
    display: flex; align-items: center; gap: 10px;
    width: 100%; height: 42px;
    border: 1px solid var(--border-input); border-radius: 6px;
    background: var(--bg-input); padding: 0 12px;
    cursor: pointer; color: var(--text-main); font-size: 13px;
    font-family: inherit; transition: border-color 0.2s, box-shadow 0.2s; text-align: left;
}
.color-select-trigger:hover { border-color: #2463eb; }
.color-select.open .color-select-trigger { border-color: #2463eb; box-shadow: 0 0 0 3px rgba(36, 99, 235, 0.1); }
.color-select-preview { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); transition: background 0.2s; background: #2463eb; }
.color-select-label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.color-select-trigger > i { color: var(--text-secondary); font-size: 12px; transition: transform 0.2s; }
.color-select.open .color-select-trigger > i { transform: rotate(180deg); }

.color-select-options {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    width: 220px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 12px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    z-index: 9999; grid-template-columns: repeat(4, 1fr); gap: 10px;
    max-height: 260px; overflow-y: auto;
}
.color-select-options::-webkit-scrollbar { width: 5px; }
.color-select-options::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }
.color-select.open .color-select-options { display: grid; }
.color-option {
    width: 100%; aspect-ratio: 1; border-radius: 8px; border: 2px solid transparent;
    cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; position: relative; padding: 0; outline: none;
}
.color-option:hover:not(.used) { transform: scale(1.1); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); }
.color-option.selected { border-color: #ffffff; box-shadow: 0 0 0 2px currentColor; }
.color-option.selected::after {
    content: '✓'; position: absolute; inset: 0; color: #fff; font-size: 18px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.color-option.used { cursor: not-allowed; opacity: 0.35; position: relative; }
.color-option.used::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(45deg, transparent calc(50% - 1px), rgba(0, 0, 0, 0.5) calc(50% - 1px), rgba(0, 0, 0, 0.5) calc(50% + 1px), transparent calc(50% + 1px));
    border-radius: 6px;
}
body.dark-mode .color-option.selected { border-color: #1e293b; }

/* ============================================================
   TABELA DE VENDEDORES (PADRÃO AZUL)
   ============================================================ */
#vtab-panel-vendedores .table-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

#vtab-panel-vendedores .table-responsive table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    display: block;
}

#vtab-panel-vendedores .table-responsive thead {
    display: table;
    width: 100%;
    table-layout: fixed;
    position: sticky;
    top: 0;
    z-index: 20;
    background: #1e3a8a;
}

#vtab-panel-vendedores .table-responsive thead th {
    background: #1e3a8a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    text-align: left;
    border: none;
    white-space: nowrap;
    vertical-align: middle;
}

#vtab-panel-vendedores .table-responsive thead th:first-child { border-top-left-radius: 12px; }
#vtab-panel-vendedores .table-responsive thead th:last-child { border-top-right-radius: 12px; }

#vtab-panel-vendedores .table-responsive tbody {
    display: block;
    max-height: 520px;
    overflow-y: auto;
    width: 100%;
}

#vtab-panel-vendedores .table-responsive tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
    transition: background 0.2s ease;
}

#vtab-panel-vendedores .table-responsive tbody tr:hover { background: var(--bg-hover); }

#vtab-panel-vendedores .table-responsive tbody td {
    padding: 12px 16px;
    color: var(--text-main);
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

#vtab-panel-vendedores .table-responsive tbody tr:last-child td { border-bottom: none; }

#vtab-panel-vendedores .table-responsive thead th:nth-child(6),
#vtab-panel-vendedores .table-responsive thead th:nth-child(7),
#vtab-panel-vendedores .table-responsive thead th:nth-child(8) { text-align: center !important; }

#vtab-panel-vendedores .table-responsive th:nth-child(1),
#vtab-panel-vendedores .table-responsive td:nth-child(1) { width: 5%; }
#vtab-panel-vendedores .table-responsive th:nth-child(2),
#vtab-panel-vendedores .table-responsive td:nth-child(2) { width: 22%; }
#vtab-panel-vendedores .table-responsive th:nth-child(3),
#vtab-panel-vendedores .table-responsive td:nth-child(3) { width: 20%; }
#vtab-panel-vendedores .table-responsive th:nth-child(4),
#vtab-panel-vendedores .table-responsive td:nth-child(4) { width: 13%; }
#vtab-panel-vendedores .table-responsive th:nth-child(5),
#vtab-panel-vendedores .table-responsive td:nth-child(5) { width: 13%; }
#vtab-panel-vendedores .table-responsive th:nth-child(6),
#vtab-panel-vendedores .table-responsive td:nth-child(6) { width: 9%; }
#vtab-panel-vendedores .table-responsive th:nth-child(7),
#vtab-panel-vendedores .table-responsive td:nth-child(7) { width: 9%; }
#vtab-panel-vendedores .table-responsive th:nth-child(8),
#vtab-panel-vendedores .table-responsive td:nth-child(8) { width: 9%; }

/* ============================================================
   ANIMAÇÕES PREMIUM DOS BOTÕES (SALVAR E CANCELAR)
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes iconWiggle {
    0%, 100% { transform: rotate(0) scale(1); }
    25%      { transform: rotate(-12deg) scale(1.15); }
    75%      { transform: rotate(12deg) scale(1.15); }
}

.form-modal .btn-primary {
    position: relative;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease, background 0.3s ease, letter-spacing 0.3s ease;
    will-change: transform;
}
.form-modal .btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(36, 99, 235, 0.35), 0 4px 10px rgba(36, 99, 235, 0.2);
    letter-spacing: 0.3px;
}
.form-modal .btn-primary:active:not(:disabled) {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 12px rgba(36, 99, 235, 0.3), inset 0 2px 6px rgba(0, 0, 0, 0.15);
    transition-duration: 0.1s;
}

.form-modal .btn-secondary {
    position: relative;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}
.form-modal .btn-secondary:hover:not(:disabled) {
    background: #ef4444; border-color: #ef4444; color: #ffffff;
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(239, 68, 68, 0.35), 0 4px 10px rgba(239, 68, 68, 0.2);
}
.form-modal .btn-secondary:active:not(:disabled) {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3), inset 0 2px 6px rgba(0, 0, 0, 0.15);
    transition-duration: 0.1s;
}

.cidade-search-wrapper {
    position: relative; /* ✅ Faz o ícone ficar preso dentro do input */
    width: 100%;
}

.cidade-search-wrapper .search-icon {
    pointer-events: none; /* ✅ Faz o clique "atravessar" a lupa e focar no input */
}