/* ========================================================================== */
/* VARIABLES */
:root {
    --sidebar-width-mini: 70px;
    --sidebar-width-full: 260px;
    --topbar-height: 70px;
    --bg-sidebar: #1e1e2d;
    --bg-topbar: #ffffff;
    --accent-color: #0d6efd;
}

/* ========================================================================== */
/* BASE */
body {
    min-height: 100vh;
    background: #f4f5f7;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

.text-logout { color:red !important; }

.img-responsive,
.thumbnail a>img,
.thumbnail>img {
    display: block;
    width: 70%;
    height: auto;
}

/* ========================================================================== */
/* TOPBAR */
#topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width-mini);
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    z-index: 1020;

    display: flex;
    align-items: center;

    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.expanded + #topbar {
    left: var(--sidebar-width-full);
}

.topbar-inner {
    display: flex;
    align-items: center;
    width: 100%;
    gap: .75rem;
    padding: 0 12px;
}

/* Divisores */
.topbar-divider {
    width: 1px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.15);
    margin: 0 0rem;
}

@media (max-width: 768px) {
    .topbar-divider { display: none; }
}

/* ========================================================================== */
/* BUSCADOR TOPBAR (ESTABLE, FLEX REAL) */
.search-float {
    display: flex;
    align-items: center;
    gap: .5rem;

    width: 40px;                 /* solo icono */
    overflow: hidden;
    flex: 0 0 auto;

    transition: width .25s ease;
}

/* botón lupa */
.search-trigger {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--accent-color);
    flex-shrink: 0;
}

/* input */
.search-box {
    flex: 1 1 auto;
    min-width: 0;

    opacity: 0;
    pointer-events: none;

    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: .9rem;

    transition: opacity .2s ease;
}

/* activo */
.search-float.active {
    width: 260px;               /* icono + input */
}

.search-float.active .search-box {
    opacity: 1;
    pointer-events: auto;
}

/* ========================================================================== */
/* TOPBAR CENTER */
.topbar-center {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

.empresa-wrapper {
    width: 100%;
    max-width: 450px;
    min-width: 0px;
    text-align: left !important; 
}

.empresa-nombre {
    width: 100%;
    resize: none;
    overflow: hidden;
    text-align: left; 
    font-size: .9rem;
    line-height: 1.3;
    background: transparent;
    border: none;
    cursor: default;
    display: flex;
    align-items: center;
}

/* ========================================================================== */
/* TOPBAR RIGHT */
.user-info {
    white-space: nowrap;
}

/* ========================================================================== */
/* SIDEBAR */
#sidebar {
    width: var(--sidebar-width-mini);
    background: var(--sidebar-bg, #e3e7f4);
    color: var(--sidebar-text, #ffffff);

    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1030;

    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;

    display: flex;
    flex-direction: column;
}

#sidebar.expanded {
    width: var(--sidebar-width-full);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 15px;
    background: rgba(0,0,0,0.1);
    white-space: nowrap;
}

.sidebar-header img {
    width: 40px;
    border-radius: 8px;
}

.header-text {
    margin-left: 15px;
    opacity: 0;
    transition: opacity 0.2s;
}

#sidebar.expanded .header-text {
    opacity: 1;
}
#sidebar.expanded .sidebar-empresa {
    max-width: 100%;
    white-space: normal;       /* permite saltos */
    word-break: normal;        /* NO rompe palabras */
    overflow-wrap: break-word; /* por si hay palabras largas */
    line-height: 1.2;
    transform: translateY(0);
    transition: all 0.25s ease;
}
/* Estado oculto */
#sidebar:not(.expanded) .sidebar-empresa {
    opacity: 0;
    max-height: 0;
    transform: translateY(-5px);
    overflow: hidden;
    pointer-events: none;
    /*transition: all 0.25s ease;*/
    display:none;
}

/* ========================================================================== */
/* MENÚ */
.nav,
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    white-space: nowrap;
    padding: 12px 20px;
    text-decoration: none;
    /*
    --link-color: #a2a3b7;
    color: var(--link-color) !important;
    */
    color: color-contrast(
        var(--sidebar-bg) 
        vs #000, #fff
    );
    
    transition: background .2s ease, color .2s ease;
}

.nav-link i:first-child {
    margin-right: 10px;
    min-width: 20px;
    text-align: center;
    color: var(--link-color);
}

.nav-link span {
    margin-left: 10px;
    opacity: 0;
    transition: opacity .2s ease;
}

#sidebar.expanded .nav-link span {
    opacity: 1;
}

.nav-link:hover {
    --link-color: #ffffff;
    background: rgba(255,255,255,0.05);
}

/* Submenú */
.submenu {
    background: var(--sidebar-bg, #eaeaf2);
}

.submenu .nav-link {
    padding-left: 20px;
    font-size: .85rem;
    border-left: 1px solid rgba(255,255,255,0.1);
}

/* Flechas */
.arrow-icon {
    margin-left: auto;
    transition: transform .3s ease;
    font-size: .8rem;
    opacity: 0;
}

#sidebar.expanded .arrow-icon {
    opacity: 1;
}

.nav-link:not(.collapsed) .arrow-icon {
    transform: rotate(-90deg);
}

/* ========================================================================== */
/* CONTENT */
#content {
    margin-top: var(--topbar-height);
    margin-left: var(--sidebar-width-mini);
    padding-top: 5px;

    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.expanded ~ #content {
    margin-left: var(--sidebar-width-full);
}
/* ================== termina los estilos de inicio ========================= */

/* ======================Tabla Principal ========================== */
.table .btn {
    padding: .25rem .45rem;
    line-height: 1;
}
/* ================= FILA NAVEGABLE ================= */
.fila-navegable {
    cursor: pointer;                 
    transition: background-color .15s ease;
}

/* Hover */
.fila-navegable:hover {
    background-color: rgba(13,110,253,.06); /* azul Bootstrap muy suave */
}
.fila-navegable .permisos {
    cursor: pointer;                
    transition: background-color .5s ease;
}


.fila-navegable.permisos:hover {
    background-color: rgba(9, 62, 142, 0.66); /* azul Bootstrap muy suave */
}

.fila-navegable-sub.permisos {
    cursor: pointer;
    transition: background-color .5s ease;
}

.fila-navegable-sub.permisos:hover {
    background-color: rgba(9, 62, 142, 0.66);
}

/* Activa (click) */
.fila-navegable:active {
    background-color: rgba(13,110,253,.12);
}

/* Si la fila est�� deshabilitada */
.fila-navegable.disabled,
.fila-navegable[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .6;
}
/* ================= FILA DESHABILITADA ================= */
.fila-navegable.disabled {
    pointer-events: none;   /* �9�8 no clic */
    cursor: not-allowed;
    opacity: .55;
    background-color: #f8f9fa;
}

/* ==================== INPUTS READONLY (VISTA) ==================== */
/* INPUTS SOLO LECTURA */
.empresa-input[readonly] {
    background-color: #f8fbff;
    border: 1px solid #4da3ff;
    box-shadow: inset 0 0 0 1px rgba(77,163,255,.15);
    cursor: default;
}

.empresa-input-actividad[readonly] {
    background-color: #ffffff;
    border: 1px solid #b2c6dc;
    box-shadow: inset 0 0 0 1px rgba(77,163,255,.15);
    cursor: default;
    margin-bottom: .25rem !important;
}

/* INPUTS EDITABLES */
.empresa-input.editable {
    background-color: #ffffff;
    border: 1px solid #ced4da;
    box-shadow: none;
    cursor: text;
    position: relative;
    z-index: 1;
}

/* FOCO CLARO CUANDO SE EDITA */
.empresa-input.editable:focus {
    border-color: #0dcaf0;
    box-shadow: 0 0 0 .15rem rgba(13,202,240,.25);
    outline: none;
}

/* Transici��n suave */
.empresa-input {
    transition: background-color .2s ease-in-out,
                border-color .2s ease-in-out,
                box-shadow .2s ease-in-out;
}


/* ==================== switch ==================== */
/* Switch apagado �� ROJO */
.switch-activa:not(:checked) {
    background-color: #dc3545;
    border-color: #dc3545;
    cursor: pointer
}

/* Switch encendido �� VERDE */
.switch-activa:checked {
    background-color: #198754;
    border-color: #198754;
    cursor: pointer
}

/* Efecto suave */
.switch-activa {
    transition: background-color .2s ease, border-color .2s ease;
}

/* Cursor correcto */
.switch-activa:disabled {
    cursor: not-allowed;
    opacity: 0.9;
    
}
/* ==================== loader ==================== */
.spinner-xl {
    width: 5rem;
    height: 5rem;
    border-width: 0.5rem;
}

.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;
}
/* ==================== negrita ==================== */
.negrita {
    font-weight: bold;
}

/* ==================== buscador ==================== */
.menu-search-wrapper {
    position: relative;     /* CONTEXTO */
    max-width: 300px;
}

#search-results {
    position: absolute;
    top: calc(100% + 6px);  /* Justo debajo del input */
    left: 0;
    width: 50%;
    z-index: 1050;
}

.menu-search-wrapper {
    outline: 1px dashed red;
}

#search-results {
    outline: 1px dashed blue;
}


#search-results li {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color .15s ease, color .15s ease;
}

/* HOVER */
#search-results li:hover,
#search-results li:focus {
    background-color: #d2d2d2;   /* celeste suave */ 
    color: #e7f3ff;              /* azul Bootstrap */
    font-weight: bold;
}

/* ==================== ancho fijo ==================== */

.t-10 {
    width: 10px !important;
    max-width: 10px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-20 {
    width: 20px !important;
    max-width: 20px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-30 {
    width: 30px !important;
    max-width: 30px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-40 {
    width: 40px !important;
    max-width: 40px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-50 {
    width: 50px !important;
    max-width: 50px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auto-table {
    width: auto !important;
    table-layout: auto;
    margin: 0 auto; /* centrar */
}

.auto-table th,
.auto-table td {
    white-space: nowrap;
    padding: 0.35rem 0.5rem;
    text-align: center;
}
/* ====== tipo de cambio ============= */
.input-tc {
    width: 100px !important;
    /*border: none !important;*/
    background: transparent !important;
    padding: 0 4px;
    font-weight: 600;
    box-shadow: none !important;
}

.input-tc:focus {
    outline: none;
    box-shadow: none;
}

/* ============ canvas lateral ===========*/
.user-trigger {
    cursor: pointer;
}

.user-trigger:hover {
    opacity: 0.85;
}
/* ============ error handler ===========*/
.error-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 420px;
    background: #842029;
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    z-index: 99999;
    box-shadow: 0 0 15px rgba(0,0,0,.4);
}
.success-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 420px;
    background: #16821c;
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    z-index: 99999;
    box-shadow: 0 0 15px rgba(0,0,0,.4);
}

/* ============ error handler ===========*/
/* ============ form switch ===========*/
.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: #198754;
    border-color: #198754;
}

.table td, .table th {
    vertical-align: middle;
}

/* ============ form switch ===========*/
/* ============ boton password ===========*/
.btn-outline-primary i {
    color: #0d6efd;
}

.btn-outline-primary:hover i {
    color: #fff;
}
.input-group .btn {
    z-index: 3;
}
.input-group-text i {
    color: inherit;
}
/* ============ boton password ===========*/
/* ============ tabla scroll ===========*/
.table-scroll-right {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.table-scroll-right thead th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa; /* table-light */
    z-index: 2;
}

/* ============ tabla scroll ===========*/

.nav-link.active {
    background-color: rgba(201,0,0,0.1);
    border-left: 3px solid #0d6efd;
    font-weight: 600;
}

.submenu .nav-link.active {
    background-color: rgba(201,0,0,0.1);
}

/* ========== Rotación elegante de la flecha  ====================== */

.arrow-icon {
    transition: transform 0.3s ease;
}

.nav-link:not(.collapsed) .arrow-icon {
    transform: rotate(-90deg);
}
/* ========== Rotación elegante de la flecha  ====================== */

/* ==========  Mejorar indentación del submenu ====================== */

.submenu {
    padding-left: 1.8rem;
}

.submenu .nav-link {
    font-size: 0.9rem;
}
/* ==========  Mejorar indentación del submenu ====================== */