/* ================================================== */
/* ===         ARCHIVO style2.css COMPLETO        === */
/* ================================================== */

/* --- Botones de Acción en Cabeceras (Exportar/Importar) --- */
.search-container button:hover {
    background-color: #5a6268;
}

.search-container button#btn-export-json,
.search-container button#btn-import-json,
.search-container button#btn-export-clientes-json,
.search-container button#btn-import-clientes-json,
.search-container button#btn-export-presupuestos-json,
.search-container button#btn-import-presupuestos-json,
.table-actions button#btn-export-servicios-json,
.table-actions button#btn-import-servicios-json {
    background-color: var(--primary-color);
}

.search-container button#btn-export-json:hover,
.search-container button#btn-import-json:hover,
.search-container button#btn-export-clientes-json:hover,
.search-container button#btn-import-clientes-json:hover,
.search-container button#btn-export-presupuestos-json:hover,
.search-container button#btn-import-presupuestos-json:hover,
.table-actions button#btn-export-servicios-json:hover,
.table-actions button#btn-import-servicios-json:hover {
    background-color: var(--primary-color-dark);
}

/* --- Vistas de Detalle (Clientes, Informes, etc.) --- */
.client-detail-view.card,
.informe-header.card {
    max-width: 800px;
    margin: 0 auto 20px auto;
}

.dl-horizontal,
.financial-summary {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 15px;
    row-gap: 8px;
    align-items: baseline;
    margin-bottom: 20px;
}

.dl-horizontal dt,
.financial-summary dt {
    grid-column: 1;
    text-align: right;
    font-weight: 600;
    color: #555;
}

.dl-horizontal dd,
.financial-summary dd {
    grid-column: 2;
    text-align: left;
    word-wrap: break-word;
    margin-left: 0;
}

.dl-horizontal dd pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    background-color: var(--light-gray);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--medium-gray);
}

.financial-summary dd {
    font-weight: bold;
}

.detail-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--medium-gray);
    text-align: right;
}

/* --- Sistema de Colores para Estados (Unificado) --- */
:root {
    --status-success: #28a745;
    --status-success-dark: #1c6c30;
    --status-progress: #0d6efd;
    --status-attention: #ffc107;
    --status-danger: #dc3545;
    --status-neutral: #6c757d;
}

/* Píldora estática (para informes) */
.status-pill {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 0.85em;
    color: white;
    text-align: center;
    min-width: 100px;
}

.status-pill.status-success {
    background-color: var(--status-success);
}

.status-pill.status-success-dark {
    background-color: var(--status-success-dark);
}

.status-pill.status-progress {
    background-color: var(--status-progress);
}

.status-pill.status-danger {
    background-color: var(--status-danger);
}

.status-pill.status-neutral {
    background-color: var(--status-neutral);
}

.status-pill.status-attention {
    background-color: var(--status-attention);
    color: #333;
}

/* --- Estilos para Menú Desplegable de Estado (Select) --- */
.cell-estado {
    padding: 2px !important;
    vertical-align: middle;
    position: relative;
}

.select-estado-inline {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    padding: 8px 28px 8px 12px;
    margin: 0;
    width: 100%;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    border-radius: 15px;
    outline: none;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.2s ease-in-out;
}

.select-estado-inline:hover {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.cell-estado::after {
    content: '▼';
    font-size: 10px;
    color: white;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    text-shadow: none;
}

.select-estado-inline option {
    background-color: #ffffff;
    color: #333333;
    font-weight: normal;
}

.select-estado-inline.status-success {
    background-color: var(--status-success);
}

.select-estado-inline.status-success-dark {
    background-color: var(--status-success-dark);
}

.select-estado-inline.status-progress {
    background-color: var(--status-progress);
}

.select-estado-inline.status-danger {
    background-color: var(--status-danger);
}

.select-estado-inline.status-neutral {
    background-color: var(--status-neutral);
}

.select-estado-inline.status-attention {
    background-color: var(--status-attention);
    color: #333;
}

.cell-estado:has(.select-estado-inline.status-attention)::after {
    color: #333;
}

/* --- Grupos de Clientes (Tabla Única) --- */
.cliente-grupo-fila td {
    padding: 10px 15px !important;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--white) !important;
    border-top: 3px solid rgba(0, 0, 0, 0.3) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.4) !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

.cliente-grupo-fila.grupo-atencion td {
    background-color: var(--status-attention) !important;
    color: #333 !important;
    text-shadow: none;
}

.cliente-grupo-fila.grupo-progreso td {
    background-color: var(--status-progress) !important;
}

.cliente-grupo-fila.grupo-exito td {
    background-color: var(--status-success) !important;
}

.cliente-grupo-fila.grupo-peligro td {
    background-color: var(--status-danger) !important;
}

.cliente-grupo-fila.grupo-neutro td {
    background-color: var(--status-neutral) !important;
}

.cliente-grupo-contador {
    font-size: 0.8em;
    font-weight: normal;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 3px 8px;
    border-radius: 10px;
    float: right;
}

.cliente-grupo-fila.grupo-atencion .cliente-grupo-contador {
    background-color: rgba(0, 0, 0, 0.1);
}

/* --- Paginación --- */
.pagination-container {
    margin-top: 25px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    border-radius: 0.3rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-item {
    margin: 0 2px;
}

.page-item .page-link {
    position: relative;
    display: block;
    padding: 0.6rem 0.95rem;
    line-height: 1.25;
    color: var(--primary-color);
    background-color: #fff;
    border: 1px solid #ddd;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.page-item .page-link:hover {
    z-index: 2;
    color: var(--primary-color-dark);
    background-color: #e9ecef;
    border-color: #ccc;
}

.page-item.active .page-link {
    z-index: 3;
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color-dark);
    font-weight: bold;
}

.page-item.disabled .page-link {
    color: #868e96;
    pointer-events: none;
    background-color: #fff;
    border-color: #eee;
}

/* --- Lista de Catálogo (Nuevo Presupuesto) --- */
.lista-catalogo {
    border: 1px solid var(--medium-gray);
    border-radius: 5px;
    padding: 5px;
    margin-top: 10px;
    max-height: 350px;
    overflow-y: auto;
    background-color: #fdfdfd;
}

.servicio-catalogo-item-clickable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.servicio-catalogo-item-clickable:last-child {
    border-bottom: none;
}

.servicio-catalogo-item-clickable:hover {
    background-color: #e9f5ff;
}

.servicio-catalogo-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-right: 15px;
}

.servicio-catalogo-concepto {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1em;
}

.servicio-catalogo-categoria {
    font-size: 0.8em;
    color: var(--secondary-color);
    text-transform: uppercase;
    margin-top: 2px;
}

.servicio-catalogo-accion {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.servicio-catalogo-precio {
    font-weight: bold;
    font-size: 1.05em;
    color: var(--success-color);
    min-width: 70px;
    text-align: right;
}

.servicio-catalogo-accion .add-icon {
    font-size: 1.6em;
    color: var(--primary-color);
    transition: transform 0.2s ease;
}

.servicio-catalogo-item-clickable:hover .add-icon {
    transform: scale(1.2) rotate(90deg);
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    font-size: 1.1em;
    color: var(--secondary-color);
}

/* --- Tabla de Ítems de Presupuesto --- */
.quote-items-table tr.subtitulo-row td {
    background-color: var(--dark-gray);
    color: var(--white);
    font-weight: bold;
    font-size: 1em;
    padding: 8px 12px;
    text-align: left !important;
    border-top: 2px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color-dark);
}

.quote-items-table input.item-inline-editable {
    width: 95%;
    padding: 4px;
    font-size: 0.9em;
    height: auto;
    text-align: right;
    border: 1px solid transparent;
    border-radius: 3px;
    background-color: transparent;
    transition: all 0.2s ease-in-out;
}

.quote-items-table input.item-inline-editable:hover {
    border: 1px solid #ccc;
    background-color: #fff;
}

.quote-items-table input.item-inline-editable:focus {
    background-color: #fff;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 3px rgba(179, 0, 0, 0.2);
}

.quote-items-table input.item-unidad {
    text-align: center;
}

/* --- Informes --- */
.card.informe-mes {
    margin-bottom: 25px;
}

.card.gran-total-informe {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    background-color: var(--dark-gray);
    color: var(--white);
    border-radius: 8px;
    border: 1px solid #000;
}

.card.gran-total-informe h4 {
    color: var(--white);
    margin-bottom: 10px;
    border: none;
}

.card.gran-total-informe span {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--success-color);
}

.informe-mes table tfoot tr.total-row-mes {
    background-color: var(--light-gray);
    font-size: 1.1em;
    border-top: 2px solid var(--dark-gray);
}

.informe-resumen-table {
    width: 100%;
    max-width: 500px;
    margin-top: 10px;
}

.informe-resumen-table td {
    padding: 6px 4px;
}

.informe-resumen-table tr.highlight-beneficio.positivo strong {
    color: var(--success-color);
}

.informe-resumen-table tr.highlight-beneficio.negativo strong {
    color: var(--danger-color);
}

.informe-resumen-table tr.margen-row {
    font-style: italic;
    border-top: 1px dashed var(--medium-gray);
}

.informe-resumen-table tr.margen-row.positivo td {
    color: var(--success-color);
}

.informe-resumen-table tr.margen-row.negativo td {
    color: var(--danger-color);
}

/* --- Responsive --- */
@media (max-width: 992px) {
    .sidebar {
        width: 200px;
    }

    .form-group {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 180px;
        font-size: 0.9em;
    }

    .sidebar button {
        padding: 10px 12px;
    }

    .main-content {
        padding: 15px;
    }

    .presupuesto-totals {
        max-width: 100%;
    }

    .search-container {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container input[type="search"],
    .search-container button {
        width: 100%;
        margin-bottom: 5px;
    }

    .form-row .form-group.form-group-quarter,
    .form-row .form-group.form-group-third {
        flex-basis: calc(50% - 10px);
    }
}

@media (max-width: 576px) {
    body {
        font-size: 13px;
    }

    .sidebar {
        width: 160px;
    }

    .sidebar button i.fa-fw {
        margin-right: 8px;
    }

    .main-content h1,
    .main-content h2 {
        font-size: 1.5em;
    }

    .form-layout {
        padding: 15px;
    }

    button.btn-accion,
    button[type="submit"] {
        padding: 8px 12px;
        font-size: 0.95em;
    }

    .total-row.final-total {
        font-size: 1.1em;
    }
}

/* Estilo para textarea con auto-ajuste de altura */
.form-group textarea.auto-resize {
    resize: none;
    /* Deshabilitamos el redimensionado manual del usuario */
    overflow-y: hidden;
    /* Ocultamos el scrollbar, ya que JS gestionará la altura */
}

/* Estilos para la galería de imágenes del cliente */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.thumbnail-container {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.thumbnail-container img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease-in-out;
}

.thumbnail-container:hover img {
    transform: scale(1.05);
}

.delete-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(220, 53, 69, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.thumbnail-container:hover .delete-image-btn {
    opacity: 1;
}

.alert-info {
    padding: 15px;
    margin-top: 15px;
    background-color: #e9f5ff;
    border: 1px solid #b3d7ff;
    color: #004085;
    border-radius: 4px;
}

/* ================================================== */
/* ===     ESTILOS CORREGIDOS PARA LIGHTBOX       === */
/* ================================================== */

/* El fondo oscuro que cubre toda la pantalla */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lightbox-overlay.visible {
    opacity: 1;
}

/* El contenedor de la imagen grande */
.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* LA CORRECCIÓN CLAVE: La imagen ahora es responsive */
.lightbox-content img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

/* El botón de cerrar (X) */
.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 45px;
    font-weight: 300;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 1002;
}

.lightbox-close:hover {
    transform: scale(1.2);
}

/* Los botones de navegación (flechas) */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    padding: 15px 20px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    z-index: 1001;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.6);
}

/* LA CORRECCIÓN CLAVE: Posicionamos los botones DENTRO del overlay */
.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* Ocultamos los botones si están deshabilitados (ej. primera o última imagen) */
.lightbox-nav[disabled] {
    display: none;
}

/* ================================================== */
/* === CORRECCIÓN PARA TEXTOS LARGOS EN CATÁLOGO  === */
/* ================================================== */

.servicio-catalogo-info {
    min-width: 0;
}

.servicio-catalogo-concepto {
    /* FORZAMOS a que el texto se ajuste y sea visible */
    white-space: normal !important;
    overflow: visible !important;
    word-wrap: break-word !important;
    height: auto !important;
    display: block !important;
}

.data-table td {
    /* Rompe la palabra en cualquier punto si no cabe en la línea */
    word-break: break-all;
    /* Asegura que el ajuste de línea general está activado */
    white-space: normal;
}

/* ========================================================== */
/* ===  NUEVAS CLASES PARA ANCHO DE COLUMNAS (FIX CSP)  === */
/* ========================================================== */

.col-id {
    width: 60px;
}

.col-estado {
    width: 200px;
}

.col-acciones {
    width: 120px;
}

/* ========================================================== */
/* ===    NUEVAS CLASES PARA LA VISTA NUEVO PRESUPUESTO   === */
/* ========================================================== */

/* Estilo para las secciones dentro de la tarjeta de "Añadir Partidas" */
.panel-section {
    margin-top: 15px;
}

/* Estilo para los botones de acción al final de un formulario o vista */
.form-actions {
    text-align: right;
    margin-top: 20px;
    margin-bottom: 40px;
}

/* Estilo para el botón de "Añadir Partida Manual" para quitarle el margen superior */
.btn-add-manual-item {
    margin-top: 0 !important;
}

/* Estilo para el grupo de formulario del Estado del Presupuesto */
.form-group-estado-presupuesto {
    margin-top: 15px;
}

/* ========================================================== */
/* ===    CLASE FINAL PARA EL INFORME DE BENEFICIOS (FIX CSP)   === */
/* ========================================================== */

.informe-mes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}


/* ========================================================== */
/* ===    CLASES FINALES PARA VISTAS DE INFORMES (FIX CSP)   === */
/* ========================================================== */

/* Estilo para los subtítulos dentro de la tabla de informe detallado */
.informe-subtitulo {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 2px;
}

/* Clase de utilidad para añadir un pequeño margen a la izquierda */
.ml-10 {
    margin-left: 10px;
}

/* ========================================================== */
/* ===  NUEVAS CLASES PARA VISTA PRECIOS/SERVICIOS (FIX CSP) === */
/* ========================================================== */

/* Para ocultar/mostrar el contenedor de la tabla de servicios */
.hidden-container {
    display: none;
}

/* Estilo para los mensajes de estado de guardado */
.save-status-message {
    margin-left: 15px;
    font-weight: bold;
}

/* ========================================================== */
/* ===         CLASE DE UTILIDAD FINAL (FIX CSP)          === */
/* ========================================================== */

/* Empuja un elemento hacia la derecha dentro de un contenedor flex */
.ml-auto {
    margin-left: auto;
}

/* En style2.css, reemplaza la regla existente por esta */
.quote-items-table tr.subtitulo-row td {
    background-color: var(--dark-gray);
    color: var(--white);
    font-weight: bold;
    font-size: 1em;
    padding: 8px 12px;
    text-align: left !important;
    border-top: 2px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color-dark);
}

/* En style2.css, asegúrate de que esta regla existe y está completa */
.quote-items-table tr.subtitulo-row td {
    background-color: var(--dark-gray);
    color: var(--white);
    font-weight: bold;
    font-size: 1em;
    padding: 8px 12px;
    text-align: left !important;
    border-top: 2px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color-dark);
}

/* ========================================================== */
/* ===    REGLAS FINALES PARA TABLA DE PRESUPUESTOS (FIX CSP)   === */
/* ========================================================== */

/* Estilo para el mensaje de "Aún no hay ítems" */
.empty-quote {
    padding: 20px;
    text-align: center;
    color: var(--secondary-color);
}

/* Estilo para la fila de subtítulo (Baño, Cocina, etc.) */
.quote-items-table tr.subtitulo-row td {
    background-color: var(--dark-gray);
    color: var(--white);
    font-weight: bold;
    font-size: 1em;
    padding: 8px 12px;
    text-align: left !important;
    border-top: 2px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color-dark);
}

/* Clases para el ancho de las columnas de la cabecera */
.col-numero {
    width: 40px;
}

.col-cantidad {
    width: 100px;
}

.col-unidad {
    width: 90px;
}

.col-precio-unitario {
    width: 130px;
}

.col-total {
    width: 120px;
}

.col-acciones {
    width: 80px;
}