/* =================================================================== */
/* 1. GLOBAIS, VARIÁVEIS E TIPOGRAFIA                                  */
/* =================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --color-primary: #7367F0;
    /* Roxo principal */
    --color-danger: #EA5455;
    /* Vermelho */
    --color-success: #28C76F;
    /* Verde */
    --color-warning: #FF9F43;
    /* Laranja */
    --color-dark: #4B4B4B;
    /* Cinza bem escuro para textos */
    --color-light: #F8F7FA;
    /* Fundo principal da página */
    --color-white: #FFFFFF;
    /* Branco para cards */
    --color-info: #00CFE8;
    /* Azul claro para informações */
    --color-gray: #B9B9C3;
    /* Cinza para bordas e textos secundários */
    --color-dark-variant: #6E6B7B;
    /* Cinza escuro para textos de parágrafo */

    --card-border-radius: .5rem;
    --border-radius-1: 0.8rem;

    --card-padding: 1.8rem;
    --padding-1: 1.2rem;

    --box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, 0.07);
}

* {
    margin: 0;
    padding: 0;
    outline: 0;
    appearance: none;
    border: 0;
    text-decoration: none;
    list-style: none;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    width: 100vw;
    font-family: 'Poppins', sans-serif;
    font-size: 0.88rem;
    background: var(--color-light);
    color: var(--color-dark-variant);
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
}

h1 {
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--color-dark);
}

h2 {
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--color-dark);
}

h3 {
    font-size: 0.87rem;
}

/* =================================================================== */
/* 2. COMPONENTES REUTILIZÁVEIS (Cards, Botões, Formulários, Alertas)  */
/* =================================================================== */

.card {
    background: var(--color-white);
    padding: var(--card-padding);
    border-radius: var(--card-border-radius);
    box-shadow: var(--box-shadow);
    transition: all 300ms ease;
}

.card:hover {
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.1);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 0.8rem 1.5rem;
    border-radius: var(--card-border-radius);
    background: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 300ms ease;
    text-align: center;
}

.btn:hover {
    background: #5f54ca;
    /* Variação mais escura do roxo */
}

.btn.btn-danger {
    background-color: var(--color-danger);
}

.btn.btn-danger:hover {
    background-color: #d44848;
}

.btn-secondary {
    background: var(--color-gray);
    color: var(--color-dark);
}

.btn-secondary:hover {
    background: #a8a8b1;
}

.alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: var(--card-border-radius);
    font-size: 0.9rem;
    text-align: left;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: #fce8e8;
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.alert-success {
    background-color: #e4f8ec;
    color: var(--color-success);
    border-color: var(--color-success);
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--color-gray);
    border-radius: var(--card-border-radius);
    box-sizing: border-box;
    background: var(--color-white);
    color: var(--color-dark-variant);
    transition: border-color 300ms ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* =================================================================== */
/* 3. LAYOUT PRINCIPAL DO DASHBOARD                                    */
/* =================================================================== */
.container {
    display: grid;
    width: 96%;
    margin: 0 auto;
    gap: 1.8rem;
    grid-template-columns: 16rem auto 20rem;
    /* Sidebar, Main, Right Section */
}

/* --- MENU LATERAL (SIDEBAR) --- */
aside {
    height: 100vh;
}

aside .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.4rem;
}

aside .logo {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    color: var(--color-dark);
}

aside .logo i {
    font-size: 2rem;
    color: var(--color-primary);
}

aside .close {
    display: none;
}

aside .sidebar {
    display: flex;
    flex-direction: column;
    height: 86vh;
    position: relative;
    top: 3rem;
}

aside .sidebar a {
    display: flex;
    color: var(--color-dark-variant);
    margin-left: 2rem;
    gap: 1rem;
    align-items: center;
    position: relative;
    height: 3.7rem;
    transition: all 300ms ease;
}

aside .sidebar a i {
    font-size: 1.6rem;
}

aside .sidebar a.active {
    background: var(--color-light);
    color: var(--color-primary);
    margin-left: 0;
}

aside .sidebar a.active:before {
    content: '';
    width: 6px;
    height: 100%;
    background: var(--color-primary);
}

aside .sidebar a:hover {
    color: var(--color-primary);
}

aside .sidebar .logout {
    position: absolute;
    bottom: 2rem;
    width: 100%;
}

/* --- CONTEÚDO PRINCIPAL (MAIN) --- */
main {
    margin-top: 1.4rem;
}

main .summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.6rem;
}

main .summary-cards>div {
    padding: var(--card-padding);
    border-radius: var(--card-border-radius);
    margin-top: 1rem;
    box-shadow: var(--box-shadow);
    transition: all 300ms ease;
    cursor: pointer;
}

main .summary-cards>div:hover {
    box-shadow: none;
}

main .summary-cards>div .icon {
    background: var(--color-primary);
    padding: 0.5rem;
    border-radius: 50%;
    color: white;
    font-size: 2rem;
}

main .summary-cards>div.expense .icon {
    background: var(--color-danger);
}

main .summary-cards>div.income .icon {
    background: var(--color-success);
}

main .summary-cards>div .right {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

main .summary-cards .summary-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-dark);
}

/* --- TABELA DE TRANSAÇÕES RECENTES --- */
main .recent-transactions {
    margin-top: 2rem;
}

main .recent-transactions h2 {
    margin-bottom: 0.8rem;
}

main .recent-transactions table {
    background: var(--color-white);
    width: 100%;
    border-radius: var(--card-border-radius);
    padding: var(--card-padding);
    text-align: left;
    box-shadow: var(--box-shadow);
    transition: all 300ms ease;
}

main .recent-transactions table:hover {
    box-shadow: none;
}

main table thead th {
    color: var(--color-dark-variant);
    font-weight: 600;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-gray);
}

main table tbody td {
    height: 3.8rem;
    border-bottom: 1px solid var(--color-light);
}

main table tbody tr:last-child td {
    border: none;
}

.badge {
    padding: 0.3em 0.7em;
    border-radius: 0.25rem;
    font-weight: 600;
    font-size: 0.75em;
    color: var(--color-white);
}

.badge-success {
    background-color: var(--color-success);
}

.badge-danger {
    background-color: var(--color-danger);
}

/* --- SEÇÃO SUPERIOR (DIREITA) --- */
.right-section {
    margin-top: 1.4rem;
}

.right-section .top {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
}

.right-section .top button {
    display: none;
}

/* Botão de menu hambúrguer */
.right-section .top .profile {
    display: flex;
    gap: 2rem;
    text-align: right;
}

.right-section .top .profile-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.right-section .top select {
    background: transparent;
    border: 1px solid var(--color-gray);
    padding: 0.5rem;
    border-radius: 0.4rem;
    color: var(--color-dark-variant);
}

/* =================================================================== */
/* 4. TELAS ESPECÍFICAS (LOGIN, CADASTRO, FORMULÁRIOS)                 */
/* =================================================================== */

/* --- TELA DE LOGIN E CADASTRO --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    max-width: 450px;
    width: 100%;
    text-align: center;
}

.auth-card h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.auth-card .link {
    margin-top: 1.5rem;
}

.auth-card .link a {
    font-weight: 600;
}

/* --- PÁGINAS DE FORMULÁRIO (GERAL) E LISTAGEM --- */
.page-container {
    display: flex;
    justify-content: center;
    padding: 2rem;
    width: 100%;
}

.content-card {
    width: 100%;
    max-width: 800px;
}

.card-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-light);
}

.card-header-actions .btn {
    width: auto;
}

/* Ajusta o botão no header */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions .btn {
    width: auto;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-buttons .action-btn {
    padding: 0.4rem 0.8rem;
    color: white;
    border-radius: 0.3rem;
    font-size: 0.8rem;
}

.action-btn.edit-btn {
    background: var(--color-warning);
}

.action-btn.delete-btn {
    background: var(--color-danger);
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =================================================================== */
/* 5. RESPONSIVIDADE (MOBILE E TABLET)                                 */
/* =================================================================== */
@media screen and (max-width: 1200px) {
    .container {
        width: 94%;
        grid-template-columns: 7rem auto;
        gap: 1rem;
    }

    aside .logo h2,
    aside .sidebar h3 {
        display: none;
    }

    aside .sidebar a {
        width: 5.6rem;
    }

    .right-section {
        display: none;
    }

    /* Esconde a coluna da direita em tablets */
}

@media screen and (max-width: 768px) {
    body {
        background: var(--color-white);
        /* Fundo branco em mobile é mais comum */
    }

    .container {
        width: 100%;
        grid-template-columns: 1fr;
    }

    aside {
        position: fixed;
        left: -100%;
        background: var(--color-white);
        width: 18rem;
        z-index: 3;
        box-shadow: 1rem 3rem 4rem rgba(0, 0, 0, 0.2);
        height: 100vh;
        padding-right: var(--card-padding);
        display: none;
        animation: showMenu 400ms ease forwards;
    }

    @keyframes showMenu {
        to {
            left: 0;
        }
    }

    aside .logo {
        margin-left: 1rem;
    }

    aside .logo h2,
    aside .sidebar h3 {
        display: inline;
    }

    aside .sidebar a {
        width: 100%;
        height: 3.4rem;
    }

    aside .sidebar a:last-child {
        position: absolute;
        bottom: 5rem;
    }

    aside .close {
        display: inline-block;
        cursor: pointer;
    }

    main {
        margin-top: 6rem;
        padding: 0 1rem;
    }

    main .summary-cards {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }

    main .recent-transactions {
        margin-top: 2rem;
    }

    main .recent-transactions table {
        width: 100%;
        margin: 0;
        box-shadow: none;
        padding: 0;
    }

    main table thead {
        display: none;
    }

    /* Esconde cabeçalho em mobile */
    main table tbody tr {
        display: block;
        width: 100%;
        padding: var(--padding-1);
        border-radius: var(--card-border-radius);
        box-shadow: var(--box-shadow);
        margin-bottom: 1rem;
    }

    main table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: auto;
        border: none;
        padding: 0.5rem 0;
    }

    main table tbody tr td:before {
        /* Adiciona label antes do dado */
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-dark);
    }

    main table tbody tr td:last-child {
        font-weight: 600;
        font-size: 1rem;
    }


    .right-section {
        display: block;
        /* Garante que a seção direita reapareça para o cabeçalho mobile */
    }

    .right-section .top {
        position: fixed;
        top: 0;
        left: 0;
        align-items: center;
        padding: 0 1rem;
        height: 4.6rem;
        background: var(--color-white);
        width: 100%;
        margin: 0;
        z-index: 2;
        box-shadow: 0 1rem 1rem rgba(0, 0, 0, 0.05);
    }

    .right-section .top .profile .info,
    .right-section .top .profile-actions .text-muted {
        display: none;
    }

    .right-section .top button {
        display: inline-block;
        background: transparent;
        cursor: pointer;
        color: var(--color-dark);
        position: absolute;
        left: 1rem;
    }

    .right-section .top button i {
        font-size: 2rem;
    }
}

/* =================================================================== */
/* 6. ESTILOS ADICIONAIS PARA TABELAS DE LISTAGEM                      */
/* =================================================================== */

/* Força a tabela a respeitar as larguras definidas, criando um layout mais estável */
main table {
    table-layout: fixed;
    word-wrap: break-word; /* Garante que textos longos quebrem a linha */
}

/* Alinha o conteúdo das células verticalmente ao meio */
main table td {
    vertical-align: middle;
}

/* Define a largura de cada coluna */
.col-cliente { width: 40%; }
.col-documento { width: 20%; }
.col-telefone { width: 20%; }
.col-acoes { 
    width: 10%; 
    min-width: 90px; /* Garante espaço mínimo para os botões */
    text-align: center; /* Centraliza os botões de ação */
}

/* Ajusta o alinhamento dos botões de ação */
.action-buttons {
    justify-content: center;
}

/* VERSÃO NOVA E CORRIGIDA */
.category-list li {
    display: flex;
    justify-content: space-between;
    /* Coloca o nome na esquerda e os botões na direita */
    align-items: center;
    /* Alinha verticalmente ao centro */
    padding: 0.8rem 0.5rem;
    /* Adiciona um pequeno padding lateral */
    border-bottom: 1px solid var(--color-light);
    gap: 1rem;
    /* Adiciona um espaço entre o nome e os botões */
}

.category-list li span {
    flex-grow: 1;
    /* Faz o nome da categoria ocupar todo o espaço disponível */
    color: var(--color-dark-variant);
}

.category-list .action-buttons {
    flex-shrink: 0;
    /* Impede que os botões encolham */
}