/* ============================================= */
/* HYCRM DASHBOARD – FINAL (CLEAN UI & SOLID)    */
/* ============================================= */

/* --- Wrapper Principal --- */
.main-wrapper {
    max-width: 1500px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
}

/* --- Cabeçalho e Títulos --- */
.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-titles h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    margin: 0;
    letter-spacing: -0.02em;
}

.header-titles p {
    color: var(--text-muted, #64748b);
    margin: 0.25rem 0 0 0;
    font-size: 0.95rem;
}

/* --- Toolbar (Busca e Botão Novo) --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 480px;
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.search-box input {
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    width: 100%;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #fff;
    box-sizing: border-box;
}

.search-box input:focus {
    border-color: var(--primary-color, #2563eb);
    outline: none;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

/* --- Tabela Card --- */
.table-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

/* Cabeçalhos (TH) */
.crm-table th {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    text-align: left;
}

/* Células (TD) */
.crm-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-main, #0f172a);
    vertical-align: middle;
    font-size: 0.9rem;
}

.crm-table tr:last-child td {
    border-bottom: none;
}

.crm-table tr:hover {
    background-color: #f8fbff;
}

/* --- Helpers de Alinhamento --- */
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }

/* --- Componentes Internos da Tabela --- */

/* 1. Badge Código + Nome */
.company-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.code-badge {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Roboto Mono', monospace;
}

.company-info .meta {
    display: flex;
    flex-direction: column;
}

.company-info strong {
    color: #0f172a;
    font-weight: 600;
}

.company-info .sub-text {
    font-size: 0.8rem;
    color: #64748b;
}

/* 2. Fonte Mono (CNPJ) */
.font-mono {
    font-family: 'Roboto Mono', monospace;
    color: #475569;
    font-size: 0.85rem;
}

/* 3. Tag de Plano */
.plan-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    background: #eff6ff;
    color: #3b82f6;
    font-size: 0.8rem;
    font-weight: 600;
}

/* 4. Status Badges */
.status-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.03em;
}

.status-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-ativo {
    background: #dcfce7;
    color: #15803d;
}
.status-ativo::before { background: #15803d; }

.status-bloqueado, 
.status-cancelado {
    background: #fef2f2;
    color: #b91c1c;
}
.status-bloqueado::before,
.status-cancelado::before { background: #b91c1c; }

/* --- AÇÕES DA TABELA (BOTÕES SÓLIDOS) --- */

.action-group {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

/* Estilo Base Sólido */
.btn-action {
    padding: 0.45rem 1rem;
    border-radius: 99px; /* Pílula */
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 85px;
    color: white !important; /* Texto sempre branco */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

/* Botão VER (Azul Sólido) */
.btn-action-view {
    background-color: #2563eb; 
}
.btn-action-view:hover {
    background-color: #1d4ed8;
}

/* Botão BLOQUEAR (Vermelho Sólido) */
.btn-action-danger {
    background-color: #dc2626;
}
.btn-action-danger:hover {
    background-color: #b91c1c;
}

/* Botão ATIVAR (Verde Sólido) */
.btn-action-success {
    background-color: #16a34a;
}
.btn-action-success:hover {
    background-color: #15803d;
}

/* --- BOTÕES GERAIS E GRANDES --- */

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

/* Botão Primário (Azul Sólido) */
.btn-primary {
    background-color: #2563eb;
    color: white;
}
.btn-primary:hover {
    background-color: #1d4ed8;
}

/* Botão Perigo (Vermelho Sólido - Para Actions da Pagina) */
.btn-danger {
    background-color: #dc2626;
    color: white;
}
.btn-danger:hover {
    background-color: #b91c1c;
}

/* Botão Secundário (Branco com borda) */
.btn-secondary {
    background: white;
    border: 1px solid #e2e8f0;
    color: #0f172a;
}
.btn-secondary:hover {
    background: #f8fafc;
}

.btn-gray {
    background-color: #f1f5f9;
    color: #475569;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    border: 1px dashed var(--border-color, #e2e8f0);
    margin-top: 2rem;
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { margin: 0 0 0.5rem 0; color: var(--text-main, #0f172a); font-weight: 600; }
.empty-state p { color: #64748b; margin-bottom: 1.5rem; }

/* --- Responsividade Mobile --- */
@media (max-width: 768px) {
    .page-header-flex { flex-direction: column; align-items: flex-start; }
    .toolbar { flex-direction: column-reverse; align-items: stretch; }
    .search-box { max-width: 100%; }
    
    .crm-table thead { display: none; }
    .crm-table, .crm-table tbody, .crm-table tr, .crm-table td {
        display: block;
        width: 100%;
    }
    
    .crm-table tr { 
        border: 1px solid var(--border-color, #e2e8f0); 
        margin-bottom: 1rem; 
        border-radius: 12px;
        padding: 1rem;
        box-shadow: 0 2px 5px rgba(0,0,0,0.03);
        background: white;
    }
    
    .crm-table td { 
        padding: 0.5rem 0; 
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }
    
    .crm-table td:last-child { border-bottom: none; }
    
    .crm-table td::before {
        /* content: attr(data-label); */
        font-weight: 600;
        color: #64748b;
        font-size: 0.85rem;
    }

    .action-group { 
        justify-content: stretch; 
        margin-top: 1rem; 
        border-top: 1px solid #f1f5f9; 
        padding-top: 1rem; 
    }
    /* No mobile, botões sólidos ocupam a largura toda */
    .action-group .btn-action {
        flex: 1;
        border-radius: 8px; 
        padding: 0.7rem;
    }
}


/* ============================================= */
/* MODAL / POPUP CENTRALIZADO (ESTILO FINAL)     */
/* ============================================= */

/* Fundo escuro que cobre a tela toda */
.modal-overlay {
    position: fixed;       /* Fixa na tela, independente do scroll */
    inset: 0;              /* Top:0, Right:0, Bottom:0, Left:0 */
    background-color: rgba(0, 0, 0, 0.6); /* Fundo preto semitransparente */
    backdrop-filter: blur(4px);           /* Desfoque suave no fundo (efeito vidro) */
    display: flex;         /* Habilita flexbox */
    align-items: center;   /* Centraliza verticalmente */
    justify-content: center; /* Centraliza horizontalmente */
    z-index: 9999;         /* Garante que fique acima de tudo */
    opacity: 0;            /* Começa invisível para animação */
    visibility: hidden;
    transition: all 0.3s ease;
}

/* Quando não tem a classe 'hidden', aparece */
.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

/* A caixa branca do modal */
.modal-content {
    background: white;
    width: 90%;
    max-width: 450px;      /* Largura máxima confortável */
    border-radius: 16px;   /* Cantos arredondados */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transform: scale(0.95); /* Começa levemente menor */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Efeito de "pulo" suave */
}

/* Quando visível, escala para o tamanho normal */
.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1);
}

/* Cabeçalho do Modal */
.modal-header {
    padding: 1.5rem 1.5rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main, #0f172a);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: #f1f5f9;
    color: #ef4444;
}

/* Corpo do Modal */
.modal-body {
    padding: 1rem 1.5rem 2rem;
    color: #475569;
    font-size: 1rem;
    line-height: 1.6;
}

/* Rodapé com botões */
.modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    background-color: #f8fafc; /* Fundo levemente cinza */
    display: flex;
    justify-content: flex-end; /* Botões à direita */
    gap: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

/* Helper para esconder elementos */
.hidden {
    display: none !important;
}