﻿/* ============================================================
   ?? TERRAVIX LAYOUT - Premium Enterprise UX/UI Design
   Dise�o moderno ERP clase mundial inspirado en Dynamics 365
   Colores corporativos Terravix + Material Design 3.0
   Blazor WebAssembly + Radzen Components + Bootstrap 5
   ============================================================ */

/* CSS Variables - Paleta Corporativa Terravix */
:root {
    /* Colores principales Terravix */
    --tvx-primary: #1F7A52;        /* Verde corporativo principal */
    --tvx-primary-light: #2E8B57;  /* Verde claro */
    --tvx-primary-dark: #0E3B2C;   /* Verde oscuro */
    --tvx-secondary: #1E5E46;      /* Verde medio */
    
    /* Superficie y fondos */
    --tvx-surface: #FFFFFF;
    --tvx-surface-variant: #F8FAFC;
    --tvx-surface-container: #F1F5F9;
    --tvx-surface-dim: #E2E8F0;
    
    /* Texto */
    --tvx-on-surface: #0F172A;     /* slate-900 */
    --tvx-on-surface-variant: #475569; /* slate-600 */
    --tvx-on-surface-muted: #64748B;   /* slate-500 */
    
    /* Estados y acciones */
    --tvx-success: #10B981;
    --tvx-warning: #F59E0B;
    --tvx-error: #EF4444;
    --tvx-info: #3B82F6;
    
    /* Bordes y sombras */
    --tvx-border: #E2E8F0;
    --tvx-border-light: #F1F5F9;
    --tvx-shadow-sm: 0 1px 1.6px 0 rgba(0, 0, 0, 0.05);
    --tvx-shadow: 0 3.2px 4.8px -1px rgba(0, 0, 0, 0.1);
    --tvx-shadow-lg: 0 8px 12px -2.4px rgba(0, 0, 0, 0.1);
    --tvx-shadow-xl: 0 16px 20px -4px rgba(0, 0, 0, 0.1);
    
    /* Radius */
    --tvx-radius-sm: 4.8px;
    --tvx-radius: 6.4px;
    --tvx-radius-lg: 9.6px;
    --tvx-radius-xl: 12.8px;
    
    /* Spacing */
    --tvx-space-xs: 0.25rem;
    --tvx-space-sm: 0.5rem;
    --tvx-space: 1rem;
    --tvx-space-lg: 1.5rem;
    --tvx-space-xl: 2rem;
    --tvx-space-2xl: 3rem;
    
    /* Typography */
    --tvx-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --tvx-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ============================================================
   ??? LAYOUT PRINCIPAL - Grid System
   ============================================================ */

.tvx-layout {
    min-height: 100vh;
    display: grid;
    grid-template-areas: 
        "sidebar header"
        "sidebar content";
    grid-template-columns: 224px 1fr;
    grid-template-rows: auto 1fr;
    font-family: var(--tvx-font);
    background: var(--tvx-surface-variant);
    color: var(--tvx-on-surface);
}

/* ============================================================
   ?? HEADER PRINCIPAL - Top Navigation
   ============================================================ */

.tvx-header {
    grid-area: header;
    background: var(--tvx-surface);
    border-bottom: 1px solid var(--tvx-border);
    box-shadow: var(--tvx-shadow-sm);
    z-index: 100;
    position: sticky;
    top: 0;
}

.tvx-header__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--tvx-space-xl);
    height: 57.6px;
}

.tvx-header__brand {
    display: flex;
    align-items: center;
    gap: var(--tvx-space);
}

.tvx-header__logo {
    height: 32px;
    width: auto;
}

.tvx-header__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 35.2px;
    height: 35.2px;
    border-radius: var(--tvx-radius);
    background: transparent;
    border: none;
    color: var(--tvx-on-surface-variant);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tvx-header__toggle:hover {
    background: var(--tvx-surface-container);
    color: var(--tvx-primary);
}

/* ============================================================
   ?? BREADCRUMBS - Navigation Path
   ============================================================ */

.tvx-breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--tvx-space-sm);
    margin: 0;
    padding: 0;
    list-style: none;
}

.tvx-breadcrumb__item {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--tvx-on-surface-muted);
}

.tvx-breadcrumb__link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tvx-breadcrumb__link:hover {
    color: var(--tvx-primary);
}

.tvx-breadcrumb__separator {
    width: 3.2px;
    height: 3.2px;
    border-radius: 50%;
    background: var(--tvx-on-surface-muted);
    margin: 0 var(--tvx-space-sm);
}

.tvx-breadcrumb__item--active {
    color: var(--tvx-on-surface);
    font-weight: 500;
}

/* ============================================================
   ??? TOOLBAR - Header Controls
   ============================================================ */

.tvx-toolbar {
    display: flex;
    align-items: center;
    gap: var(--tvx-space);
}

.tvx-toolbar__section {
    display: flex;
    align-items: center;
    gap: var(--tvx-space-sm);
    padding: 0 var(--tvx-space);
    position: relative;
}

.tvx-toolbar__section:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 19.2px;
    background: var(--tvx-border);
}

.tvx-toolbar__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tvx-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* ============================================================
   ?? SELECTOR BADGES - Company, Field, Season
   ============================================================ */

.tvx-selector-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: var(--tvx-space-xs) !important;
    padding: var(--tvx-space-sm) var(--tvx-space) !important;
    background: linear-gradient(135deg, var(--tvx-primary) 0%, var(--tvx-primary-light) 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: var(--tvx-radius) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: var(--tvx-shadow-sm) !important;
    position: relative !important;
    overflow: hidden !important;
}

.tvx-selector-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border-radius: inherit;
    pointer-events: none;
}

.tvx-selector-badge:hover {
    transform: translateY(-1.6px) !important;
    box-shadow: var(--tvx-shadow-lg) !important;
    background: linear-gradient(135deg, var(--tvx-primary-light) 0%, var(--tvx-primary) 100%) !important;
}

.tvx-selector-badge i,
.tvx-selector-badge .rz-icon {
    font-size: 1.125rem !important;
    opacity: 0.9;
}

/* Dropdown overrides para selectores */
.tvx-selector-dropdown {
    min-width: 160px !important;
    border: 1.6px solid var(--tvx-primary) !important;
    border-radius: var(--tvx-radius) !important;
    box-shadow: var(--tvx-shadow-lg) !important;
}

.tvx-selector-dropdown .rz-dropdown-panel {
    border-radius: var(--tvx-radius) !important;
    box-shadow: var(--tvx-shadow-xl) !important;
    border: 1px solid var(--tvx-border) !important;
}

/* ============================================================
   ?? SIDEBAR - Navigation Menu
   ============================================================ */

.tvx-sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, var(--tvx-primary-dark) 0%, var(--tvx-secondary) 100%);
    color: white;
    overflow-y: auto;
    z-index: 200;
    box-shadow: var(--tvx-shadow-lg);
}

.tvx-sidebar__header {
    padding: var(--tvx-space-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tvx-sidebar__user {
    display: flex;
    align-items: center;
    gap: var(--tvx-space);
    padding: var(--tvx-space);
    margin-bottom: var(--tvx-space);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--tvx-radius-lg);
    transition: all 0.3s ease;
}

.tvx-sidebar__user:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1.6px);
}

.tvx-sidebar__avatar {
    width: 38.4px;
    height: 38.4px;
    border-radius: 50%;
    border: 1.6px solid rgba(255, 255, 255, 0.2);
    object-fit: cover;
}

.tvx-sidebar__user-info {
    flex: 1;
    min-width: 0;
}

.tvx-sidebar__user-name {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    line-height: 1.3;
}

.tvx-sidebar__user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.tvx-sidebar__user-status {
    display: flex;
    align-items: center;
    gap: 3.2px;
    font-size: 0.75rem;
    color: var(--tvx-success);
    margin-top: 1.6px;
}

.tvx-sidebar__status-dot {
    width: 4.8px;
    height: 4.8px;
    border-radius: 50%;
    background: var(--tvx-success);
}

/* ============================================================
   ?? SEARCH - Quick Search
   ============================================================ */

.tvx-search {
    position: relative;
    margin-bottom: var(--tvx-space-lg);
}

.tvx-search__input {
    width: 100%;
    padding: var(--tvx-space) var(--tvx-space) var(--tvx-space) 2.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--tvx-radius);
    color: white;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.tvx-search__input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.tvx-search__input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 2.4px rgba(255, 255, 255, 0.1);
}

.tvx-search__icon {
    position: absolute;
    left: var(--tvx-space);
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
}

/* ============================================================
   ?? MENU NAVIGATION - Dynamic Menu
   ============================================================ */

.tvx-menu {
    padding: 0 var(--tvx-space);
}

.tvx-menu__item {
    margin-bottom: 1.6px;
}

.tvx-menu__link {
    display: flex;
    align-items: center;
    gap: var(--tvx-space);
    padding: var(--tvx-space-sm) var(--tvx-space);
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: var(--tvx-radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tvx-menu__link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.tvx-menu__link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(3.2px);
}

.tvx-menu__link:hover::before {
    left: 100%;
}

.tvx-menu__link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
}

.tvx-menu__link.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2.4px;
    background: white;
    border-radius: 1.6px 0 0 1.6px;
}

.tvx-menu__icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tvx-menu__icon i {
    font-size: 1.125rem;
}

.tvx-menu__title {
    flex: 1;
    font-weight: inherit;
}

.tvx-menu__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    background: var(--tvx-warning);
    color: white;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tvx-menu__arrow {
    transition: transform 0.3s ease;
}

.tvx-menu__item.open .tvx-menu__arrow {
    transform: rotate(90deg);
}

/* Submenu */
.tvx-submenu {
    margin-left: var(--tvx-space-xl);
    margin-top: var(--tvx-space-xs);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: var(--tvx-space);
}

.tvx-submenu .tvx-menu__link {
    font-size: 0.8125rem;
    padding: var(--tvx-space-xs) var(--tvx-space-sm);
}

/* ============================================================
   ?? CONTENT AREA - Main Content
   ============================================================ */

.tvx-content {
    grid-area: content;
    background: var(--tvx-surface);
    padding: 16px 19.2px;
    overflow-y: auto;
    min-height: calc(100vh - 57.6px);
}

.tvx-content__container {
    width: 100%;
    box-sizing: border-box;
}

/* ============================================================
   ?? FOOTER - Bottom Section
   ============================================================ */

.tvx-footer {
    background: var(--tvx-surface);
    border-top: 1px solid var(--tvx-border);
    padding: var(--tvx-space) var(--tvx-space-xl);
    color: var(--tvx-on-surface-muted);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================================
   ?? RESPONSIVE DESIGN
   ============================================================ */

@media (max-width: 1200px) {
    .tvx-layout {
        grid-template-columns: 208px 1fr;
    }
    
    .tvx-toolbar__label {
        display: none;
    }
}

@media (max-width: 992px) {
    .tvx-layout {
        grid-template-areas: 
            "header header"
            "content content";
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .tvx-sidebar {
        position: fixed;
        top: 0;
        left: -224px;
        bottom: 0;
        width: 224px;
        transition: left 0.3s ease;
        z-index: 1000;
    }
    
    .tvx-sidebar.open {
        left: 0;
    }
    
    .tvx-header__toggle {
        display: flex;
    }
    
    .tvx-content {
        min-height: calc(100vh - 57.6px);
    }
}

@media (max-width: 768px) {
    .tvx-header__content {
        padding: 0 var(--tvx-space);
    }
    
    .tvx-toolbar {
        flex-wrap: wrap;
        gap: var(--tvx-space-sm);
    }
    
    .tvx-toolbar__section {
        padding: 0 var(--tvx-space-sm);
    }
    
    .tvx-content {
        padding: var(--tvx-space);
    }
}

@media (max-width: 480px) {
    .tvx-toolbar__section:not(:last-child)::after {
        display: none;
    }
    
    .tvx-selector-badge {
        font-size: 0.75rem !important;
        padding: var(--tvx-space-xs) var(--tvx-space-sm) !important;
    }
}

/* ============================================================
   ?? DARK MODE SUPPORT
   ============================================================ */

@media (prefers-color-scheme: dark) and (max-width: 0px) { /* Tema oscuro deshabilitado: la app siempre usa tema claro */
    :root {
        --tvx-surface: #0F172A;
        --tvx-surface-variant: #1E293B;
        --tvx-surface-container: #334155;
        --tvx-surface-dim: #475569;
        --tvx-on-surface: #F8FAFC;
        --tvx-on-surface-variant: #CBD5E1;
        --tvx-on-surface-muted: #94A3B8;
        --tvx-border: #334155;
        --tvx-border-light: #475569;
    }
}

/* ============================================================
   ? ACCESSIBILITY ENHANCEMENTS
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible enhancements */
.tvx-menu__link:focus-visible,
.tvx-selector-badge:focus-visible,
.tvx-search__input:focus-visible {
    outline: 1.6px solid var(--tvx-primary);
    outline-offset: 1.6px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --tvx-primary: #000000;
        --tvx-on-surface: #000000;
        --tvx-border: #000000;
    }
    
    .tvx-sidebar {
        background: #000000;
    }
    
    .tvx-menu__link {
        border: 1px solid transparent;
    }
    
    .tvx-menu__link:hover,
    .tvx-menu__link.active {
        border-color: white;
    }
}

/* ============================================================
   ?? LOADING STATES & ANIMATIONS
   ============================================================ */

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tvx-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.tvx-slide-in-right {
    animation: slideInRight 0.3s ease forwards;
}

/* Loading spinner */
.tvx-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.tvx-loading::after {
    content: '';
    width: 12.8px;
    height: 12.8px;
    border: 1.6px solid rgba(255, 255, 255, 0.3);
    border-top: 1.6px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
