/* =========================================
   1. Variáveis e Cores da Marca (Coco & Cia)
   ========================================= */
:root {
    /* Paleta da Marca */
    --brand-green: #387C44;
    /* Verde Principal */
    --brand-yellow: #FDCB58;
    /* Amarelo Sol (Detalhes) */
    --brand-orange: #ED8936;
    /* Laranja Terra (Ações) */
    --brand-cream: #F4F7F6;
    /* Fundo Off-white */
    --brand-dark: #1a3a23;
    /* Texto Escuro */

    /* Cores de Sistema */
    --danger: #e74c3c;
    /* Erro/Sair */
    --success: #2ecc71;
    /* Sucesso/Online */
    --gray-light: #ddd;
}

/* =========================================
   2. Reset e Estilos Globais
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif;
    background-color: var(--brand-cream);
    color: var(--brand-dark);
    /* Espaço para o footer fixo não cobrir conteúdo */
    padding-bottom: 60px;
    line-height: 1.6;
}

/* Container Principal */
.container {
    width: 95%;
    max-width: 1000px;
    /* Aumentado para caber tabelas */
    margin: 0 auto;
    padding: 20px 0;
}

/* =========================================
   3. Header e Navegação (Desktop First)
   ========================================= */
.main-header {
    background-color: var(--brand-green);
    color: white;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: sticky;
    /* Fixa o header no topo */
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Identidade Visual (Logo) */
.brand-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
    transition: opacity 0.3s;
}

.brand-logo:hover {
    opacity: 0.9;
}

.header-logo-img {
    height: 45px;
    width: 45px;
    margin-right: 12px;
    border-radius: 50%;
    border: 2px solid var(--brand-yellow);
    background: white;
    object-fit: cover;
}

.brand-name {
    font-weight: 700;
    font-size: 1.3rem;
    line-height: 1.1;
    display: flex;
    flex-direction: column;
}

.brand-subtitle {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--brand-yellow);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Navegação Principal */
.main-nav .nav-list {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 5px;
}

.nav-link {
    text-decoration: none;
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
}

.nav-link:hover,
.nav-link:focus {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--brand-yellow);
}

/* Botão Sair */
.btn-logout {
    background-color: rgba(231, 76, 60, 0.2);
    margin-left: 10px;
}

.btn-logout:hover {
    background-color: var(--danger);
    color: white;
}

/* --- Dropdown Menu (Cadastros) --- */
.dropdown-item {
    position: relative;
}

.dropdown-toggle .arrow {
    font-size: 0.7rem;
    margin-left: 6px;
    transition: transform 0.3s;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 0;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1001;
}

.dropdown-menu li a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--brand-dark);
    transition: background 0.2s;
    font-size: 0.9rem;
}

.dropdown-menu li a:hover {
    background-color: #f0f0f0;
    color: var(--brand-green);
    padding-left: 25px;
    /* Efeito visual de slide */
}

/* Mostra Dropdown no Hover (Desktop) */
.dropdown-item:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item:hover .arrow {
    transform: rotate(180deg);
}

/* Toggle Mobile (Escondido no Desktop) */
.mobile-menu-toggle {
    display: none;
}


/* =========================================
   4. Estilos de Formulários e Botões
   ========================================= */
input,
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    font-size: 16px;
    /* Evita zoom no iOS */
    background-color: white;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--brand-green);
    box-shadow: 0 0 0 3px rgba(56, 124, 68, 0.1);
}

button[type="submit"],
.btn-primary {
    width: 100%;
    padding: 15px;
    background-color: var(--brand-green);
    color: white;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: background-color 0.3s, transform 0.1s;
    margin-bottom: 15px;
}

button[type="submit"]:hover {
    background-color: #2e6638;
    /* Verde mais escuro */
}

button[type="submit"]:active {
    transform: scale(0.98);
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--brand-dark);
    font-size: 0.95rem;
}

/* Mensagens de Alerta */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
}

.alert.error {
    background-color: #fadbd8;
    color: #922b21;
    border: 1px solid #f5b7b1;
}

.alert.success {
    background-color: #d4efdf;
    color: #1e8449;
    border: 1px solid #a9dfbf;
}

/* =========================================
   5. Tabelas (Dashboard)
   ========================================= */
.table-responsive {
    overflow-x: auto;
    background: white;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Garante largura mínima no mobile */
}

thead tr {
    background-color: var(--brand-green);
    color: white;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

tr:hover {
    background-color: #f9f9f9;
}

/* =========================================
   6. Responsividade (Mobile < 768px)
   ========================================= */
@media (max-width: 768px) {
    .header-container {
        padding: 0.2rem 0;
    }

    .brand-name {
        font-size: 1.1rem;
    }

    .header-logo-img {
        height: 38px;
        width: 38px;
    }

    /* Botão Hambúrguer */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
        background: transparent;
        border: none;
        cursor: pointer;
        z-index: 1002;
        padding: 0;
        margin-left: 10px;
    }

    .mobile-menu-toggle span {
        width: 100%;
        height: 3px;
        background-color: white;
        border-radius: 10px;
        transition: all 0.3s linear;
        position: relative;
        transform-origin: 1px;
    }

    /* Animação X do Hambúrguer */
    .mobile-menu-toggle.active span:first-child {
        transform: rotate(45deg);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg);
    }

    /* Menu Mobile Slide-in */
    .main-nav {
        position: fixed;
        top: 60px;
        /* Abaixo do header */
        right: 0;
        width: 75%;
        /* Ocupa 75% da tela */
        height: calc(100vh - 60px);
        background-color: var(--brand-green);
        padding: 20px 0;
        box-shadow: -2px 5px 10px rgba(0, 0, 0, 0.2);
        transform: translateX(100%);
        /* Esconde na direita */
        transition: transform 0.3s ease-in-out;
        overflow-y: auto;
    }

    .main-nav.active {
        transform: translateX(0);
    }

    .nav-list {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .nav-list li {
        width: 100%;
    }

    .nav-link {
        display: block;
        width: 100%;
        padding: 15px 25px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        text-align: left;
    }

    .btn-logout {
        margin: 0;
        background-color: rgba(231, 76, 60, 0.2);
        border-bottom: none;
    }

    /* Dropdown Mobile (Accordion) */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background-color: rgba(0, 0, 0, 0.1);
        /* Fundo mais escuro */
        border-radius: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .dropdown-menu.show-mobile {
        max-height: 300px;
    }

    .dropdown-menu li a {
        padding-left: 40px;
        color: #eee;
    }

    .dropdown-toggle .arrow {
        display: none;
    }
}

/* =========================================
   7. Footer e Status (Connection)
   ========================================= */
.main-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.8rem;
    color: #777;
}

#status-connection {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    font-weight: bold;
    z-index: 2000;
    letter-spacing: 0.5px;
}

.status-online {
    background-color: var(--success);
    color: white;
}

.status-offline {
    background-color: var(--danger);
    color: white;
}