/* ========================================
   PLATAFORMA ROY - ESTILOS PROFESIONALES
   Autor: Diseño Profesional
   Versión: 2.0
   ======================================== */

/* ==========================================
   VARIABLES DE COLORES PROFESIONALES
   ========================================== */
:root {
    /* Paleta Principal */
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --info-color: #16a085;
    
    /* Colores de Fondo */
    --bg-dark: #1a252f;
    --bg-light: #ecf0f1;
    --bg-white: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    /* Colores de Texto */
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --text-white: #ffffff;
    
    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    
    /* Transiciones */
    --transition-fast: all 0.2s ease;
    --transition-normal: all 0.3s ease;
    --transition-slow: all 0.5s ease;
    
    /* Bordes */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 20px;
}

/* ==========================================
   FONDO DE LOGIN - RESPONSIVE
   ========================================== */
.fondoLogin {
    background-image: url('../Image/promo.jpeg');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
    min-height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Overlay oscuro para mejorar legibilidad */
    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-overlay);
        z-index: 1;
    }
    
    /* Todo el contenido sobre el overlay */
    > * {
        position: relative;
        z-index: 2;
    }
}

/* ==========================================
   NAVBAR - MEJORAS PROFESIONALES
   ========================================== */
.main-header.navbar {
    border-bottom: 3px solid var(--secondary-color);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--bg-white) 0%, #f8f9fa 100%);
}

.navbar-nav .nav-link {
    transition: var(--transition-fast);
    border-radius: var(--border-radius-sm);
    margin: 0 4px;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(52, 152, 219, 0.1);
    transform: translateY(-2px);
}

.navbar-badge {
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ==========================================
   SIDEBAR - DISEÑO MODERNO
   ========================================== */
.main-sidebar {
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--primary-color) 100%);
    box-shadow: var(--shadow-lg);
    width: 280px !important; /* Ancho ampliado para mostrar subtítulos completos */
}

/* Ajustar el content-wrapper cuando el sidebar está expandido */
.sidebar-mini:not(.sidebar-collapse) .content-wrapper,
.sidebar-mini:not(.sidebar-collapse) .main-footer,
.sidebar-mini:not(.sidebar-collapse) .main-header {
    margin-left: 280px !important;
}

/* Cuando el sidebar está colapsado */
.sidebar-mini.sidebar-collapse .main-sidebar {
    width: 4.6rem !important;
}

/* Prevenir overflow horizontal en el sidebar */
.sidebar {
    overflow-x: hidden;
    overflow-y: auto;
}

.brand-link {
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding: 1.2rem 1rem;
    transition: var(--transition-normal);
}

.brand-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.brand-text {
    color: var(--text-white) !important;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

/* Menú de Navegación */
.nav-sidebar .nav-link {
    border-radius: var(--border-radius-md);
    margin: 4px 8px;
    padding: 12px 16px;
    transition: var(--transition-normal);
    color: rgba(255, 255, 255, 0.8);
    white-space: normal; /* Permite que el texto se ajuste */
    word-wrap: break-word;
}

.nav-sidebar .nav-link p {
    display: inline-block;
    width: 100%;
    line-height: 1.4;
}

.nav-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
    color: var(--text-white);
}

.nav-sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    color: var(--text-white);
    box-shadow: var(--shadow-md);
}

.nav-sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.nav-treeview .nav-link {
    padding-left: 3rem;
    font-size: 0.9rem;
    padding-top: 10px;
    padding-bottom: 10px;
    white-space: normal;
    line-height: 1.4;
}

.nav-treeview .nav-link::before {
    content: '•';
    margin-right: 10px;
    color: var(--secondary-color);
    font-weight: bold;
    flex-shrink: 0;
}

.nav-treeview .nav-link p {
    margin: 0;
    display: inline;
}

/* ==========================================
   USER MENU - DROPDOWN MEJORADO
   ========================================== */
.user-menu .dropdown-menu {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    border: none;
    min-width: 280px;
}

.user-header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.user-header img {
    border: 4px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-md);
}

.user-footer {
    padding: 1rem;
    background-color: var(--bg-light);
}

.user-footer .btn {
    border-radius: var(--border-radius-md);
    padding: 8px 20px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.user-footer .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==========================================
   CONTENT WRAPPER - ÁREA DE CONTENIDO
   ========================================== */
.content-wrapper {
    background-color: var(--bg-light);
    min-height: calc(100vh - 57px);
}

.content-header h1 {
    color: var(--text-dark);
    font-weight: 700;
    font-size: 2rem;
    position: relative;
    display: inline-block;
    padding-bottom: 10px;
}

.content-header h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary-color) 0%, var(--info-color) 100%);
    border-radius: 2px;
}

/* ==========================================
   CHAT ROY - DISEÑO PROFESIONAL
   ========================================== */

/* Botón de Chat Flotante */
.bchatroy {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1050;
    padding: 14px 24px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--border-radius-xl);
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    border: none;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-normal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bchatroy:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: var(--shadow-xl);
    background: linear-gradient(135deg, var(--info-color) 0%, var(--secondary-color) 100%);
}

.bchatroy i {
    margin-right: 8px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Ventana de Chat */
.chatroy {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 1040;
    width: 380px;
    max-width: calc(100vw - 60px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatroy .card-header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    color: var(--text-white);
    padding: 1rem 1.25rem;
    border: none;
}

.chatroy .card-header .card-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

.chatroy .card-body {
    background-color: var(--bg-white);
    max-height: 400px;
    overflow-y: auto;
}

/* Mensajes del Chat */
.direct-chat-messages {
    padding: 1rem;
}

.direct-chat-msg {
    margin-bottom: 1.5rem;
}

.direct-chat-text {
    border-radius: var(--border-radius-lg);
    padding: 12px 16px;
    background-color: #e8f4f8;
    box-shadow: var(--shadow-sm);
    max-width: 75%;
    word-wrap: break-word;
}

.direct-chat-msg.right .direct-chat-text {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    color: var(--text-white);
}

.direct-chat-img {
    border: 3px solid var(--bg-white);
    box-shadow: var(--shadow-md);
}

.direct-chat-infos {
    margin-bottom: 8px;
}

.direct-chat-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.direct-chat-timestamp {
    color: var(--text-light);
    font-size: 0.8rem;
}

/* Footer del Chat */
.chatroy .card-footer {
    background-color: var(--bg-light);
    border-top: 2px solid rgba(52, 152, 219, 0.2);
    padding: 1rem;
}

.chatroy .card-footer .form-control {
    border-radius: var(--border-radius-lg);
    border: 2px solid #ddd;
    transition: var(--transition-fast);
}

.chatroy .card-footer .form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.chatroy .card-footer .btn {
    border-radius: var(--border-radius-lg);
    padding: 8px 20px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    border: none;
    transition: var(--transition-fast);
}

.chatroy .card-footer .btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* Scrollbar Personalizado */
.direct-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.direct-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.direct-chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--secondary-color) 0%, var(--info-color) 100%);
    border-radius: 3px;
}

/* ==========================================
   FOOTER - DISEÑO MODERNO
   ========================================== */
.main-footer {
    background: linear-gradient(135deg, var(--bg-white) 0%, #f8f9fa 100%);
    border-top: 3px solid var(--secondary-color);
    padding: 1.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

.main-footer strong {
    color: var(--text-dark);
    font-weight: 700;
}

/* ==========================================
   DROPDOWN MENUS - MEJORADOS
   ========================================== */
.dropdown-menu {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: none;
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.75rem 1.5rem;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
}

.dropdown-item:hover {
    background-color: rgba(52, 152, 219, 0.1);
    border-left-color: var(--secondary-color);
    transform: translateX(3px);
}

.dropdown-header {
    font-weight: 700;
    color: var(--text-dark);
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-light);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-top-color: rgba(0, 0, 0, 0.08);
}

/* ==========================================
   BADGES - NOTIFICACIONES
   ========================================== */
.badge {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
}

.badge-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.badge-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.badge-primary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
}

/* ==========================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ========================================== */

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
    .content-header h1 {
        font-size: 1.75rem;
    }
    
    .chatroy {
        width: 340px;
    }
    
    /* Mantener sidebar amplio en tablets */
    .main-sidebar {
        width: 280px !important;
    }
}

/* Tablets Portrait (max-width: 768px) */
@media (max-width: 768px) {
    .fondoLogin {
        background-attachment: scroll;
    }
    
    .content-header h1 {
        font-size: 1.5rem;
    }
    
    .bchatroy,
    .chatroy {
        right: 20px;
    }
    
    .bchatroy {
        bottom: 20px;
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .chatroy {
        bottom: 80px;
        width: calc(100vw - 40px);
    }
    
    .user-menu .dropdown-menu {
        min-width: 240px;
    }
    
    /* Ajustar sidebar en móvil */
    .sidebar-mini.sidebar-collapse .main-sidebar {
        margin-left: -280px;
    }
    
    /* Cuando está abierto en móvil */
    .sidebar-mini:not(.sidebar-collapse) .main-sidebar {
        width: 280px !important;
    }
    
    .sidebar-mini:not(.sidebar-collapse) .content-wrapper,
    .sidebar-mini:not(.sidebar-collapse) .main-footer,
    .sidebar-mini:not(.sidebar-collapse) .main-header {
        margin-left: 0 !important;
    }
}

/* Móviles (max-width: 480px) */
@media (max-width: 480px) {
    .content-header h1 {
        font-size: 1.25rem;
    }
    
    .bchatroy {
        bottom: 15px;
        right: 15px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .bchatroy i {
        margin-right: 5px;
    }
    
    .chatroy {
        bottom: 70px;
        right: 15px;
        width: calc(100vw - 30px);
    }
    
    .chatroy .card-body {
        max-height: 300px;
    }
    
    .direct-chat-text {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem;
    }
    
    .user-footer .btn {
        font-size: 0.85rem;
        padding: 6px 16px;
    }
    
    .dropdown-menu {
        font-size: 0.9rem;
    }
}

/* Móviles Pequeños (max-width: 360px) */
@media (max-width: 360px) {
    .bchatroy {
        font-size: 0;
        width: 50px;
        height: 50px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }
    
    .bchatroy i {
        margin: 0;
        font-size: 1.2rem;
    }
    
    .chatroy {
        width: calc(100vw - 20px);
        right: 10px;
    }
}

/* ==========================================
   ORIENTACIÓN LANDSCAPE EN MÓVILES
   ========================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .chatroy .card-body {
        max-height: 200px;
    }
    
    .bchatroy {
        bottom: 10px;
        right: 10px;
    }
    
    .chatroy {
        bottom: 70px;
    }
}

/* ==========================================
   UTILIDADES ADICIONALES
   ========================================== */

/* Animación de carga */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Hover en cards */
.card {
    transition: var(--transition-normal);
    border-radius: var(--border-radius-lg);
    border: none;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

/* Links profesionales */
a {
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    text-decoration: none;
}

/* Botones mejorados */
.btn {
    border-radius: var(--border-radius-md);
    font-weight: 500;
    transition: var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.875rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--info-color) 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--info-color) 0%, var(--secondary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Inputs mejorados */
.form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* ==========================================
   ACCESIBILIDAD
   ========================================== */
*:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

button:focus,
a:focus {
    outline: 2px solid var(--secondary-color);
}

/* ==========================================
   OPTIMIZACIONES DE RENDIMIENTO
   ========================================== */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   DARK MODE SUPPORT (Opcional)
   ========================================== */
@media (prefers-color-scheme: dark) {
    /* Puedes activar esto si deseas soporte para modo oscuro */
    /*
    :root {
        --bg-light: #1a1a1a;
        --bg-white: #2d2d2d;
        --text-dark: #ffffff;
    }
    */
}

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
    .main-sidebar,
    .main-header,
    .main-footer,
    .bchatroy,
    .chatroy {
        display: none !important;
    }
    
    .content-wrapper {
        margin: 0 !important;
    }
}

/* Sidebar profesional: reglas finales para prevalecer sobre AdminLTE. */
:root { --roy-sidebar-width: 300px; --roy-sidebar-collapsed-width: 74px; }

@media (min-width: 769px) {
    .main-sidebar {
        width: var(--roy-sidebar-width) !important;
        overflow: visible !important;
        transition: width .24s ease, box-shadow .24s ease !important;
    }
    .sidebar-mini:not(.sidebar-collapse) .content-wrapper,
    .sidebar-mini:not(.sidebar-collapse) .main-footer,
    .sidebar-mini:not(.sidebar-collapse) .main-header {
        margin-left: var(--roy-sidebar-width) !important;
        transition: margin-left .24s ease !important;
    }
    .sidebar-mini.sidebar-collapse .main-sidebar { width: var(--roy-sidebar-collapsed-width) !important; }
    .sidebar-mini.sidebar-collapse .main-sidebar:hover,
    .sidebar-mini.sidebar-collapse .main-sidebar:focus-within {
        width: var(--roy-sidebar-width) !important;
        box-shadow: 12px 0 30px rgba(9, 24, 39, .28) !important;
    }
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .brand-text,
    .sidebar-mini.sidebar-collapse .main-sidebar:focus-within .brand-text,
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar .nav-link p,
    .sidebar-mini.sidebar-collapse .main-sidebar:focus-within .nav-sidebar .nav-link p {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar > .has-treeview > .nav-treeview,
    .sidebar-mini.sidebar-collapse .main-sidebar:focus-within .nav-sidebar > .has-treeview > .nav-treeview {
        display: none !important;
    }
    /* En modo compacto se abre verticalmente sólo la rama señalada. */
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar > .has-treeview:hover > .nav-treeview,
    .sidebar-mini.sidebar-collapse .main-sidebar:focus-within .nav-sidebar > .has-treeview:focus-within > .nav-treeview {
        display: block !important;
        height: auto !important;
    }
}

/* Distribución real: icono + texto + flecha, sin competir por el ancho. */
.nav-sidebar .nav-link {
    display: flex !important;
    align-items: center;
    gap: 11px;
    min-height: 46px;
    padding: 10px 13px !important;
    white-space: nowrap;
}
.nav-sidebar .nav-link > .nav-icon,
.nav-sidebar .nav-link > i {
    flex: 0 0 24px;
    width: 24px !important;
    margin: 0 !important;
    text-align: center;
}
.nav-sidebar .nav-link > p {
    display: block;
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0;
    margin: 0;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
}
.nav-sidebar .nav-link > p > .right {
    top: 50% !important;
    right: 12px !important;
    transform: translateY(-50%);
}
.nav-sidebar > .nav-item > .nav-link > p { padding-right: 18px; }
.nav-treeview { padding: 3px 6px 7px 17px; }
.nav-treeview .nav-link {
    min-height: 40px;
    margin: 2px 5px;
    padding: 8px 12px !important;
    font-size: .88rem;
}
.nav-treeview .nav-link::before { flex: 0 0 auto; margin-right: 0; }
.nav-treeview .nav-link > p { display: block; white-space: normal; }
.nav-sidebar .nav-link:hover { transform: translateX(3px); }

@media (min-width: 769px) {
    .sidebar-mini.sidebar-collapse .main-sidebar:not(:hover):not(:focus-within) .nav-sidebar > .nav-item > .nav-link {
        justify-content: center;
        margin-left: 8px;
        margin-right: 8px;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    .sidebar-mini.sidebar-collapse .main-sidebar:not(:hover):not(:focus-within) .nav-sidebar .nav-link > p {
        display: none !important;
    }
}
/* Imagen del area de resultados, independiente del contenido del reporte. */
#Tablas.roy-report-background {
    position: relative;
    isolation: isolate;
    min-height: max(360px, calc(100vh - 265px));
    background: transparent;
}
#Tablas.roy-report-background::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: #101c30 url('../Image/roy-report-wallpaper.png') center top / cover no-repeat;
    border-radius: 8px;
    transition: filter .3s ease, opacity .3s ease;
}
#Tablas.roy-report-has-data::before {
    filter: blur(8px);
    opacity: .28;
}
/* Con un modal abierto se quita el aislamiento: si no, los modales de los reportes
   (que viven dentro de #Tablas) quedan debajo del .modal-backdrop del body y no
   se pueden usar (ej. confirmacion de traslados). */
body.modal-open #Tablas.roy-report-background {
    isolation: auto;
}
@media print {
    #Tablas.roy-report-background { min-height: 0; }
    #Tablas.roy-report-background::before { display: none; }
}
