/* Estas reglas pisan utilidades de Bootstrap que usan !important. Van dentro de @layer bootstrap:
   un !important sin capa pierde contra el !important de una capa. */
@layer bootstrap {
#contenido-app .bg-light .text-muted {
    color: #9ca3af !important;
}
}

@layer bootstrap {
#contenido-app .card.bg-light {
    background-color: #111827 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #f3f4f6;
}
}

@layer bootstrap {
#contenido-app .card.bg-light .card-body,
#contenido-app .card.bg-light .form-check-label,
#contenido-app .card.bg-light label,
#contenido-app .card.bg-light .fw-bold {
    color: #f3f4f6 !important;
}
}

@layer bootstrap {
#contenido-app .card.bg-light .text-muted,
#contenido-app .card.bg-light .small,
#contenido-app .card.bg-light .form-text {
    color: #cbd5e1 !important;
}
}

.bt-lang-select {
    background-color: transparent !important;
    color: #f9fafb !important;
    border: 0 !important;
    box-shadow: none !important;
}

.bt-lang-select:focus {
    background-color: transparent !important;
    color: #f9fafb !important;
    box-shadow: none !important;
}

.bt-lang-select option {
    background-color: #ffffff;
    color: #111827;
}

/* Nav de perfil.html: resetear estilos de Bootstrap para links del nav oscuro */
nav a {
    text-decoration: none;
}
#desktop-menu a,
#desktop-menu button {
    color: rgb(209 213 219);
    text-decoration: none;
}
#desktop-menu a:hover {
    color: white;
    text-decoration: none;
}
#desktop-menu a.text-primary,
#desktop-menu a.font-bold {
    color: #e91e63;
}
#desktop-menu a.text-primary:hover {
    color: #c2185b;
}

/* BarraTools responsive sidebar */
#layout {
    display: flex;
}

#sidebarMenu {
    width: 250px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

#sidebarMenu .list-group-item {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mainContent {
    flex: 1;
}

@media (min-width: 992px) {
    #sidebarMenu.collapsed {
        display: none;
    }
}

/* Mobile overlay */
@media (max-width: 991.98px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Bloquea el scroll del body cuando el sidebar está abierto */
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    #layout {
        display: block !important; /* override Bootstrap d-flex !important */
    }
    #mainContent {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    #sidebarMenu {
        position: fixed !important;
        top: 80px;
        left: 0;
        height: calc(100% - 80px);
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        width: min(280px, 85vw);
        min-width: unset;
    }
    #sidebarMenu.open {
        transform: translateX(0);
    }
    #sidebarMenu .list-group-item {
        min-height: 48px;
        font-size: 1rem;
    }
    #sidebarOverlay {
        display: none;
        position: fixed;
        top: 80px;
        left: 0;
        width: 100%;
        height: calc(100% - 80px);
        background: rgba(0, 0, 0, 0.65);
        z-index: 1040;
    }
    #sidebarOverlay.show {
        display: block;
    }
    #estChipNav {
        display: flex !important;
    }
    #sidebarNavLinks {
        display: block !important;
    }
}

/* ── Modales: UX mobile global ── */

/* Los modales sin fullscreen-sm-down que tienen contenido largo:
   el modal-body scrollea internamente en lugar de cortar el contenido */
@media (max-width: 575.98px) {
    .modal-dialog:not(.modal-fullscreen):not(.modal-fullscreen-sm-down) {
        margin: 0.75rem auto;
        max-width: calc(100vw - 1.5rem);
    }
    .modal-dialog:not(.modal-fullscreen):not(.modal-fullscreen-sm-down) .modal-content {
        max-height: calc(100svh - 1.5rem);
        display: flex;
        flex-direction: column;
    }
    .modal-dialog:not(.modal-fullscreen):not(.modal-fullscreen-sm-down) .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* ── Input groups: evitar textos cortados y inputs diminutos ── */

/* El texto del addon nunca se corta */
.input-group-text {
    white-space: nowrap;
}

/* En mobile, los input-group con botón grande (ej: "Seleccionar") se apilan
   para que el campo de texto no quede ridículamente angosto */
@media (max-width: 575.98px) {
    .input-group:not(.input-group-sm):not(.no-stack) {
        flex-wrap: wrap;
        gap: 6px;
    }
    .input-group:not(.input-group-sm):not(.no-stack) > .form-control,
    .input-group:not(.input-group-sm):not(.no-stack) > .form-select {
        flex: 1 1 100%;
        border-radius: var(--bs-border-radius) !important;
    }
    .input-group:not(.input-group-sm):not(.no-stack) > .btn {
        flex: 0 0 auto;
        border-radius: var(--bs-border-radius) !important;
        width: 100%;
    }
}

/* Los input-group-sm de cantidad dentro de filas de restricciones:
   el texto "Cant." siempre visible y el input numerico tiene mínimo decente */
.input-group-sm .input-group-text {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}
.input-group-sm .form-control[type="number"] {
    min-width: 56px;
}

/* Fuerza que los inputs numéricos con width inline no sean diminutos en mobile */
@media (max-width: 575.98px) {
    input[type="number"][style*="width"] {
        width: auto !important;
        min-width: 64px;
    }
}

/* ── Tabs scrolleables: fade de borde para indicar scroll ── */
@media (max-width: 768px) {
    .nav-tabs[style*="overflow-x"] {
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
        scrollbar-width: none;
    }
    .nav-tabs[style*="overflow-x"]::-webkit-scrollbar {
        display: none;
    }
}

/* ── rt-table: override para dark theme de barratools ── */
@media (max-width: 768px) {
    #contenido-app .rt-table tbody tr {
        background: #1f2937;
        border-color: #374151;
    }
    #contenido-app .rt-table tbody td {
        border-color: #374151;
        color: #f3f4f6;
    }
    #contenido-app .rt-table tbody td::before {
        color: #9ca3af;
    }
}

/* ── Focus states visibles ── */
.form-control:focus,
.form-select:focus {
    outline: 2px solid #e91e63 !important;
    outline-offset: -1px;
    box-shadow: none !important;
}
.btn:focus-visible {
    outline: 2px solid #e91e63 !important;
    outline-offset: 2px;
}

/* ── Chip de establecimiento: más ancho ── */
#estChipNav {
    max-width: 200px !important;
}

/* ── Botón Guardar sticky en modales mobile ── */
@media (max-width: 575.98px) {
    .modal-fullscreen-sm-down .modal-footer {
        position: sticky;
        bottom: 0;
        background: #1f2937;
        border-top: 1px solid #374151;
        z-index: 10;
        padding: 12px 16px;
    }
}

/* ── Image cropper: más chico en pantallas bajas ── */
@media (max-height: 600px) {
    #imageCropperContainerFlyer {
        max-height: 180px !important;
        height: auto !important;
    }
}

/* ── Botones de acción en tablas: tap target mínimo ── */
@media (max-width: 768px) {
    #contenido-app .btn-sm {
        min-height: 38px;
        min-width: 38px;
        padding: 6px 10px;
    }
}

/* ── Encabezado común de las BarraTools ─────────────────────────────── */
.bt-tool-header {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(55, 65, 81, 0.5);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
    color: #fff;
}

.bt-tool-header::before {
    content: "";
    position: absolute;
    top: -8rem;
    right: -8rem;
    width: 16rem;
    height: 16rem;
    border-radius: 50%;
    background: rgba(233, 30, 99, 0.12);
    filter: blur(48px);
    pointer-events: none;
}

.bt-tool-header__icon {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.75rem;
    background: rgba(233, 30, 99, 0.2);
    font-size: 1.75rem;
    line-height: 1;
}

.bt-tool-header__text {
    position: relative;
    flex: 1 1 14rem;
    min-width: 0;
}

.bt-tool-header__title {
    margin: 0 0 0.15rem;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.bt-tool-header__subtitle {
    margin: 0;
    color: #9ca3af;
    font-size: 0.875rem;
}

.bt-tool-header__actions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .bt-tool-header {
        padding: 2rem;
    }

    .bt-tool-header__title {
        font-size: 1.875rem;
    }
}

@media (max-width: 575.98px) {
    .bt-tool-header__icon {
        width: 3rem;
        height: 3rem;
        font-size: 1.5rem;
    }
}

.bt-tool-header__icon .material-icons {
    font-size: 1.9rem;
    color: #f48fb1;
}

@media (max-width: 575.98px) {
    .bt-tool-header__icon .material-icons {
        font-size: 1.6rem;
    }
}

/* Títulos de sección dentro de las herramientas: ícono + texto alineados */
.bt-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bt-section-title .material-icons {
    color: #e91e63;
    font-size: 1.35em;
}
