/* ============================================
   BALANCES PAGE — Specific Styles
   Extends the shared design system in styles.css
   ============================================ */

/* ---- Filter section ---- */
.filter-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.filter-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group label .count {
    font-weight: 400;
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: all var(--duration-fast);
    outline: none;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-group input::placeholder {
    color: var(--text-tertiary);
}

/* ---- Dropdown multi-select ---- */
.dropdown-wrapper {
    position: relative;
}

.dropdown-trigger {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--duration-fast);
    outline: none;
}

.dropdown-trigger:hover,
.dropdown-trigger:focus {
    border-color: var(--accent);
}

.dropdown-trigger svg {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    transition: transform var(--duration-fast);
}

.dropdown-panel {
    position: absolute;
    z-index: 200;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-surface-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    animation: dropdown-open 0.2s var(--ease);
}

@keyframes dropdown-open {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-panel .dropdown-header {
    position: sticky;
    top: 0;
    background: var(--bg-surface-raised);
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
    z-index: 1;
}

.dropdown-panel .dropdown-header button {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--accent-light);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast);
}

.dropdown-panel .dropdown-header button:hover {
    background: var(--accent-glow);
}

.dropdown-panel .dropdown-body {
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
}

/* Checkbox items */
.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast);
    gap: 0.4rem;
}

.checkbox-item:hover {
    background: var(--bg-hover);
}

.checkbox-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-item span,
.checkbox-item label {
    flex: 1;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-primary);
}

/* ---- Filter tags ---- */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    animation: tag-pop 0.2s var(--ease);
}

@keyframes tag-pop {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.filter-tag button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1;
    transition: color var(--duration-fast);
}

.filter-tag button:hover {
    color: white;
}

.filter-tags .text-xs {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    align-self: center;
}

.filter-tags .text-xs.text-red-500 {
    color: var(--rose);
}

/* ---- Balances Table ---- */
.balances-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: opacity var(--duration);
}

.balances-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.balances-table-wrap thead {
    background: var(--bg-surface-raised);
    border-bottom: 1px solid var(--border);
}

.balances-table-wrap th {
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    cursor: default;
    transition: all var(--duration-fast);
}

.balances-table-wrap th.sortable {
    cursor: pointer;
}

.balances-table-wrap th.sortable:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.balances-table-wrap th.sortable.sorted {
    color: var(--accent-light);
}

.sort-icon {
    margin-left: 0.3rem;
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.balances-table-wrap tbody {
    text-align: center;
}

.balances-table-wrap tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--duration-fast);
}

.balances-table-wrap tbody tr:last-child {
    border-bottom: none;
}

.balances-table-wrap tbody tr:hover {
    background: var(--bg-hover);
}

.balances-table-wrap td {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Cell types */
.badge-grupo {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--accent-glow);
    color: var(--accent-light);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}

.username {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 0.82rem;
}

.balance-cell {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    color: var(--emerald);
    font-size: 0.9rem;
}

.fecha-cell {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.status {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
}

.status.ok {
    background: var(--emerald-dim);
    color: var(--emerald);
}

.status.caution {
    background: var(--amber-dim);
    color: var(--amber);
}

.status.warning {
    background: var(--rose-dim);
    color: var(--rose);
}

/* ---- Loading overlay ---- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.loading-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-card p {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

/* ---- Pagination ---- */
.pagination-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.page-btn {
    padding: 0.45rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.page-btn:hover:not(:disabled) {
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.page-btn:disabled {
    background: var(--bg-surface-raised);
    color: var(--text-tertiary);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.page-info {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
        min-width: 0;
    }

    .balances-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .balances-table-wrap table {
        min-width: 700px;
    }

    .pagination-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
}