﻿/* ===================================
   SPI PRODUCCIÓN - SITE.CSS
   Actualizado para Bootstrap 5
   =================================== */

/* DEFAULTS
----------------------------------------------------------*/

body {
    background: #e9ecef;
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #495057;
}

a {
    color: #0d6efd;
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

    a:hover {
        color: #0a58ca;
        text-decoration: underline;
    }

p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* HEADINGS   
----------------------------------------------------------*/

h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    color: #212529;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5, h6 {
    font-size: 1rem;
}

/* LAYOUT RESPONSIVO
----------------------------------------------------------*/

.container-fluid {
    max-width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

@media (min-width: 768px) {
    .container-fluid {
        padding-right: 30px;
        padding-left: 30px;
    }
}

/* SIDEBAR LAYOUT
----------------------------------------------------------*/

:root {
    --spi-sidebar-width: 240px;
    --spi-topbar-height: 52px;
    --spi-sidebar-bg: #1c1f23;
    --spi-sidebar-hover: #2c3036;
    --spi-sidebar-active: #157a35;
    --spi-sidebar-text: #adb5bd;
    --spi-sidebar-text-hover: #f8f9fa;

    /* Paleta corporativa SPI */
    --spi-green:       #157a35;
    --spi-green-dark:  #0f5e27;
    --spi-green-light: #e6f5ec;
    --spi-gray:        #dfe2e5;
    --spi-gray-dark:   #b0b8c1;
}

/* Top bar */
.spi-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--spi-topbar-height);
    background: #212529;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1045;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

.spi-topbar-left {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.spi-topbar-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.spi-topbar-brand img {
    display: block;
    height: 30px;
    width: auto;
}

.spi-toggle-btn {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: 1.1rem;
    padding: .35rem .5rem;
    border-radius: .375rem;
    cursor: pointer;
    line-height: 1;
    transition: background .15s, color .15s;
}

.spi-toggle-btn:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.spi-user-btn {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: .875rem;
    padding: .35rem .6rem;
    border-radius: .375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: background .15s, color .15s;
}

.spi-user-btn:hover,
.spi-user-btn.show {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.spi-user-btn i {
    font-size: 1.15rem;
}

/* Sidebar */
.spi-sidebar {
    position: fixed;
    top: var(--spi-topbar-height);
    left: calc(-1 * var(--spi-sidebar-width));
    width: var(--spi-sidebar-width);
    height: calc(100vh - var(--spi-topbar-height));
    background: var(--spi-sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    transition: left .25s ease;
    z-index: 1040;
    box-shadow: 3px 0 10px rgba(0,0,0,.25);
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

.spi-sidebar.show {
    left: 0;
}

.spi-sidebar-header {
    padding: .75rem 1.1rem .5rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: .25rem;
}

.spi-sidebar-section {
    padding: .7rem 1.1rem .2rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #6c757d;
    font-weight: 700;
}

.spi-sidebar-nav {
    padding: .25rem 0 1rem;
}

.spi-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .7rem;
    padding: .5rem 1rem .5rem 1.1rem;
    color: var(--spi-sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    transition: background .15s, color .15s;
    /* indicador activo con box-shadow para no afectar el padding */
    box-shadow: inset 0 0 0 transparent;
    white-space: nowrap;
}

.spi-sidebar-link i {
    width: 1rem;
    text-align: left;
    flex-shrink: 0;
    font-size: .875rem;
    opacity: .75;
}

.spi-sidebar-link span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.spi-sidebar-link:hover {
    background: var(--spi-sidebar-hover);
    color: var(--spi-sidebar-text-hover);
    text-decoration: none;
}

.spi-sidebar-link:hover i {
    opacity: 1;
}

.spi-sidebar-link.active {
    background: rgba(13,110,253,.12);
    color: #6ea8fe;
    /* borde izquierdo sin afectar layout */
    box-shadow: inset 3px 0 0 var(--spi-sidebar-active);
    font-weight: 500;
}

.spi-sidebar-link.active i {
    opacity: 1;
}

/* Main content */
.spi-main {
    padding-top: var(--spi-topbar-height);
    min-height: 100vh;
    transition: margin-left .25s ease;
}

@media (min-width: 992px) {
    .spi-main.sidebar-open {
        margin-left: var(--spi-sidebar-width);
    }
}

/* Backdrop mobile */
.spi-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--spi-topbar-height);
    background: rgba(0,0,0,.5);
    z-index: 1039;
}

.spi-backdrop.show {
    display: block;
}

/* NAVBAR CUSTOM
----------------------------------------------------------*/

.navbar-dark {
    background-color: #212529 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.navbar-brand img {
    max-height: 50px;
    width: auto;
}

@media (max-width: 767px) {
    .navbar-brand img {
        max-height: 40px;
    }
}

.nav-link {
    font-size: 0.95rem;
    padding: 0.5rem 1rem !important;
}

.navbar-nav .nav-link.active {
    font-weight: 600;
}

/* DROPDOWN MENU
----------------------------------------------------------*/

.dropdown-menu {
    border: 1px solid rgba(0,0,0,.15);
    box-shadow: 0 6px 12px rgba(0,0,0,.175);
}

.dropdown-item {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

    .dropdown-item:hover {
        background-color: #f8f9fa;
    }

/* FORMS RESPONSIVOS
----------------------------------------------------------*/

.form-control,
.form-select {
    font-size: 0.9rem;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Mejoras para formularios en dispositivos pequeños */
@media (max-width: 767px) {
    .form-group {
        margin-bottom: 1rem;
    }

    .col-sm-2,
    .col-md-4 {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    label.control-label {
        text-align: left !important;
        display: block;
        margin-bottom: 0.25rem;
    }
}

/* BUTTONS
----------------------------------------------------------*/

.btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (max-width: 576px) {
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* TABLES RESPONSIVE
----------------------------------------------------------*/

.table {
    font-size: 0.85rem;
}

.table-responsive {
    border-radius: 0.375rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .table {
        font-size: 0.75rem;
    }

        .table thead {
            display: none;
        }

        .table tr {
            display: block;
            margin-bottom: 1rem;
            border: 1px solid #dee2e6;
            border-radius: 0.375rem;
        }

        .table td {
            display: block;
            text-align: right;
            border: none;
            padding: 0.5rem;
        }

            .table td:before {
                content: attr(data-label);
                float: left;
                font-weight: 600;
                color: #495057;
            }
}

/* FILTROS - Sistema de filtros mejorado
----------------------------------------------------------*/

#filtros {
    background: #fff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    margin-bottom: 2rem;
}

    #filtros fieldset {
        border: none;
        padding: 0;
        margin-bottom: 1.5rem;
    }

    #filtros legend {
        background: var(--spi-green);
        color: #fff;
        font-size: 1.1rem;
        font-weight: 600;
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
        border-radius: 0.375rem;
        width: 100%;
    }

    #filtros .form-group {
        margin-bottom: 1rem;
    }

    #filtros label {
        font-weight: 500;
        color: #495057;
        margin-bottom: 0.5rem;
    }

    #filtros input:not([type=radio]):not([type=checkbox]),
    #filtros textarea,
    #filtros select {
        width: 100%;
        padding: 0.5rem;
        border: 1px solid #ced4da;
        border-radius: 0.375rem;
        font-size: 0.9rem;
        transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    }

        #filtros input:focus,
        #filtros select:focus,
        #filtros textarea:focus {
            border-color: #86b7fe;
            box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
            background-color: #fff;
        }

    #filtros button {
        background: var(--spi-green);
        color: #fff;
        border: none;
        padding: 0.75rem 2rem;
        border-radius: 0.5rem;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
        box-shadow: 0 4px 6px rgba(0,0,0,.1);
    }

        #filtros button:hover {
            background: var(--spi-green-dark);
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0,0,0,.15);
        }

        #filtros button:active {
            transform: translateY(0);
        }

/* INDICADORES
----------------------------------------------------------*/

.cssTituloColumnaIndicadores {
    font-size: 1.5rem;
    font-weight: 700;
    background-color: #f8f9fa;
    text-align: center;
    padding: 1rem;
    border-radius: 0.375rem;
}

.cssDetalleColumnaIndicadores {
    font-size: 2.5rem;
    font-weight: 400;
    text-align: center;
    color: #6c757d;
    padding: 1rem;
}

@media (max-width: 767px) {
    .cssDetalleColumnaIndicadores {
        font-size: 1.75rem;
    }
}

/* FOOTER
----------------------------------------------------------*/

footer {
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

    footer a {
        color: #6c757d;
        font-weight: 500;
    }

        footer a:hover {
            color: #495057;
        }

/* UTILITIES RESPONSIVE
----------------------------------------------------------*/

.text-responsive {
    font-size: 1rem;
}

@media (max-width: 767px) {
    .text-responsive {
        font-size: 0.875rem;
    }
}

/* GRÁFICOS - Evita desbordamiento al cambiar ancho del contenedor
----------------------------------------------------------*/

/* Morris.js genera SVGs con width fijo; overflow:hidden en el wrapper
   evita el desborde visual durante la transición del sidebar */
.card-body svg {
    max-width: 100%;
}

/* ANIMATIONS
----------------------------------------------------------*/

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ACCESSIBILITY
----------------------------------------------------------*/

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
}

/* BRAND UTILITIES
----------------------------------------------------------*/

.bg-spi                { background-color: var(--spi-green)       !important; }
.bg-spi-light          { background-color: var(--spi-green-light)  !important; }
.text-spi              { color:            var(--spi-green)        !important; }
.border-spi            { border-color:     var(--spi-green)        !important; }

.btn-spi {
    background-color: var(--spi-green);
    border-color:     var(--spi-green-dark);
    color: #fff;
    transition: background-color .15s, border-color .15s;
}
.btn-spi:hover,
.btn-spi:focus {
    background-color: var(--spi-green-dark);
    border-color:     var(--spi-green-dark);
    color: #fff;
}

.btn-outline-spi {
    color:            var(--spi-green);
    border-color:     var(--spi-green);
    background-color: transparent;
    transition: background-color .15s, color .15s;
}
.btn-outline-spi:hover,
.btn-outline-spi:focus {
    background-color: var(--spi-green);
    border-color:     var(--spi-green);
    color: #fff;
}

/* PRINT STYLES
----------------------------------------------------------*/

@media print {
    .spi-topbar,
    .spi-sidebar,
    .spi-backdrop,
    .btn,
    footer {
        display: none !important;
    }

    .spi-main {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }

    body {
        background: #fff;
    }

    .container-fluid {
        padding: 0;
    }
}
