/* ============================================================
   AutoDeal360 — Módulo Gestión de Inventario
   Dashboard con acciones rápidas + últimas transacciones
   Identidad alineada a vehículos/clientes (paleta #004B94)
   ============================================================ */

/* Body sticky igual que el resto de módulos */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 15px;
    box-sizing: border-box;
    background: #f5f7fa;
    font-family: 'Roboto', sans-serif;
}

.module-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
}

/* ──────────────────────────────────────────────────────────────────
   ACCIONES (tarjetas grandes)
   ────────────────────────────────────────────────────────────────── */
.acciones-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.accion-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 18px 16px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    font-family: inherit;
}

.accion-card:hover {
    border-color: #004B94;
    box-shadow: 0 6px 16px rgba(0, 75, 148, 0.15);
    transform: translateY(-2px);
}

.accion-card:active {
    transform: translateY(0);
}

.accion-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    background: linear-gradient(135deg, #004B94, #20376A);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.accion-icon.entrada   { background: linear-gradient(135deg, #198754, #126c41); }
.accion-icon.salida    { background: linear-gradient(135deg, #dc3545, #b02a37); }
.accion-icon.proveedor { background: linear-gradient(135deg, #f59e0b, #c47a08); }

.accion-texto h3 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #004B94;
}

.accion-texto p {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
}

/* ──────────────────────────────────────────────────────────────────
   ÚLTIMAS TRANSACCIONES
   ────────────────────────────────────────────────────────────────── */
.transacciones-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border-top: 1px solid #e9ecef;
    padding-top: 16px;
}

.transacciones-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.transacciones-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #004B94;
    display: flex;
    align-items: center;
    gap: 8px;
}

.transacciones-header h2 i { color: #004B94; }

.btn-refresh {
    background: #fff;
    border: 1px solid #ddd;
    color: #495057;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
}

.btn-refresh:hover {
    background: #f8f9fa;
    border-color: #004B94;
    color: #004B94;
}

.btn-refresh i { transition: transform .3s; }
.btn-refresh:hover i { transform: rotate(180deg); }

/* Filtro de rango de fecha */
.filtros-fecha {
    margin-bottom: 12px;
    flex-shrink: 0;
}

.filtros-fecha-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.fecha-chip {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.fecha-chip:hover { border-color: #004B94; color: #004B94; }
.fecha-chip.active {
    background: #004B94;
    border-color: #004B94;
    color: #fff;
}
.fecha-chip-custom.active { background: #20376A; border-color: #20376A; }

.rango-custom-panel {
    display: none;
    align-items: flex-end;
    gap: 12px;
    margin-top: 10px;
    padding: 12px 14px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    flex-wrap: wrap;
}
.rango-custom-panel.show { display: flex; }

.rango-custom-campo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rango-custom-campo label {
    font-size: 11px;
    font-weight: 600;
    color: #004B94;
}
.rango-custom-campo input {
    height: 34px;
    width: 130px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: #2d3748;
}
.rango-custom-campo input:focus {
    outline: none;
    border-color: #004B94;
    box-shadow: 0 0 0 3px rgba(0,75,148,.12);
}

.btn-aplicar-rango {
    height: 34px;
    padding: 0 18px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    background: #004B94;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
}
.btn-aplicar-rango:hover { background: #20376A; transform: translateY(-1px); }
.btn-aplicar-rango:active { transform: translateY(0); }

.rango-custom-hint {
    font-size: 11px;
    color: #dc3545;
    font-weight: 600;
}

/* Filtros (chips) */
.filtros-tipo {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.filtro-chip {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    color: #6c757d;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.filtro-chip:hover {
    background: #fff;
    border-color: #004B94;
    color: #004B94;
}

.filtro-chip.active {
    background: #004B94;
    border-color: #004B94;
    color: #fff;
}

.filtro-chip .chip-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.filtro-chip.active .chip-count {
    background: rgba(255, 255, 255, 0.25);
}

/* Tabla de transacciones */
.transacciones-table-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.transacciones-table {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    border-collapse: collapse;
}

.transacciones-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
    flex-shrink: 0;
}

.transacciones-table thead th {
    background: #004B94;
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .4px;
}

.transacciones-table thead th.col-tipo    { text-align: left; }
.transacciones-table thead th.col-fecha   { text-align: left; }
.transacciones-table thead th.col-detalle { text-align: left; }
.transacciones-table thead th.col-info    { text-align: left; }
.transacciones-table thead th.col-usuario { text-align: left; }

/* Anchos de columna — declarados UNA vez y aplicados a th Y td por posición,
   para que el thead (tabla propia) y cada fila del tbody (tabla propia)
   calculen exactamente las mismas columnas y queden alineadas. */
.transacciones-table th:nth-child(1), .transacciones-table td:nth-child(1) { width: 150px; }
.transacciones-table th:nth-child(2), .transacciones-table td:nth-child(2) { width: 170px; }
.transacciones-table th:nth-child(3), .transacciones-table td:nth-child(3) { /* Detalle: toma el espacio restante */ }
.transacciones-table th:nth-child(4), .transacciones-table td:nth-child(4) { width: 27%; }
.transacciones-table th:nth-child(5), .transacciones-table td:nth-child(5) { width: 170px; }

.transacciones-table tbody {
    display: block;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: #fafbfc;
}

.transacciones-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
    transition: background .12s;
}
.transacciones-table tbody tr:nth-child(even) { background: #f5f7fa; }
.transacciones-table tbody tr:hover           { background: #eef5fc; }
.transacciones-table tbody tr.fila-cargando:hover { background: transparent; }

.transacciones-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
    font-size: 14px;
    color: #2d3748;
}
.transacciones-table tbody tr:last-child td { border-bottom: none; }

.transaccion-tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: #fff;
    white-space: nowrap;
}
.transaccion-tipo-badge.crear     { background: #004B94; }
.transaccion-tipo-badge.entrada   { background: #198754; }
.transaccion-tipo-badge.salida    { background: #dc3545; }
.transaccion-tipo-badge.proveedor { background: #f59e0b; }

.transaccion-fecha-cell {
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
}
.transaccion-fecha-cell i { color: #adb5bd; margin-right: 5px; }

.transaccion-titulo-cell {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaccion-info-cell {
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-cantidad {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}
.info-cantidad i { font-size: 13px; }
.info-cantidad.aumento     { color: #198754; }
.info-cantidad.disminucion { color: #dc3545; }

.info-extra {
    color: #6c757d;
    font-weight: 400;
}
.info-extra::before { content: '· '; }

.transaccion-usuario-cell {
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.transaccion-usuario-cell i { color: #adb5bd; margin-right: 5px; }

.fila-vacia td { padding: 40px !important; text-align: center; color: #a0aec0; }

/* Paginación */
.transacciones-paginacion {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    padding-top: 12px;
    font-size: 12px;
    color: #495057;
}
.transacciones-rows-per-page {
    display: flex;
    align-items: center;
    gap: 6px;
}
.transacciones-rows-per-page label { font-weight: 600; }
.transacciones-rows-per-page select {
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 0 8px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    color: #2d3748;
}
#transacciones-total-info { color: #6c757d; }
.transacciones-pag-botones {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.trans-page-btn {
    width: 28px; height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #495057;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.trans-page-btn:hover:not(:disabled) { background: #eef5fc; border-color: #004B94; color: #004B94; }
.trans-page-btn:disabled { opacity: .4; cursor: not-allowed; }
#trans-page-info { font-size: 12px; color: #495057; min-width: 95px; text-align: center; }

/* Estado vacío / sin datos */
.sin-transacciones {
    text-align: center;
    padding: 30px 20px;
    color: #a0aec0;
}

.sin-transacciones i {
    font-size: 32px;
    margin-bottom: 8px;
    color: #cbd5e0;
}

.sin-transacciones p { margin: 0; font-size: 13px; }

/* ──────────────────────────────────────────────────────────────────
   LOADING
   ────────────────────────────────────────────────────────────────── */
.loading {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    display: none;
    justify-content: center; align-items: center;
    z-index: 1000;
}

.loading.show { display: flex; }

.loading-content { text-align: center; }

.spinner {
    border: 4px solid rgba(0,0,0,0.1);
    border-top: 4px solid #004B94;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: gst-spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes gst-spin {
    to { transform: rotate(360deg); }
}

.loading-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: #6c757d;
    font-size: 13px;
}

.spinner-mini {
    width: 18px;
    height: 18px;
    border: 2px solid #e9ecef;
    border-top-color: #004B94;
    border-radius: 50%;
    animation: gst-spin 0.7s linear infinite;
}

/* ──────────────────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 992px) {
    .acciones-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .acciones-grid { grid-template-columns: 1fr; }
    .transacciones-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .filtros-tipo { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .filtro-chip { white-space: nowrap; flex-shrink: 0; }
    .rango-custom-panel { flex-direction: column; align-items: stretch; }
    .rango-custom-campo input { width: 100%; }
    .transacciones-table-wrapper { overflow-x: auto; }
    .transacciones-paginacion { flex-wrap: wrap; row-gap: 8px; }
    .transacciones-pag-botones { margin-left: 0; }
}