/* ===== Reset e Base ===== */

html {
    /* reserva espaço da scrollbar mesmo quando ela não aparece,
       evita reflow horizontal ao filtrar/encolher conteúdo */
    scrollbar-gutter: stable;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2937;
}

/* ===== Tipografia ===== */

h1, h2, h3 {
    color: #1f2937;
}

h1 {
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.2em;
    margin-bottom: 1rem;
}

.subtitle {
    color: #abb7cf;
    margin-bottom: 2rem;
}

/* ===== Headers ===== */

header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3em;
    font-weight: 700;
    color: #667eea;
}

/* ===== Navegação ===== */

nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: #4b5563;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav a:hover {
    color: #667eea;
}

.btn-logout {
    background: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.3s ease;
}

.btn-logout:hover {
    background: #dc2626;
}

/* Botão neutro (ações não-destrutivas, ex.: trocar senha) */
.btn-neutro {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-neutro:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* ===== Container ===== */

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ===== Formulários ===== */

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #ffffff;
    font-size: 0.9em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select {
    width: fit-content;
    height: 15px;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95em;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Controles de formulário não herdam a fonte da página por padrão */
button,
input,
select,
textarea {
    font-family: inherit;
}

/* Campo de arquivo: botão nativo no estilo do .btn-secondary */
input[type="file"] {
    font-size: .9rem;
    color: #475569;
    max-width: 100%;
}

input[type="file"]::file-selector-button {
    margin-right: .75rem;
    padding: .55rem 1.1rem;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

input[type="file"]::file-selector-button:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* ===== Botões ===== */

button,
input[type="submit"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.95em;
}

button:hover,
input[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* ===== Footer ===== */

footer {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 2rem;
    text-align: center;
    color: #6b7280;
    margin-top: 3rem;
}

footer a {
    color: #1d4ed8;
}

/* ===== Mensagens e Alertas ===== */

.erro,
.error {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #991b1b;
    margin-bottom: 1rem;
}

.success {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    padding: 1rem;
    border-radius: 4px;
    color: #166534;
    margin-bottom: 1rem;
}

.alert {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 2rem;
    color: #92400e;
}

.alert strong {
    display: block;
    margin-bottom: 0.25rem;
}

/* ===== Cards ===== */

.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* ===== Grid ===== */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

/* ===== Tabelas Admin ===== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

th {
    background: #f1f5f9;
    text-align: left;
    padding: .65rem 1rem;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
}

td {
    padding: .65rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

tr:hover td {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-supervisor {
    background: #dbeafe;
    color: #1e40af;
}

.badge-staff {
    background: #f0fdf4;
    color: #166534;
}

.badge-sucesso {
    background: #dcfce7;
    color: #15803d;
}

.badge-falha {
    background: #fee2e2;
    color: #b91c1c;
}

.status-icon {
    font-size: 1.1rem;
}

.search-bar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.25rem;
    align-items: baseline;
}

.search-bar input,
.search-bar select {
    padding: .55rem .9rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: .9rem;
    outline: none;
    background: #fff;
    color: #1e293b;
    font-family: inherit;
    height: 38px;
    box-sizing: border-box;
}

.search-bar input {
    flex: 1;
    min-width: 0;
}

.search-bar select {
    min-width: 220px;
    max-width: 400px;
    cursor: pointer;
}

.search-bar input:focus,
.search-bar select:focus {
    border-color: #6366f1;
}

.date-filter {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: 0 .9rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    height: 38px;
    color: #475569;
    font-size: .85rem;
}

.date-filter:focus-within {
    border-color: #6366f1;
}

.date-filter input[type="date"] {
    border: none;
    padding: 0;
    margin: 0;
    height: auto;
    background: transparent;
    font-size: .9rem;
    color: #1e293b;
    outline: none;
    line-height: 1;
    position: relative;
}

.date-filter input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: url('../icons/agenda.svg');
    background-repeat: no-repeat;
    background-size: contain;
    width: 18px;
    height: 18px;
    opacity: .6;
    cursor: pointer;
    filter: invert(28%) sepia(15%) saturate(580%) hue-rotate(180deg);
}

.date-filter input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.btn-primary {
    padding: .55rem 1.1rem;
    background: #2b6de9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .9rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary:hover {
    background: #4f46e5;
}

.flash {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.flash-sucesso {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash-erro {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #94a3b8;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    color: #475569;             /* cinza-azul base — neutraliza azul padrão de <a> */
    text-decoration: none;
    transition: background .15s, color .15s;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: #1e293b;
    transform: none;
    box-shadow: none;
}

/* ===== Modal ===== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal h2 {
    margin: 0 0 1.25rem;
    font-size: 1.1rem;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .35rem;
}

.field input,
.field select {
    width: 100%;
    height: auto;
    padding: .55rem .9rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: .9rem;
    box-sizing: border-box;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #6366f1;
}

.modal-actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-secondary {
    padding: .55rem 1.1rem;
    background: #f1f5f9;
    color: #475569;
    border: none;
    border-radius: 8px;
    font-size: .9rem;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Links com aparência de botão: mesma altura do <button> e sem sublinhado */
a.btn-primary,
a.btn-secondary {
    display: inline-block;
    line-height: normal;
    text-decoration: none;
}

/* ===== Responsivo ===== */

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }

    nav {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .grid,
    .cards {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 0 1rem;
    }
}

/* ===== Demonstração (DEMO_MODE) ===== */
.faixa-demo {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fcd34d;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.aviso-pagina {
    max-width: 560px;
    margin: 4rem auto;
    padding: 0 1rem;
    text-align: center;
}

.aviso-pagina p {
    margin-bottom: 1.5rem;
}

.demo-emails-intro {
    color: #475569;
    margin-bottom: 1rem;
}

.demo-email {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.demo-email-cabecalho {
    display: grid;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
    font-size: 0.92rem;
}

.demo-email-cabecalho .btn-secondary {
    justify-self: start;
    margin-top: 0.4rem;
}

.demo-email a:not([class]),
.demo-emails-lista a {
    color: #1d4ed8;
}

.demo-email-corpo {
    width: 100%;
    height: 70vh;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f4f6f8;
}

.demo-email-texto {
    white-space: pre-wrap;
    font-size: 0.9rem;
}

.contas-demo {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    text-align: left;
    color: #78350f;
}

.contas-demo ul {
    margin: 0.3rem 0 0 1.1rem;
    padding: 0;
}

.contas-demo code {
    overflow-wrap: anywhere;
}
