/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    color: #333;
}

/* Cores do Sistema */
:root {
    --primary-blue: #2a5298;
    --secondary-blue: #1e3c72;
    --accent-red: #dc3545;
    --white: #ffffff;
    --light-gray: #f8f9fa;
    --dark-gray: #6c757d;
    --success-green: #28a745;
    --warning-yellow: #ffc107;
}

/* Layout Principal */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Tela de Login */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.logo {
    text-align: center;
    margin-bottom: 40px;
    color: var(--white);
}

.logo i {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 300;
}

#loginForm {
    background: var(--white);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
}

.guest-login {
    width: 100%;
    max-width: 400px;
}

/* Header */
.header {
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://images.unsplash.com/photo-1524661135-423995f22d0b?ixlib=rb-4.0.3&auto=format&fit=crop&w=1600&q=80');
    background-size: cover;
    background-position: center;
    opacity: 0.30;
    z-index: 0;
    pointer-events: none;
}

.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.header h1 {
    color: var(--primary-blue);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-blue);
    cursor: pointer;
    padding: 5px;
}

.mobile-only {
    display: none;
}

/* Navegação */
.nav-tabs {
    background: var(--white);
    border-bottom: 1px solid #e9ecef;
    padding: 0 20px;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tab {
    background: none;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--dark-gray);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Responsividade e Mobile Menu */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header h1 i {
        font-size: 1.1rem;
    }

    .user-info {
        display: none; /* Esconde nome do usuário no mobile para economizar espaço */
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }

    .menu-toggle {
        display: block;
    }

    .nav-tabs {
        display: none; /* Esconde menu por padrão no mobile */
        flex-direction: column;
        padding: 0;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        z-index: 99;
        border-bottom: none;
    }

    .nav-tabs.active {
        display: flex;
    }

    .nav-tab {
        width: 100%;
        text-align: left;
        padding: 15px 25px;
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-tab.active {
        border-bottom: 1px solid #f0f0f0;
        border-left: 4px solid var(--primary-blue);
        background-color: #f8f9fa;
    }

    /* Ajuste dos filtros para não rolar horizontalmente */
    .header-with-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .header-filters {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        overflow-x: visible; /* Remove rolagem horizontal */
    }

    .filter-input {
        width: 100%; /* Ocupa 100% da largura */
        min-width: 0; /* Permite encolher se necessário */
    }

    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .filters select {
        width: 100%;
    }
    
    .tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .tab-header button {
        width: 100%;
    }
    
    .header-with-total {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

.nav-tab:hover {
    color: var(--primary-blue);
}

.nav-tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

/* Conteúdo das Abas */
.tab-content {
    display: none;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-with-filters, .header-with-total {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.header-filters {
    display: flex;
    gap: 10px;
}

.filter-input {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.filter-input:focus {
    border-color: var(--primary-blue);
}

.total-badge {
    background: var(--success-green);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tab-header h2 {
    color: var(--white);
    font-size: 2rem;
    font-weight: 600;
}

/* Botões */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-align: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--secondary-blue);
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-outline {
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.btn-outline:hover {
    background: var(--primary-blue);
    color: var(--white);
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: var(--success-green);
    color: var(--white);
}

.btn-success:hover {
    background: #218838;
}

/* Cards */
.trip-card, .expense-card, .report-card, .admin-card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.trip-card:hover, .expense-card:hover {
    transform: translateY(-5px);
}

.trip-card h3, .expense-card h3 {
    color: var(--secondary-blue);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.trip-info, .expense-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-weight: 600;
    color: var(--dark-gray);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.info-value {
    color: var(--secondary-blue);
    font-size: 1.1rem;
}

/* Status */
.status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

.status.active {
    background: #d4edda;
    color: #155724;
}

.status.completed {
    background: #cce5ff;
    color: #004085;
}

.status.planned {
    background: #fff3cd;
    color: #856404;
}

/* Formulários */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-blue);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Modais */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

/* Modal de Edição/Criação de Despesa deve ficar acima da lista de despesas da viagem */
#expenseModal {
    z-index: 1050;
}

/* Modal de Mapa também deve ficar acima */
#mapModal {
    z-index: 1060;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--white);
    border-radius: 15px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 25px 0;
    margin-bottom: 25px;
}

.modal-header h3 {
    color: var(--secondary-blue);
    font-size: 1.5rem;
}

.close {
    font-size: 2rem;
    cursor: pointer;
    color: var(--dark-gray);
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--accent-red);
}

.modal form {
    padding: 0 25px 25px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Filtros */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filters select {
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: var(--white);
    min-width: 200px;
}

/* Listas */
.trips-list, .expenses-list {
    display: grid;
    gap: 20px;
}

/* Preview de Recibo */
#receiptPreview {
    margin-top: 10px;
}

#receiptPreview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

/* Administração */
.admin-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

/* Gráficos */
.charts-filters {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.charts-filters .form-group {
    margin-bottom: 0;
    max-width: 300px;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
}

.chart-card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.chart-card:hover {
    transform: translateY(-5px);
}

.chart-card h3 {
    color: var(--secondary-blue);
    margin-bottom: 20px;
    font-size: 1.3rem;
    text-align: center;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    margin-bottom: 20px;
}

.chart-wrapper canvas {
    max-height: 300px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    color: var(--dark-gray);
}

.legend-value {
    color: var(--secondary-blue);
    font-weight: 600;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--dark-gray);
}

.loading i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade */
@media (max-width: 768px) {
    /* Menu Mobile e Header */
    .header-content {
        padding: 15px;
        flex-wrap: nowrap; /* Impede quebra para manter na mesma linha */
    }

    .menu-toggle {
        display: block;
        margin-left: auto; /* Empurra botão para direita */
        font-size: 1.8rem;
        order: 2; /* Garante que fique à direita */
    }

    .user-actions {
        display: none; /* Oculta ações do usuário no mobile para limpar header */
    }

    .header h1 {
        font-size: 1.4rem;
        order: 1; /* Garante que fique à esquerda */
    }

    /* Navegação Mobile (Menu Collapsível) */
    .nav-tabs {
        display: none; /* Escondido por padrão */
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--white);
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        z-index: 1000;
        padding: 0;
        border-top: 1px solid #eee;
    }

    .nav-tabs.active {
        display: flex; /* Exibe quando ativo */
    }

    .nav-tab {
        width: 100%;
        text-align: left;
        padding: 15px 20px;
        border-bottom: 1px solid #f1f1f1;
        font-size: 1rem;
    }

    .nav-tab:last-child {
        border-bottom: none;
    }

    /* Mostrar botão Sair no menu */
    .mobile-only {
        display: block;
        color: var(--accent-red);
        font-weight: 600;
    }
    
    .header h1 {
        font-size: 1.4rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters select {
        min-width: auto;
    }
    
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .admin-sections {
        grid-template-columns: 1fr;
    }
    
    /* Gráficos responsivos */
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-wrapper {
        height: 250px;
    }
    
    .chart-legend {
        gap: 10px;
    }
    
    .legend-item {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 2rem;
    }
    
    .logo i {
        font-size: 3rem;
    }
    
    #loginForm {
        padding: 30px 20px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .trip-card, .expense-card, .report-card, .admin-card {
        padding: 20px;
    }
}

/* Utilitários */
.hidden {
    display: none !important;
}

.admin-only {
    display: none;
}

.admin-only.show {
    display: block;
}

.admin-only.show.nav-tab {
    display: inline-block;
}

.admin-only.show.btn {
    display: inline-flex;
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success-green);
}

.text-danger {
    color: var(--accent-red);
}

.text-warning {
    color: var(--warning-yellow);
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}