﻿/* ✅ RESPONSIVE LAYOUT - Sin colores, solo estructura */

/* Variables de layout (no colores) */
:root {
    --sidebar-width: 250px;
    --sidebar-mobile-width: 280px;
    --header-height: 3.5rem;
    --mobile-breakpoint: 768px;
}

/* Estructura base */
.layout-container {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.top-header {
    height: var(--header-height);
    position: relative;
    z-index: 1030;
    flex-shrink: 0;
}

/* Contenedor principal flexible */
.main-content-wrapper {
    display: flex;
    height: calc(100vh - var(--header-height));
    position: relative;
    overflow: hidden;
}

/* Sidebar desktop */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
    flex-shrink: 0;
}

/* Área de contenido */
.content-area {
    flex: 1;
    overflow-y: auto;
    min-width: 0; /* Previene overflow en flex */
    height: 100%;
}

/* ✅ MOBILE RESPONSIVE */
@media (max-width: 767px) {
    /* Header sticky en móvil */
    .top-header {
        position: sticky;
        top: 0;
        z-index: 1030;
    }

    /* Sidebar móvil como overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-mobile-width);
        height: 100vh;
        z-index: 1040;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

        /* Sidebar visible */
        .sidebar.show {
            transform: translateX(0);
        }

    /* Overlay oscuro */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }

        .sidebar-overlay.show {
            display: block;
            opacity: 1;
        }

    /* Contenido ocupa todo el ancho en móvil */
    .content-area {
        width: 100%;
        margin-left: 0 !important;
    }

    /* Botón hamburguesa */
    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-right: 0.5rem;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0.25rem;
        position: relative;
        z-index: 1031;
    }

        .mobile-menu-toggle:focus {
            outline: none;
            box-shadow: none;
        }

        .mobile-menu-toggle i {
            font-size: 1.5rem;
        }

    /* Ajustes de padding */
    .content-area {
        padding: 1rem;
    }

    /* Prevenir scroll del body cuando menú abierto */
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* Desktop - ocultar elementos móviles */
@media (min-width: 768px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* ✅ UTILIDADES RESPONSIVE */
/* Ocultar en móvil */
@media (max-width: 575px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Ocultar en tablet */
@media (max-width: 991px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Solo móvil */
@media (min-width: 576px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* ✅ AJUSTES DE TEXTO Y COMPONENTES RESPONSIVE */
@media (max-width: 767px) {
    /* Texto más pequeño en móvil */
    .user-email {
        display: none;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    /* Cards más compactas */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Tablas responsive */
    .table-responsive {
        font-size: 0.875rem;
    }

    /* Botones más pequeños */
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }

    /* Dropdown menu ajustado */
    .dropdown-menu {
        font-size: 0.875rem;
    }

    /* Badges más pequeños */
    .badge {
        font-size: 0.75rem;
    }
}

/* ✅ PANTALLAS MUY PEQUEÑAS */
@media (max-width: 374px) {
    .sidebar {
        width: 250px;
        left: -250px;
    }

        .sidebar.show {
            left: 0;
            transform: none;
        }

    .top-header {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .content-area {
        padding: 0.5rem;
    }

    /* Ocultar más elementos en pantallas muy pequeñas */
    .hide-xs {
        display: none !important;
    }
}

/* ✅ SCROLL IMPROVEMENTS */
/* Mejor scroll en iOS */
.sidebar,
.content-area {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

    /* Scrollbar personalizado (sin colores específicos) */
    .sidebar::-webkit-scrollbar,
    .content-area::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    .sidebar::-webkit-scrollbar-track,
    .content-area::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
    }

    .sidebar::-webkit-scrollbar-thumb,
    .content-area::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
    }

        .sidebar::-webkit-scrollbar-thumb:hover,
        .content-area::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.3);
        }

/* ✅ ANIMACIONES SUAVES */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ✅ AJUSTES PARA LANDSCAPE MÓVIL */
@media (max-width: 767px) and (orientation: landscape) {
    .top-header {
        height: 3rem;
    }

    .main-content-wrapper {
        height: calc(100vh - 3rem);
    }

    .content-area {
        padding: 0.5rem;
    }
}

/* ✅ PRINT STYLES */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .sidebar-overlay {
        display: none !important;
    }

    .content-area {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .top-header {
        position: static;
        page-break-after: avoid;
    }
}

/* ✅ ACCESIBILIDAD */
/* Focus visible para teclado */
.mobile-menu-toggle:focus-visible,
.sidebar a:focus-visible,
.sidebar button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Reducir movimiento si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-overlay,
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ✅ FIXES ESPECÍFICOS */
/* Fix para contenido que se desborda */
.content-area > * {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Fix para imágenes responsive */
.content-area img {
    max-width: 100%;
    height: auto;
}

/* Fix para tablas largas */
.content-area .table-responsive {
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

/* Fix para modales en móvil */
@media (max-width: 575px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 0.25rem;
    }
}
