/* Reset e configurações básicas */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Container principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header .empresa-info {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* Navegação */
.nav {
    background: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.nav-menu a:hover {
    background-color: #667eea;
    color: white;
}

.nav-menu a.active {
    background-color: #667eea;
    color: white;
}

/* Menu hambúrguer para mobile */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.card h2 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.card h3 {
    color: #555;
    margin-bottom: 0.8rem;
    font-size: 1.2rem;
}

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

/* Tabelas */
.table-container {
    overflow-x: auto;
    margin: 1rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #667eea;
    color: white;
    font-weight: 600;
}

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

/* Formulários */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

select.form-control {
    cursor: pointer;
}

/* Botões */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5a6fd8;
    transform: translateY(-1px);
}

.btn-success {
    background-color: #28a745;
    color: white;
}

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

.btn-danger {
    background-color: #dc3545;
    color: white;
}

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

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

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

/* Alertas */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

/* Resumo financeiro */
.resumo-financeiro {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.resumo-item {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.resumo-item h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.resumo-item .valor {
    font-size: 1.8rem;
    font-weight: bold;
    color: #333;
}

.resumo-item.positivo .valor {
    color: #28a745;
}

.resumo-item.negativo .valor {
    color: #dc3545;
}

/* Lista de movimentos */
.movimento-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.movimento-item:last-child {
    border-bottom: none;
}

.movimento-info h4 {
    margin-bottom: 0.25rem;
    color: #333;
}

.movimento-info p {
    color: #666;
    font-size: 0.9rem;
}

.movimento-valor {
    font-weight: bold;
    font-size: 1.1rem;
}

.movimento-valor.entrada {
    color: #28a745;
}

.movimento-valor.saida {
    color: #dc3545;
}

/* Responsividade */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        padding: 1rem;
    }

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

    .nav-toggle {
        display: block;
    }

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

    .resumo-financeiro {
        grid-template-columns: 1fr;
    }

    .movimento-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .container {
        padding: 0 15px;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Utilitários */
.text-center {
    text-align: center;
}

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

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

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

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }


/* ===== RESPONSIVIDADE MOBILE ===== */

/* Configurações gerais para mobile */
@media screen and (max-width: 768px) {
    body {
        font-size: 16px; /* Evita zoom automático no iOS */
    }
    
    .container {
        padding: 0 15px;
    }
    
    /* Header responsivo */
    .header {
        padding: 0.75rem 0;
    }
    
    .header h1 {
        font-size: 1.4rem;
        text-align: center;
    }
    
    .header .empresa-info {
        font-size: 0.8rem;
        text-align: center;
    }
    
    /* Navegação mobile */
    .nav {
        padding: 0.5rem 0;
        margin-bottom: 1rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-item {
        width: 100%;
        text-align: center;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Cards responsivos */
    .card {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Formulários mobile */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control {
        font-size: 16px; /* Evita zoom no iOS */
        padding: 0.75rem;
        border-radius: 8px;
    }
    
    .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .d-flex {
        flex-direction: column;
    }
    
    .d-flex .btn {
        margin-bottom: 0.5rem;
    }
    
    /* Tabelas responsivas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 0.85rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Dashboard mobile */
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        text-align: center;
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Relatórios mobile */
    .relatorio-section {
        margin-bottom: 1.5rem;
    }
    
    .chart-container {
        height: 250px;
        margin-bottom: 1rem;
    }
    
    /* Badges e elementos pequenos */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Alertas mobile */
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    /* Movimento valor */
    .movimento-valor {
        font-size: 0.9rem;
    }
    
    /* Seções de informação */
    .info-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* Tablets (768px - 1024px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 0 30px;
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-item {
        flex: 0 0 auto;
        min-width: 120px;
    }
    
    table {
        font-size: 0.9rem;
    }
}

/* Smartphones pequenos (até 480px) */
@media screen and (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header .empresa-info {
        font-size: 0.75rem;
    }
    
    .card {
        padding: 0.75rem;
    }
    
    .form-control {
        padding: 0.6rem;
    }
    
    .btn {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 0.4rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .movimento-valor {
        font-size: 0.85rem;
    }
}

/* Orientação landscape em mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 0.5rem 0;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .nav {
        padding: 0.4rem 0;
    }
    
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-item {
        flex: 0 0 auto;
        width: auto;
        min-width: 100px;
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}

/* Melhorias para touch */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }
    
    .nav-item:hover {
        transform: none;
    }
    
    .card:hover {
        transform: none;
    }
    
    /* Aumentar área de toque */
    .btn {
        min-height: 44px;
    }
    
    .nav-item {
        min-height: 44px;
    }
    
    input, select, textarea {
        min-height: 44px;
    }
}

/* PWA - Esconder elementos do browser em fullscreen */
@media all and (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .card {
        background-color: #2d2d2d;
        border-color: #404040;
    }
    
    .nav {
        background-color: #2d2d2d;
    }
    
    .form-control {
        background-color: #404040;
        border-color: #555;
        color: #e0e0e0;
    }
    
    table {
        background-color: #2d2d2d;
    }
    
    table th {
        background-color: #404040;
    }
    
    table tr:nth-child(even) {
        background-color: #353535;
    }
}

/* Animações suaves para mobile */
@media screen and (max-width: 768px) {
    * {
        transition: all 0.2s ease;
    }
    
    .card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .btn {
        transition: background-color 0.2s ease, transform 0.1s ease;
    }
    
    .form-control:focus {
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
}
