/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body { 
    font-family: Arial, sans-serif; 
    background: #f9fafb; 
    color: #333;
    overflow-x: hidden;
}

/* Layout Principal */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 20px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: bold;
}

/* Filtros na Sidebar */
.sidebar-filters {
    margin-bottom: 30px;
}

.filter-group {
    margin-bottom: 15px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: bold;
}

.filter-group select {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.9);
    color: #333;
    font-size: 14px;
}

.btn-update {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.3s ease;
}

.btn-update:hover {
    background: rgba(255,255,255,0.3);
}

/* Navegação na Sidebar */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    padding: 12px 16px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 14px;
    display: block;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: white;
    font-weight: bold;
}

/* Botão Mobile Menu */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1100;
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Conteúdo Principal */
.main-content {
    margin-left: 280px;
    min-height: 100vh;
    padding: 20px;
    transition: margin-left 0.3s ease;
}

.wrap { 
    max-width: 1200px; 
    margin: 0 auto; 
}

h1 { 
    text-align: center; 
    margin: 0 0 20px; 
    color: #333;
    font-size: 28px;
}

/* Cards */
.cards { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 15px; 
    margin: 20px 0; 
}

.card { 
    background: #fff; 
    border-radius: 12px; 
    padding: 20px; 
    text-align: center; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h3 { 
    margin: 0 0 10px 0; 
    font-size: 16px; 
    color: #666; 
}

.card .v { 
    font-size: 24px; 
    font-weight: bold; 
}

.receita { 
    color: #16a34a; 
}

.despesa { 
    color: #ef4444; 
}

/* Mensagens */
.msg { 
    text-align: center; 
    margin: 15px 0; 
    color: #16a34a; 
    font-weight: bold; 
    background: #f0f9f0;
    padding: 10px;
    border-radius: 8px;
}

/* Tabelas */
.table-container {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 20px;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 800px;
}

th, td { 
    padding: 12px; 
    border-bottom: 1px solid #e5e7eb; 
    font-size: 14px; 
    text-align: center; 
}

th { 
    background: #f8f9fa; 
    font-weight: bold;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Controle de Visibilidade Desktop/Mobile */
.desktop-only {
    display: table-cell;
}

.mobile-only {
    display: none;
}

.mobile-desc {
    text-align: left;
}

.mobile-desc strong {
    display: block;
    margin-bottom: 4px;
}

.mobile-desc small {
    color: #666;
    font-size: 11px;
}

/* Ações */
.acoes { 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
    justify-content: center; 
}

.btn-edit {
    background: #0ea5e9;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 12px;
    transition: background-color 0.3s;
}

.btn-edit:hover {
    background: #0284c7;
}

.btn-del { 
    background: #ef4444; 
    color: #fff; 
    border: none; 
    padding: 6px 10px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 12px;
    transition: background-color 0.3s;
}

.btn-del:hover {
    background: #dc2626;
}

.btn-parc { 
    background: #8b5cf6; 
    color: #fff; 
    border: none; 
    padding: 6px 10px; 
    border-radius: 6px; 
    cursor: pointer; 
    text-decoration: none; 
    font-size: 12px;
    transition: background-color 0.3s;
}

.btn-parc:hover {
    background: #7c3aed;
}

.btn-pago {
    background: #10b981;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.btn-pago:hover {
    background: #059669;
}

.btn-despago {
    background: #f59e0b;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.btn-despago:hover {
    background: #d97706;
}

.conta-badge {
    background: #e5e7eb;
    color: #374151;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

/* Cards de Contas */
.cards-contas {
    margin: 25px 0;
}

.titulo-contas {
    margin-bottom: 15px;
    color: #495057;
    text-align: center;
    font-size: 18px;
}

.conta-card {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-left: 4px solid #007bff;
}

.conta-card h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 14px;
    font-weight: bold;
}

.conta-detalhes {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.conta-detalhes .receitas {
    color: #16a34a;
    font-weight: bold;
}

.conta-detalhes .despesas {
    color: #ef4444;
    font-weight: bold;
}

.conta-saldo {
    font-weight: bold;
    font-size: 16px;
    border-top: 1px solid #dee2e6;
    padding-top: 8px;
}

/* ============================================ */
/* RESPONSIVIDADE */
/* ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 260px;
    }
    
    .sidebar {
        width: 260px;
    }
    
    table {
        min-width: 700px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Sidebar Mobile */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    /* Conteúdo Principal Mobile */
    .main-content {
        margin-left: 0;
        padding: 70px 15px 20px;
    }
    
    /* Controle de Visibilidade Mobile */
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: table-cell !important;
    }
    
    /* Tabelas Mobile */
    table {
        min-width: 100%;
        font-size: 12px;
    }
    
    th, td {
        padding: 8px 4px;
    }
    
    /* Cards Mobile */
    .cards {
        grid-template-columns: 1fr;
    }
    
    .card {
        padding: 15px;
    }
    
    .card .v {
        font-size: 20px;
    }
    
    /* Ações Mobile */
    .acoes {
        flex-direction: column;
        gap: 4px;
    }
    
    .btn-edit, .btn-del, .btn-parc, .btn-pago, .btn-despago {
        padding: 8px 12px;
        font-size: 11px;
        width: 100%;
    }
    
    /* Título Mobile */
    h1 {
        font-size: 22px;
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: 18px;
        margin-top: 30px;
    }
    
    /* Cards de Contas Mobile */
    .conta-detalhes {
        flex-direction: column;
        gap: 2px;
    }
    
    .titulo-contas {
        font-size: 16px;
    }
    
    .conta-card h4 {
        font-size: 13px;
    }
    
    .conta-detalhes {
        font-size: 11px;
    }
    
    .conta-saldo {
        font-size: 14px;
    }
}

/* Mobile Pequeno */
@media (max-width: 480px) {
    .main-content {
        padding: 70px 10px 20px;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .wrap {
        padding: 0;
    }
    
    .card {
        padding: 12px;
    }
    
    .card .v {
        font-size: 18px;
    }
    
    th, td {
        padding: 6px 2px;
        font-size: 11px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .mobile-desc strong {
        font-size: 12px;
    }
    
    .mobile-desc small {
        font-size: 10px;
    }
    
    .conta-badge {
        font-size: 10px;
        padding: 1px 4px;
    }
}

/* ============================================ */
/* OUTROS ESTILOS MANTIDOS */
/* ============================================ */

.voltar {
    display: inline-block;
    background: #6c757d;
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    transition: background-color 0.3s;
    margin: 30px auto;
    text-align: center;
}

.voltar:hover {
    background: #5a6268;
    text-decoration: none;
    color: white;
}

.voltar-container {
    text-align: center;
    margin-top: 30px;
}

/* Modal de confirmação */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    margin: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-top: 0;
    color: #dc3545;
    text-align: center;
}

.modal-content p {
    margin: 10px 0;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-modal-danger,
.btn-modal-warning,
.btn-modal-cancel {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-modal-danger {
    background: #dc3545;
    color: white;
}

.btn-modal-danger:hover {
    background: #c82333;
}

.btn-modal-warning {
    background: #ffc107;
    color: #212529;
}

.btn-modal-warning:hover {
    background: #e0a800;
}

.btn-modal-cancel {
    background: #6c757d;
    color: white;
}

.btn-modal-cancel:hover {
    background: #5a6268;
}

/* Scrollbar personalizada para sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

/* Overlay para mobile quando sidebar está aberta */
@media (max-width: 768px) {
    .sidebar.active::after {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        width: calc(100vw - 280px);
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: -1;
    }
}

/* Estilos para a funcionalidade de busca */
.search-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

#searchInput {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.total-busca {
    padding: 8px 15px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Responsivo para mobile */
@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .total-busca {
        width: 100%;
        min-width: auto;
    }
}

.saldo-info {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    margin-top: 0;
    color: #ef4444;
}

.modal-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-modal-warning {
    background-color: #f59e0b;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-modal-danger {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-modal-cancel {
    background-color: #6b7280;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-modal-warning:hover,
.btn-modal-danger:hover,
.btn-modal-cancel:hover {
    opacity: 0.9;
}