/* ====== BASE ====== */
body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #f4faff;
    margin: 0;
    padding: 0;
    color: #333;
    padding-bottom: 50px;
    /* espaço para o footer fixo */
}

header {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    text-align: center;
}

footer {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    text-align: center;
    font-size: 14px;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

/* ====== CONTAINER WIDE ADAPTÁVEL ====== */
/* grande, mas se ajusta ao tamanho da tela */
.container.container-wide {
    width: 95%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

/* telas médias: dá um fôlego */
@media (max-width: 1200px) {
    .container.container-wide {
        width: 96%;
        max-width: 1100px;
    }
}

/* telas pequenas: usa quase tudo, mas com margens */
@media (max-width: 768px) {
    .container.container-wide {
        width: 96%;
        max-width: 96%;
        padding: 16px;
    }
}

/* ====== TABELA RESPONSIVA ====== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Nome: 1 linha em telas grandes (melhor leitura) */
.tabela-clientes th:nth-child(1),
.tabela-clientes td:nth-child(1) {
    white-space: nowrap;
    min-width: 380px;
    /* ajuste se quiser mais (400/420) */
    max-width: none;
}

/* Email também em 1 linha (opcional) */
.tabela-clientes th:nth-child(3),
.tabela-clientes td:nth-child(3) {
    white-space: nowrap;
}

/* Em telas menores, deixe quebrar para não bagunçar */
@media (max-width: 1024px) {

    .tabela-clientes th:nth-child(1),
    .tabela-clientes td:nth-child(1),
    .tabela-clientes th:nth-child(3),
    .tabela-clientes td:nth-child(3) {
        white-space: normal;
        /* pode quebrar */
        min-width: 220px;
        /* espaço mínimo razoável */
        word-break: break-word;
        /* quebra palavras longas */
    }
}

/* CPF/WhatsApp podem quebrar para liberar espaço */
.tabela-clientes td:nth-child(4),
.tabela-clientes td:nth-child(5) {
    white-space: normal;
    word-break: break-word;
}

/* ====== BOTÕES DAS AÇÕES ALINHADOS E RESPONSIVOS ====== */
.btn-acao {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    line-height: 1;
    min-height: 36px;
    /* altura consistente */
    min-width: 100px;
    /* largura mínima igual */
    text-align: center;
}

/* quando não couber, quebra em linhas bonitinho */
.acoes-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* em telas bem pequenas, cada botão pode ocupar metade ou 100% */
@media (max-width: 520px) {
    .acoes-cell .btn-acao {
        flex: 1 1 48%;
        /* 2 por linha */
    }
}

@media (max-width: 380px) {
    .acoes-cell .btn-acao {
        flex: 1 1 100%;
        /* 1 por linha */
    }
}

/* ====== FORM / CONTROLES ====== */
input,
select,
button {
    padding: 10px;
    margin: 8px 0;
    width: 100%;
    border-radius: 5px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

/* ====== MENU ====== */
.menu {
    background-color: #e8f0ff;
    padding: 10px;
    text-align: center;
}

.menu a {
    margin: 0 10px;
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
}

/* ====== BOTÕES GRANDES ====== */
.botoes-dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
}

.btn-enviar {
    padding: 30px 50px;
    font-size: 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: 300px;
}

.btn-enviar:hover {
    background-color: #0056b3;
}

.btn-menor {
    padding: 12px 20px;
    font-size: 16px;
    background-color: #5aa8ff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: 220px;
}

.btn-menor:hover {
    background-color: #3e8ed0;
}

/* ====== CARDS ====== */
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

/* ====== GRIDS ====== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 12px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field input,
.field select,
.field textarea {
    padding: 8px 10px;
    font-size: 14px;
    box-sizing: border-box;
}

.subtitle {
    font-weight: 700;
    margin: 12px 0 6px;
    color: #374151;
}

#formCadastro,
#formEditar {
    display: none;
}

/* ====== TABELAS ====== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tabela-clientes {
    width: 100%;
    table-layout: auto;
    white-space: normal;
    word-break: break-word;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

.tabela-clientes th,
.tabela-clientes td {
    border: 1px solid #e5e7eb;
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    white-space: normal;
    max-width: 600px;
    /* limite global suave; pode quebrar */
}

.tabela-clientes th {
    background: #007bff;
    color: #fff;
}

/* Nome: uma linha só, com largura mínima confortável e sem limite máximo */
.tabela-clientes th:nth-child(1),
.tabela-clientes td:nth-child(1) {
    white-space: nowrap;
    min-width: 380px;
    /* ajuste se necessário: 400/420 */
    max-width: none;
}

/* Email (opcional) em uma linha */
.tabela-clientes th:nth-child(3),
.tabela-clientes td:nth-child(3) {
    white-space: nowrap;
}

/* Coluna Ações compacta */
.tabela-clientes td.col-acoes {
    white-space: nowrap;
}

/* ====== AÇÕES ====== */
.acoes-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.acao-form {
    margin: 0;
    display: inline-block;
}

.btn-acao {
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;

    min-width: 10px;
    /* largura mínima igual pra todos */
    text-align: center;
    /* centraliza o texto/ícone */
}

.btn-editar {
    background: #198754;
    color: #fff;
}

.btn-editar:hover {
    background: #146c43;
}

.btn-reset {
    background: #007bff;
    color: #fff;
}

.btn-reset:hover {
    background: #0056b3;
}

.btn-excluir {
    background: #dc3545;
    color: #fff;
}

.btn-excluir:hover {
    background: #b02a37;
}

/* ====== ALERTA ====== */
.alert {
    background: #ecfeff;
    border: 1px solid #67e8f9;
    color: #155e75;
    padding: 10px 12px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 12px;
    font-weight: 600;
}

/* ====== RESPONSIVO ====== */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 640px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .form-busca {
        display: flex;
        flex-direction: column;
    }

    .form-busca input[type="text"],
    .form-busca button {
        width: 100%;
        border-radius: 6px;
    }
}

/* ====== AÇÕES (alinhados, mesmo tamanho, centralizados) ====== */
.acoes-cell {
    display: flex;
    justify-content: center;
    /* centraliza os botões na célula */
    align-items: center;
    gap: 8px;
    /* espaço entre botões */
    flex-wrap: wrap;
    /* quebra linha quando necessário */
}

.acao-form {
    margin: 0;
    display: inline-block;
    /* mantém cada form como “caixa” do botão */
}

.btn-acao {
    padding: 8px 0;
    /* altura uniforme */
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;

    width: 110px;
    /* todos EXACTAMENTE iguais */
    min-height: 36px;
    /* mesma altura mínima */
    text-align: center;
    /* centraliza texto/emoji */
    box-sizing: border-box;
    /* inclui padding na largura */
}

/* Responsivo: em telas pequenas, os botões se ajustam sem perder padrão */
@media (max-width: 520px) {
    .acoes-cell .btn-acao {
        flex: 1 1 48%;
        /* 2 por linha */
        width: auto;
        /* libera a largura para o layout responsivo */
    }
}

@media (max-width: 380px) {
    .acoes-cell .btn-acao {
        flex: 1 1 100%;
        /* 1 por linha */
    }
}

/* Cores/estados permanecem como você já tinha */
.btn-editar {
    background: #198754;
    color: #fff;
}

.btn-editar:hover {
    background: #146c43;
}

.btn-reset {
    background: #007bff;
    color: #fff;
}

.btn-reset:hover {
    background: #0056b3;
}

.btn-excluir {
    background: #dc3545;
    color: #fff;
}

.btn-excluir:hover {
    background: #b02a37;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #b02a37;
}

/* botão de toggle (padrão ativo = azul, desativado = cinza) */
.btn-acao.btn-toggle {
    background: #0d6efd;
    border: 1px solid #0b5ed7;
    color: #fff;
}

.btn-acao.btn-toggle:hover {
    filter: brightness(0.95);
}

/* quando a faixa estiver DESATIVADA, o botão fica cinza */
.btn-acao.btn-toggle.is-inactive {
    background: #d1d5db;
    /* cinza claro */
    border-color: #cbd5e1;
    /* cinza um pouco mais escuro */
    color: #4b5563;
    /* cinza do texto */
}

.btn-acao.btn-toggle.is-inactive:hover {
    filter: brightness(0.98);
}

.btn-wa {
    background: #25D366;
    color: #fff;
}

.btn-wa:hover {
    filter: brightness(0.95);
}

.btn-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    padding: 0;
    font-size: 18px;
    /* tamanho do emoji */
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}

.btn-wa {
    background: #ffffff;
    color: #fff;
}

.btn-wa:hover {
    filter: brightness(0.95);
}

/* ====== Menu agrupado com dropdowns ====== */
.menu-groups {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Link padrão do menu já existente — reaproveitamos sua classe .menu */
.menu-groups>a,
.menu-groups .dropbtn {
    background: #f5f7fb;
    border: 1px solid #e3e7ee;
    color: #333;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: all .15s ease;
    font-weight: 600;
}

.menu-groups>a:hover,
.menu-groups .dropbtn:hover {
    background: #e9eef7;
}

/* Dropdown container */
.menu-groups .dropdown {
    position: relative;
    display: inline-block;
}

/* Submenu */
.menu-groups .dropdown-content {
    display: none;
    position: absolute;
    min-width: 200px;
    top: calc(100% + 6px);
    left: 0;
    background-color: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
    z-index: 999;
    padding: 6px;
}

.menu-groups .dropdown-content a {
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    color: #333;
}

.menu-groups .dropdown-content a:hover {
    background: #f5f7fb;
}

/* Mostrar no hover (desktop) */
.menu-groups .dropdown:hover .dropdown-content {
    display: block;
}

/* Estado aberto via JS (para clique e mobile) */
.menu-groups .dropdown.open .dropdown-content {
    display: block;
}

/* Botão SAIR em vermelho */
.menu-groups .btn-sair {
    background: #dc3545;
    /* vermelho */
    border-color: #dc3545;
    color: #fff !important;
}

.menu-groups .btn-sair:hover {
    filter: brightness(0.92);
}
/* Botão verde claro para disparo manual */
.btn-success-light {
    background: #e8f8ee;
    color: #0f6b2a;
    border-color: #cdeed6;
    box-shadow: 0 2px 6px rgba(15, 107, 42, .12);
}

.btn-success-light:hover {
    background: #d8f1e1;
}

.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    /* não quebra linha */
}