/* statements-section.css: Estilos para la sección de statements, con consistencia visual con horizontal-nav */

/* ===== STATEMENTS NAV - Consistent with horizontal menu ===== */
.statements-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--puntilla-gray-200);
    align-items: center;
    justify-content: flex-start;
}

.statements-tab {
    background: none;
    border: none;
    padding: var(--spacing-2) var(--spacing-3);
    cursor: pointer;
    font-size: var(--font-size-xs);
    font-weight: 400;
    color: var(--puntilla-gray-600);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    position: relative;
    min-width: 120px;
    justify-content: flex-start;
    height: 100%;
}

/* Hover - visible in both light and dark themes */
.statements-tab:hover:not(.active) {
    background: var(--puntilla-gray-200);
    color: var(--puntilla-gray-800) !important;
}

/* Active - consistent with nav-item-horizontal.active .nav-link-horizontal */
.statements-tab.active {
    background: var(--puntilla-primary) !important;
    color: var(--puntilla-white) !important;
    box-shadow: var(--shadow-md);
    border-bottom-color: var(--puntilla-primary);
}

/* Active hover - consistent with nav-item-horizontal.active .nav-link-horizontal:hover */
.statements-tab.active:hover {
    background: var(--puntilla-primary) !important;
    color: var(--puntilla-white) !important;
    transform: translateY(-1px);
}

/* Dark theme hover states */
.main-content.theme-dark .statements-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--puntilla-text-main, #fff) !important;
}

.statements-tab i {
    font-size: 18px;
    color: currentColor;
    margin-right: var(--spacing-2);
}

/* ===== STATEMENTS FILTERS ===== */
.statements-filters {
    display: flex;
    gap: 0.75rem; /* tighter spacing between groups */
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--puntilla-gray-50);
    border-radius: 0.75rem;
    border: 1px solid var(--puntilla-gray-200);
    align-items: flex-end; /* bottom-align controls across groups */
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem; /* reduce vertical separation between label and control */
    /* Let groups be flexible and never overflow the parent */
    flex: 1 1 220px; /* fallback base width per group */
    flex-basis: clamp(40px, 22vw, 220px); /* responsive base to fit more groups per row on mid widths */
    min-width: 0; /* critical so content can shrink within flex item */
    max-width: 100%;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--puntilla-gray-700);
    line-height: 1.2; /* slightly tighter */
    margin: 0; /* avoid extra gaps differing across browsers */
    display: block;
    margin-bottom: 0.375rem; /* consistent compact spacing above control */
}

.filter-select {
    padding: 0.625rem 1rem; /* reduce top/bottom padding slightly */
    border: 1px solid var(--puntilla-gray-300);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: var(--puntilla-white);
    transition: all 0.2s ease;
    line-height: 1.4; /* increase for better text display */
    height: 44px; /* increase height to prevent text clipping */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0; /* neutralize UA margins */
    white-space: normal; /* allow wrapping */
}

/* Invisible label retains layout space like visible labels */
.filter-group label.invisible {
    display: block;
    visibility: hidden; /* keeps space */
    opacity: 0; /* ensure it's not visible even during transitions */
    height: 1em; /* compact reserved space */
    margin-bottom: 0.375rem;
}

.filter-select:focus {
    outline: none;
    border-color: var(--puntilla-primary);
    box-shadow: 0 0 0 3px var(--puntilla-primary-light);
}

/* Normalize button sizing to match selects */
.statements-filters .btn,
.statements-filters .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem; /* same as .filter-select */
    font-size: 0.875rem; /* match select font size */
    line-height: 1; /* normalize for vertical centering */
    border-radius: 0.5rem; /* match select radius */
    height: 40px; /* match select height */
    margin: 0; /* neutralize UA margins */
    text-align: center; /* ensure centered text */
}

/* Keep the refresh button group at intrinsic width on wider screens */
.statements-filters .filter-group:last-child {
    flex: 0 0 auto; /* don't grow */
}
.statements-filters .filter-group:last-child .btn,
.statements-filters .filter-group:last-child .btn-primary {
    width: auto;
    max-width: none;
    align-self: flex-start; /* align left within its group */
    white-space: nowrap; /* keep theme-like compact button width */
}

.statements-filters .btn .fas,
.statements-filters .btn-primary .fas {
    margin-right: 0.5rem;
    line-height: 1; /* align icon vertically */
    align-self: center;
}

/* ===== STATEMENTS CONTENT ===== */
.statements-tab-content {
    display: none;
}

.statements-tab-content.active {
    display: block;
}

.statements-header,
.transactions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--puntilla-gray-200);
}

.statements-header h3,
.transactions-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--puntilla-gray-800);
    margin: 0;
}

.statements-stats,
.transactions-stats {
    display: flex;
    gap: 2rem;
    justify-content: flex-end; /* align stats to the right */
    align-items: center; /* center content vertically within the row */
}

/* Dark theme compatibility for statements header */
.main-content.theme-dark .statements-header,
.main-content.theme-dark .transactions-header {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}
.main-content.theme-dark .statements-header h3,
.main-content.theme-dark .transactions-header h3 {
    color: var(--puntilla-text-main, #fff);
}
.main-content.theme-dark .statements-stats .stat-item,
.main-content.theme-dark .transactions-stats .stat-item {
    color: var(--puntilla-color-red);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center; /* center horizontally inside each card */
    justify-content: center; /* center vertically inside each card */
    text-align: center;
    padding-left: 0.75rem;
    border-left: 4px solid var(--puntilla-color-red); /* Puntilla red highlight */
}

.stat-item strong {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--puntilla-primary);
    font-variant-numeric: tabular-nums; /* consistent number width */
}

.stat-item {
    font-size: 0.875rem;
    color: var(--puntilla-gray-600);
}

/* Explicit value colors for light/dark themes */
.main-content.theme-light #total-statements,
.main-content.theme-light #total-amount {
    color: var(--puntilla-gray-900);
}

/* ===== STATEMENTS TABLES ===== */
.statements-table-container,
.transactions-table-container {
    background: var(--puntilla-white);
    border-radius: 0.75rem;
    border: 1px solid var(--puntilla-gray-200);
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 1.5rem;
}

.statements-table,
.transactions-table {
    width: 100%;
    min-width: 800px; /* Ancho mínimo para garantizar que se active el scroll si es necesario */
    border-collapse: collapse;
}

.statements-table th,
.transactions-table th {
    background: var(--puntilla-gray-50);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--puntilla-gray-700);
    border-bottom: 1px solid var(--puntilla-gray-200);
    font-size: 0.875rem;
    white-space: nowrap;
    min-width: 120px;
}

.statements-table td,
.transactions-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--puntilla-gray-100);
    font-size: 0.875rem;
    color: var(--puntilla-gray-700);
    white-space: nowrap;
    min-width: 120px;
}

.statements-table tr:hover,
.transactions-table tr:hover {
    background: var(--puntilla-gray-50);
}

.statements-table tr:last-child td,
.transactions-table tr:last-child td {
    border-bottom: none;
}

/* Estilos para el scroll horizontal de las tablas */
.statements-table-container::-webkit-scrollbar,
.transactions-table-container::-webkit-scrollbar {
    height: 8px;
}

.statements-table-container::-webkit-scrollbar-track,
.transactions-table-container::-webkit-scrollbar-track {
    background: var(--puntilla-gray-100);
    border-radius: 4px;
}

.statements-table-container::-webkit-scrollbar-thumb,
.transactions-table-container::-webkit-scrollbar-thumb {
    background: var(--puntilla-gray-400);
    border-radius: 4px;
}

.statements-table-container::-webkit-scrollbar-thumb:hover,
.transactions-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--puntilla-gray-500);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .statements-nav {
        flex-direction: column;
        gap: 0;
    }
    
    .statements-tab {
        border-bottom: 1px solid var(--puntilla-gray-200);
        border-radius: 0;
        min-width: auto;
        width: 100%;
    }
    
    .statements-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: auto;
        width: 100%;
        max-width: 100%;
    }
    
    /* Stack header content on small screens */
    .statements-header,
    .transactions-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .statements-stats,
    .transactions-stats {
        justify-content: flex-end; /* keep right-aligned on small screens too */
    }
    
    .statements-stats,
    .transactions-stats {
        flex-direction: column;
        gap: 1rem;
    }
}