/* ============================================
   VARIABLES GLOBALES
   ============================================ */
:root {
    /* Colores del tema */
    --color-primary: #036647;
    --color-primary-light: #d1fae5;
    --color-primary-dark: #022c22;
    
    --color-secondary: #11805c;
    --color-secondary-dark: #021813;
    
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    
    /* Color titulos y encabezados */
    --color-heading: #064e3b;

    /* Colores de texto */
    --color-text-primary: #111827;
    --color-text-secondary: #6b7280;
    --color-text-light: #d1fae5;

    /* Grises */
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-700: #374151;
    --color-gray-900: #111827;
    
    /* Espaciado */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Bordes */
    --border-radius-sm: 0.375rem;
    --border-radius-md: 0.5rem;
    --border-radius-lg: 0.75rem;
    --border-radius-full: 9999px;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Transiciones */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 200ms ease-in-out;
    --transition-slow: 300ms ease-in-out;

    /* Altura navbar */
    --navbar-height: 4rem;
}

/* ============================================
   RESET Y ESTILOS BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: #f9fafb;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Clase para screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    background: var(--color-primary);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--navbar-height);
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.navbar-container {
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

/* Logo y Marca */
.navbar-brand-wrapper {
    flex: 0 0 auto;
    display: flex;
}

.navbar-logo-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.navbar-logo {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    object-fit: contain;
}

.navbar-brand {
    color: var(--color-text-light);
    font-weight: 700;
    font-size: 0.875rem;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity var(--transition-base);
}

.navbar-brand:hover {
    opacity: 0.8;
}

/* Título del Producto */
.navbar-title-wrapper {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0; /* Permite que se encoja */
}

.navbar-product-title {
    color: var(--color-text-light);
    font-size: 0.875rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Selector de Idioma */
.navbar-language-wrapper {
    flex: 0 0 auto;
}

.language-form {
    position: relative;
    display: flex;
    align-items: center;
}

.language-select {
    appearance: none;
    background: transparent;
    border: 1px solid rgba(209, 250, 229, 0.3);
    border-radius: 0.375rem;
    color: var(--color-text-light);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.language-select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(209, 250, 229, 0.5);
}

.language-select:focus {
    outline: none;
    border-color: var(--color-text-light);
    box-shadow: 0 0 0 3px rgba(209, 250, 229, 0.2);
}

.language-select option {
    background: var(--color-primary);
    color: var(--color-text-light);
}

.language-icon {
    position: absolute;
    right: 0.5rem;
    width: 1rem;
    height: 1rem;
    pointer-events: none;
    color: var(--color-text-light);
    opacity: 0.7;
}

/* Botón Mobile Menu */
.navbar-mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--color-text-light);
    padding: 0.5rem;
    cursor: pointer;
    transition: opacity var(--transition-base);
}

.navbar-mobile-toggle:hover {
    opacity: 0.8;
}

.menu-icon {
    width: 1.5rem;
    height: 1.5rem;
    stroke: var(--color-text-light);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* Menú de navegación desktop */
.navbar-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.navbar-link {
    color: var(--color-text-light);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.navbar-link:hover {
    background: rgba(209, 250, 229, 0.2);
}

/* Acciones del navbar (usuario + idioma + mobile menu) */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Botón de usuario */
.navbar-user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 50%;
    transition: all var(--transition-base);
    border: 2px solid transparent;
}

.navbar-user-btn:hover {
    border-color: rgba(239, 68, 68, 0.5);
}

.navbar-user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
}

/* Menú Mobile */
.navbar-mobile-menu {
    background: var(--color-primary-dark);
    padding: var(--spacing-md);
    border-top: 1px solid rgba(209, 250, 229, 0.2);
}

.navbar-mobile-link {
    display: block;
    color: var(--color-text-light);
    text-decoration: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 500;
    transition: background var(--transition-base);
}

.navbar-mobile-link:hover {
    background: rgba(209, 250, 229, 0.1);
}

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */
.main-content {
    flex: 1 0 auto;
    padding-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    flex-shrink: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--spacing-xl) var(--spacing-md);
    z-index: 950;
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.footer-logo {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
}

.footer-brand-name {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.footer-copyright {
    font-size: 0.75rem;
    color: rgba(209, 250, 229, 0.8);
    text-align: center;
}



/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 768px) {
    .navbar-container {
        padding: 0 var(--spacing-md);
    }

    .navbar-product-title {
        font-size: 0.75rem;
    }

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

    .language-select {
        font-size: 0.75rem;
        padding: 0.25rem 1.75rem 0.25rem 0.5rem;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 640px) {
    :root {
        --navbar-height: 3.5rem;
    }

    .navbar-mobile-toggle {
        display: block;
    }

    .navbar-title-wrapper {
        display: none;
    }

    .navbar-language-wrapper {
        margin-right: var(--spacing-sm);
    }

    .language-select {
        border: none;
        padding: 0.25rem 1.5rem 0.25rem 0.25rem;
    }

    .language-icon {
        right: 0.25rem;
    }

    .footer-content {
        padding: var(--spacing-md) 0;
    }

    .footer-copyright {
        font-size: 0.7rem;
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.navbar {
    animation: fadeIn 0.3s ease-out;
}

/* ============================================
   UTILIDADES
   ============================================ */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Focus visible para accesibilidad */
*:focus-visible {
    outline: 2px solid var(--color-text-light);
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE - ACTUALIZACIONES
   ============================================ */
@media (max-width: 1024px) {
    .navbar-menu {
        display: none;
    }
    
    .navbar-link {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
}

@media (max-width: 768px) {
    .navbar-logo {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .navbar-user-avatar {
        width: 1.75rem;
        height: 1.75rem;
    }
}

@media (max-width: 640px) {
    .navbar-brand {
        display: none;
    }
    
    .navbar-actions {
        gap: 0.25rem;
    }
}


/* ============================================
   SIDEBAR
   ============================================ */

/* Contenedor del sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--navbar-height);
    bottom: 0;
    width: 270px;
    background: white;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-base);
    z-index: 900;
    display: flex;
    flex-direction: column;
}

/* Scrollbar personalizada para el sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Header del sidebar */
.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: white;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-title-icon {
    width: 1rem;
    height: 1rem;
    color: var(--color-primary);
    flex-shrink: 0;
}

/* Navegación del sidebar */
.sidebar-nav {
    flex: 1;
    padding: var(--spacing-sm) 0;
    overflow-y: auto;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin: 0;
}

/* Título de sección */
.sidebar-section-title {
    padding: var(--spacing-md) var(--spacing-lg) var(--spacing-xs);
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    list-style: none;
}

/* Enlaces del sidebar */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: var(--color-text-primary);
    border-left-color: #e5e7eb;
}

.sidebar-link:hover .sidebar-link-icon {
    color: var(--color-primary);
}

/* Link activo */
.sidebar-link--active {
    background: #ecfdf5;
    color: var(--color-primary);
    font-weight: 600;
    border-left-color: var(--color-primary);
}

.sidebar-link--active .sidebar-link-icon {
    color: var(--color-primary);
}

/* Link de logout especial */
.sidebar-link--logout {
    color: #dc2626;
}

.sidebar-link--logout:hover {
    background: #fef2f2;
    border-left-color: #dc2626;
}

.sidebar-link--logout .sidebar-link-icon {
    color: #dc2626;
}

/* Ícono del link */
.sidebar-link-icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: color var(--transition-base);
}

.sidebar-link-icon svg {
    width: 100%;
    height: 100%;
}

/* Texto del link */
.sidebar-link-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badge de notificaciones */
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    background: var(--color-primary);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 0.625rem;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-badge--warning {
    background: #f59e0b;
}

.sidebar-badge--danger {
    background: #dc2626;
}

.sidebar-badge--info {
    background: #3b82f6;
}

/* Divisor */
.sidebar-divider {
    height: 1px;
    background: #e5e7eb;
    margin: var(--spacing-md) var(--spacing-lg);
    list-style: none;
}

/* Footer del sidebar */
.sidebar-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    background: white;
}

/* ============================================
   OVERLAY Y TOGGLE MOBILE
   ============================================ */

/* Overlay para mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 899;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-base);
    backdrop-filter: blur(2px);
}

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

/* Botón toggle mobile */
.sidebar-toggle {
    width: 3.5rem;
    height: 3.5rem;
    border: none;
    cursor: pointer;
    z-index: 901;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    background: none;
}

.sidebar-toggle:hover {
    background: #047857;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(3, 102, 71, 0.5);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.sidebar-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

.sidebar-toggle-icon {
    width: 1.5rem;
    height: 1.5rem;
}

/* ============================================
   LAYOUT CON SIDEBAR
   ============================================ */

.layout-with-sidebar {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    padding-top: var(--navbar-height);
}

.sidebar ~ .main-content,
.layout-with-sidebar .main-content {
    margin-left: 270px;
    margin-top: var(--navbar-height);
    flex: 1;
    padding: var(--spacing-md);
    background: #f9fafb;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left var(--transition-base);
}

/* ============================================
   ESTADOS DEL SIDEBAR
   ============================================ */

/* Sidebar colapsado */
.sidebar.collapsed {
    width: 4rem;
}

.sidebar.collapsed .sidebar-link-text,
.sidebar.collapsed .sidebar-badge,
.sidebar.collapsed .sidebar-title span {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: var(--spacing-sm);
}

.sidebar.collapsed .sidebar-link-icon {
    width: 2rem;
    height: 2rem;
}

/* ============================================
   ANIMACIONES DEL SIDEBAR
   ============================================ */

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutToLeft {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}

.sidebar.mobile-open {
    animation: slideInFromLeft 0.3s ease-out;
}

/* ============================================
   RESPONSIVE - TABLET (max-width: 1024px)
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar ~ .main-content,
    .layout-with-sidebar .main-content {
        margin-left: 0;
    }
    
    .sidebar-toggle {
        display: flex;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (max-width: 640px)
   ============================================ */

@media (max-width: 640px) {
    .sidebar {
        width: 280px;
        max-width: 85vw;
    }
    
    .sidebar-toggle {
        width: 3rem;
        height: 3rem;
        bottom: 1rem;
        right: 1rem;
    }
    
    .sidebar-toggle-icon {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    .sidebar-header {
        padding: var(--spacing-md);
    }
    
    .sidebar-link {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.8125rem;
    }
    
    .sidebar-link-icon {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    .sidebar-section-title {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .sidebar-divider {
        margin: var(--spacing-sm) var(--spacing-md);
    }
}

/* ============================================
   MODO OSCURO (opcional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .sidebar {
        background: #1f2937;
        border-right-color: #374151;
    }
    
    .sidebar-header {
        background: #1f2937;
        border-bottom-color: #374151;
    }
    
    .sidebar-title {
        color: #9ca3af;
    }
    
    .sidebar-section-title {
        color: #9ca3af;
    }
    
    .sidebar-link {
        color: #d1d5db;
    }
    
    .sidebar-link:hover {
        background: #374151;
        color: #f9fafb;
    }
    
    .sidebar-link--active {
        background: rgba(3, 102, 71, 0.2);
        color: #6ee7b7;
    }
    
    .sidebar-divider {
        background: #374151;
    }
    
    .sidebar-footer {
        background: #1f2937;
        border-top-color: #374151;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

/* Mejorar visibilidad de focus en sidebar */
.sidebar-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    z-index: 1;
}

/* Reducir movimiento para usuarios con preferencias */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-link,
    .sidebar-toggle,
    .sidebar-overlay {
        transition: none;
    }
    
    .sidebar.mobile-open {
        animation: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .sidebar,
    .sidebar-toggle,
    .sidebar-overlay {
        display: none !important;
    }
    
    .sidebar ~ .main-content,
    .layout-with-sidebar .main-content {
        margin-left: 0 !important;
    }
}

/* ============================================
   ESTADOS DE HOVER MEJORADOS
   ============================================ */

/* Efecto ripple en click (opcional) */
.sidebar-link {
    position: relative;
    overflow: hidden;
}

.sidebar-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(3, 102, 71, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.sidebar-link:active::before {
    width: 300px;
    height: 300px;
}

/* Indicador de carga para links (opcional) */
.sidebar-link.loading {
    pointer-events: none;
    opacity: 0.6;
}

.sidebar-link.loading::after {
    content: '';
    position: absolute;
    right: var(--spacing-md);
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   UTILIDADES ESPECÍFICAS DEL SIDEBAR
   ============================================ */

/* Clase helper para ocultar sidebar en ciertas páginas */
.no-sidebar .sidebar,
.no-sidebar .sidebar-toggle,
.no-sidebar .sidebar-overlay {
    display: none !important;
}

.no-sidebar .main-content {
    margin-left: 0 !important;
}

/* Clase helper para sidebar siempre visible */
.sidebar-always-visible .sidebar {
    transform: translateX(0) !important;
}

/* ...existing code... */