﻿body {
    padding-top: 50px;
    padding-bottom: 20px;
}

/* Set padding to keep content from hitting the edges */
.body-content {
    padding-left: 15px;
    padding-right: 15px;
}

/* Override the default bootstrap behavior where horizontal description lists 
   will truncate terms that are too long to fit in the left column 
*/
.dl-horizontal dt {
    white-space: normal;
}

/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
    max-width: 280px;
}

/* Dashboard KPI cards */
.dashboard-kpi {
    border-radius: 4px;
    margin-bottom: 15px;
    border: none;
}

.dashboard-kpi .panel-body {
    padding: 15px 10px;
}

.dashboard-kpi h4 {
    margin-top: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    opacity: 0.9;
}

.dashboard-kpi .kpi-value {
    margin: 5px 0 0;
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.kpi-ingresos {
    background-color: #27ae60;
}

.kpi-egresos {
    background-color: #e74c3c;
}

.kpi-balance-pos {
    background-color: #2980b9;
}

.kpi-balance-neg {
    background-color: #e67e22;
}

.kpi-cantidad {
    background-color: #8e44ad;
}

/* ============================================================
   Totales por Año - Tabla sofisticada (Opción B: scroll interno)
   ============================================================ */

.totales-toolbar {
    margin-bottom: 12px;
}

.totales-toolbar .anio-link {
    display: inline-block;
    padding: 4px 10px;
    margin-right: 4px;
    border-radius: 4px;
    color: #337ab7;
    text-decoration: none;
    font-size: 13px;
}

.totales-toolbar .anio-link:hover {
    background-color: #eef5fb;
    text-decoration: none;
}

.totales-toolbar .anio-link.activo {
    background-color: #337ab7;
    color: #fff;
    font-weight: bold;
}

/* Contenedor con scroll interno (vertical + horizontal) */
.totales-scroll {
    max-height: 70vh;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    position: relative;
}

/* Tabla base */
.tabla-totales {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.tabla-totales th,
.tabla-totales td {
    padding: 6px 10px;
    white-space: nowrap;
    border-bottom: 1px solid #eee;
}

/* Montos alineados a la derecha con fuente tabular */
.tabla-totales td.monto,
.tabla-totales th.monto {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: Consolas, "Courier New", monospace;
}

/* Zebra striping en filas de datos */
.tabla-totales tbody tr.fila-dato:nth-child(even) {
    background-color: #fafafa;
}

/* Hover sobre filas de datos */
.tabla-totales tbody tr.fila-dato:hover {
    background-color: #eef5fb;
}

/* ---- Header sticky (arriba) ---- */
.tabla-totales thead th {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #2c3e50;
    color: #fff;
    font-weight: 600;
    text-align: right;
    border-bottom: 2px solid #1a252f;
}

.tabla-totales thead th.col-categoria {
    text-align: left;
}

/* ---- Primera columna sticky (izquierda) ---- */
.tabla-totales .col-categoria {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #fff;
    text-align: left;
    font-weight: 500;
    min-width: 170px;
    box-shadow: 1px 0 0 #ddd;
}

/* Esquina: header + primera columna (debe quedar sobre todo) */
.tabla-totales thead th.col-categoria {
    z-index: 4;
    background-color: #2c3e50;
}

/* Mantener fondo de la primera columna en filas zebra/hover */
.tabla-totales tbody tr.fila-dato:nth-child(even) .col-categoria {
    background-color: #fafafa;
}

.tabla-totales tbody tr.fila-dato:hover .col-categoria {
    background-color: #eef5fb;
}

/* ---- Filas de sección (Egresos / Ingresos / Capital) ---- */
.tabla-totales tr.seccion td {
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
    color: #fff;
}

.tabla-totales tr.seccion .col-categoria {
    color: #fff;
}

.tabla-totales tr.seccion-egreso td,
.tabla-totales tr.seccion-egreso .col-categoria {
    background-color: #c0392b;
}

.tabla-totales tr.seccion-ingreso td,
.tabla-totales tr.seccion-ingreso .col-categoria {
    background-color: #27ae60;
}

.tabla-totales tr.seccion-capital td,
.tabla-totales tr.seccion-capital .col-categoria {
    background-color: #2980b9;
}

/* ---- Fila de subtotales por mes ---- */
.tabla-totales tr.subtotal td,
.tabla-totales tr.subtotal .col-categoria {
    background-color: #ecf0f1;
    font-weight: bold;
    border-top: 2px solid #bdc3c7;
}

/* ---- Fila separadora ---- */
.tabla-totales tr.separador td {
    height: 10px;
    background-color: #fff;
    border-bottom: none;
}

/* ---- Columna del mes actual resaltada ---- */
.tabla-totales .mes-actual {
    background-color: #d4edfa !important;
}

.tabla-totales thead th.mes-actual {
    background-color: #34688f !important;
}

/* ---- Colores de valores ---- */
.tabla-totales .valor-egreso {
    color: #c0392b;
}

.tabla-totales .valor-ingreso {
    color: #27ae60;
}

.tabla-totales .valor-cero {
    color: #cfcfcf;
}

.tabla-totales .col-resumen {
    font-weight: bold;
    background-color: #f7f9fa;
}

/* ============================================================
   Lista de Movimientos
   ============================================================ */

/* Fila de filtros bajo el header */
.tabla-totales thead tr.fila-filtros th {
    position: -webkit-sticky;
    position: sticky;
    top: 34px;
    z-index: 3;
    background-color: #3b5064;
    padding: 4px 6px;
}

.tabla-totales thead tr.fila-filtros th.col-categoria {
    z-index: 4;
    left: 0;
}

.tabla-totales thead tr.fila-filtros select,
.tabla-totales thead tr.fila-filtros input {
    width: 100%;
    max-width: 100%;
    font-size: 12px;
    padding: 2px 4px;
    color: #333;
    border-radius: 3px;
    border: 1px solid #ccc;
}

/* Colores de fila según moneda / estado de pago */
.tabla-totales tr.mov-usd-pendiente td,
.tabla-totales tr.mov-usd-pendiente td {
    background-color: #ffe8cc;
}

.tabla-totales tr.mov-usd-pago td {
    background-color: #d9f2d9;
}

.tabla-totales tr.mov-pesos-pendiente td {
    background-color: #ffd9cc;
}

/* hover unificado para movimientos */
.tabla-totales tbody tr.fila-mov:hover td {
    background-color: #eef5fb;
}

.badge-tipo {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
}

.badge-ingreso {
    background-color: #27ae60;
}

.badge-egreso {
    background-color: #c0392b;
}

.badge-pago {
    color: #27ae60;
    font-weight: bold;
}

.badge-pendiente {
    color: #e67e22;
    font-weight: bold;
}

/* Toolbar de meses */
.meses-toolbar {
    margin: 10px 0 14px;
}

.meses-toolbar .mes-link {
    display: inline-block;
    padding: 4px 10px;
    margin: 2px;
    border-radius: 4px;
    color: #337ab7;
    text-decoration: none;
    font-size: 13px;
}

.meses-toolbar .mes-link:hover {
    background-color: #eef5fb;
    text-decoration: none;
}

.meses-toolbar .mes-link.activo {
    background-color: #337ab7;
    color: #fff;
    font-weight: bold;
}

/* ---- Header de página elegante ---- */
.page-header-mov {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    border-bottom: 3px solid #337ab7;
    padding-bottom: 10px;
    margin: 20px 0 15px;
}

.page-header-mov h2 {
    margin: 0;
    font-weight: 300;
    color: #2c3e50;
}

.page-header-mov .mes-badge {
    display: inline-block;
    background-color: #337ab7;
    color: #fff;
    padding: 4px 14px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    margin-left: 8px;
}

.page-header-mov .header-acciones {
    display: flex;
    gap: 8px;
}

/* ---- Botones de acción (toolbar + tabla) ---- */
.btn-accion {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    line-height: 1.5;
    margin: 2px;
}

.btn-accion:hover {
    text-decoration: none;
    opacity: 0.85;
    color: #fff;
}

.btn-nuevo {
    background-color: #27ae60;
    color: #fff;
}

.btn-tarjeta {
    background-color: #2980b9;
    color: #fff;
}

.btn-editar {
    background-color: #f0ad4e;
    color: #fff;
}

.btn-borrar {
    background-color: #c0392b;
    color: #fff;
}

.btn-editar:hover,
.btn-borrar:hover,
.btn-nuevo:hover,
.btn-tarjeta:hover {
    color: #fff;
}

/* Celda de acciones sin wrap */
.tabla-totales td.col-acciones {
    white-space: nowrap;
}

/* Filtro de la columna Pago: ancho ajustado */
.tabla-totales thead tr.fila-filtros th select.filtro-pago {
    min-width: 90px;
}

/* Total pie de tabla */
.mov-total-pie {
    margin-top: 12px;
    font-size: 15px;
}

.mov-total-pie .valor {
    color: #c0392b;
    font-weight: bold;
    font-size: 18px;
}

/* ---- Tabla de movimientos: ajustar al ancho sin scroll horizontal ---- */
#tablaMovimientos {
    table-layout: fixed;
    width: 100%;
}

#tablaMovimientos th,
#tablaMovimientos td {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#tablaMovimientos .col-categoria {
    min-width: 0;
    width: 8%;
}

/* Anchos de columnas de movimientos */
#tablaMovimientos col.c-tipo { width: 8%; }
#tablaMovimientos col.c-moneda { width: 7%; }
#tablaMovimientos col.c-fecha { width: 8%; }
#tablaMovimientos col.c-pago { width: 6%; }
#tablaMovimientos col.c-monto { width: 9%; }
#tablaMovimientos col.c-tarjeta { width: 12%; }
#tablaMovimientos col.c-categoria { width: 11%; }
#tablaMovimientos col.c-subcategoria { width: 11%; }
#tablaMovimientos col.c-descripcion { width: 14%; }
#tablaMovimientos col.c-acciones { width: 14%; }

#tablaMovimientos .fila-filtros select,
#tablaMovimientos .fila-filtros input {
    box-sizing: border-box;
}
