:root {
    --primary: #4CAF50;
    --primary-dark: #45a049;
    --danger: #f44336;
    --danger-dark: #da190b;
    --info: #007bff;
    --info-dark: #0056b3;
    --light-bg: #f5f5f5;
    --container-bg: #fff;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --border: 1px solid #ddd;
}

.tab-selector {
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
    display: flex;
    gap: 10px;
    background-color: #fafafa; /* Fundo suave */
    padding: 5px 0 0; /* Mais espaço em cima */
}

.tab-button {
    display: inline-block;
    padding: 10px 15px;
    text-decoration: none !important; /* FORÇA A REMOÇÃO DO SUBLINHADO */
    color: #555 !important; /* FORÇA A COR DO TEXTO */
    font-weight: bold;
    border: 1px solid transparent;
    border-bottom: 0;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    line-height: 1.2; /* Para garantir alinhamento */
}

.tab-button:hover {
    background-color: #eee;
}

.tab-button.active {
    color: var(--primary) !important; /* Cor verde para ativo */
    border-color: #ddd;
    border-top-color: #ddd;
    border-left-color: #ddd;
    border-right-color: #ddd;
    background-color: var(--container-bg);
    border-bottom: 2px solid var(--primary); /* Linha verde de destaque */
    margin-bottom: -2px;
}

/* Definição de largura das colunas */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;

}

.table-container {
    /* Define uma largura máxima para o contêiner */
    max-width: 100%; 
    /* Adiciona a barra de rolagem horizontal quando o conteúdo exceder a largura */
    overflow-x: auto; 
    margin-bottom: 20px; /* Adiciona algum espaço abaixo da tabela */
}

.table-container table {
    /* Garante que a tabela use o espaço necessário, permitindo que ela seja maior que 100% da viewport */
    width: 100%; 
    /* Adicione 'min-width' se a largura total for muito pequena para as colunas */
    /* Por exemplo: min-width: 1200px; */ /* <-- Comente ou remova esta linha */
    
    /* 🚀 NOVO: Define a largura mínima para forçar a rolagem horizontal */
    min-width: 1500px; /* Valor em pixels para acomodar as 13 colunas */
    
    border-collapse: collapse;
}

th:nth-child(1), td:nth-child(1) { /* ID */
    width: 5%;
}

th:nth-child(2), td:nth-child(2) { /* Nome */
    width: 14%;
}

th:nth-child(3), td:nth-child(3) { /* Telefone */
    width: 13%;
}

th:nth-child(4), td:nth-child(4) { /* Email */
    width: 15%;
}

th:nth-child(5), td:nth-child(5) { /* Mensagem */
    width: 12%;
}

th:nth-child(6), td:nth-child(6) { /* Fonte */
    width: 9%;
}

th:nth-child(7), td:nth-child(7) { /* Data */
    width: 12%;
}

th:nth-child(8), td:nth-child(8) { /* Obs. */
    width: 10%;
}

th:nth-child(9), td:nth-child(9) { /* Obs. */
    width: 10%;
}


/* Estilos gerais */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--light-bg);
}

.container {
    max-width: 1350px;
    margin: 0 auto;
    background-color: var(--container-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: relative;
}

h1 {
    color: #333;
    margin: 0 0 15px;
    font-size: 1.5em;
}

/* Login */
.login-box {
    padding: 20px;
    border: var(--border);
    border-radius: 5px;
    background-color: var(--container-bg);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 340px;
    margin: 80px auto;
    text-align: center;
}

.login-box h2 {
    margin-bottom: 20px;
    color: #333;
}

.login-box .error {
    color: red;
    margin-bottom: 10px;
}

.login-box input,
.search-box input[type="text"],
.search-box input[type="date"] {
    margin-bottom: 10px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
    border: var(--border);
    border-radius: 4px;
    font-size: 14px;
}

.leadsperpage {
    margin: 0px 5px;
}

.leadsperpages {
    padding: 8px;
}

button,
input[type="submit"],
.clear-button,
.refresh-button,
.logout {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

button,
input[type="submit"] {
    background-color: var(--primary);
}

button:hover,
input[type="submit"]:hover {
    background-color: var(--primary-dark);
}

.clear-button,
.logout {
    background-color: var(--danger);
    text-decoration: none;
}

.clear-button:hover,
.logout:hover {
    background-color: var(--danger-dark);
}

.refresh-button {
    background-color: var(--info);
}

.refresh-button:hover {
    background-color: var(--info-dark);
}

.logout {
    position: absolute;
    top: 10px;
    right: 20px;
}

.search-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.date-fields {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Tabela */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th,
td {
    padding: 5px;
    text-align: left;
    border-bottom: var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

th {
    background-color: var(--primary);
    color: white;
    font-weight: bold;
}

tr:hover {
    background-color: #f9f9f9;
}

th a {
    color: white;
    text-decoration: none;
    display: block;
    padding: 12px;
    box-sizing: border-box;
}

/* Estilos para as colunas */
.nome-resumido,
.email-resumido,
.mensagem-resumida,
.obs-resumida {
    cursor: pointer;
    display: block;
    padding: 5px;
    line-height: 1em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    /* CORRIGIDO: Cor do stroke alterada para cinza escuro (%23555) */
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23555" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>') no-repeat center;
    vertical-align: middle;
    margin-left: 5px;
}

.obs-edit {
    width: 100%;
    height: auto;
    line-height: 1em;
    padding: 5px;
    resize: vertical;
    border: var(--border);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    display: none;
}

/* Paginação */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
    padding: 5px;
    background-color: #f0f0f0;
    border-radius: 5px;
    gap: 5px;
}

.pagination a {
    color: #333;
    padding: 8px 12px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    transition: background-color 0.2s;
}

.pagination a:hover:not(.active) {
    background-color: #ddd;
}

.pagination a.active {
    background-color: #4CAF50;
    color: white;
    border: 1px solid #4CAF50;
    font-weight: bold;
}

.pagination .ellipsis {
    padding: 8px 12px;
    color: #999;
    font-size: 14px;
    user-select: none;
}

/* Mensagem */
#success-message {
    display: block;
    padding: 10px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 10px;
}

.no-results {
    text-align: center;
    padding: 20px;
    color: #666;
}

/* Responsivo */
@media (max-width: 600px) {
    .search-box {
        flex-direction: column;
        align-items: stretch;
    }

    .date-fields {
        flex-direction: row;
        width: 100%;
    }

    .date-fields input[type="date"] {
        width: 50%;
    }

    .button-group {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        margin: 10px 0px;
    }

    .button-group input[type="submit"],
    .button-group .clear-button {
        width: 48%;
    }

    .login-box {
        margin: 40px auto;
        width: 90%;
    }

    .container {
        padding: 10px;
    }

    .leadsperpage {
        margin: 0px;
    }

    table {
        width: 100%;
        min-width: 600px;
        font-size: 12px;
    }

    th, td {
        padding: 8px;
    }

    th a {
        padding: 8px;
    }

    .search-box input[type="text"],
    .search-box input[type="date"],
    .search-box select {
        font-size: 12px;
    }

    .pagination a {
        padding: 6px 10px;
        font-size: 12px;
    }

    th:nth-child(4), td:nth-child(4), /* Email */
    th:nth-child(5), td:nth-child(5), /* Mensagem */
    th:nth-child(6), td:nth-child(6), /* Fonte */
    th:nth-child(8), td:nth-child(8) { /* Obs. */
        display: none;
    }
}