/**
 * Dashboard VoiceBot ILUMNO v4.0
 * Base CSS - Reset y utilidades
 */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--surface-bg);
    height: 100vh;
    overflow: hidden;
}

/* ========================================
   LAYOUT PRINCIPAL - ZERO SCROLL
   ======================================== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    height: 100vh;
    overflow: hidden;
    transition: margin-left var(--transition-normal);
}

.main-wrapper {
    flex: 1;
    padding: var(--space-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Tab content debe ocupar el espacio disponible */
.tab-content {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-content.active {
    display: flex;
}

/* Overview layout */
#tab-overview {
    display: none;
    flex-direction: column;
    gap: var(--space-sm);
    overflow-y: auto;
    overflow-x: hidden;
}

#tab-overview.active {
    display: flex;
}

/* Métricas y gráficos deben ajustarse */
.metrics-grid {
    flex-shrink: 0;
}

.charts-grid {
    flex: 1;
    min-height: 280px;
}

/* En desktop grande, preferir overflow auto para permitir scroll si es necesario */
@media (min-width: 1200px) and (min-height: 800px) {
    .tab-content,
    #tab-overview {
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* ========================================
   UTILIDADES - Display
   ======================================== */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* ========================================
   UTILIDADES - Flexbox
   ======================================== */
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ========================================
   UTILIDADES - Texto
   ======================================== */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

/* ========================================
   BOTONES
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-accent);
    color: white;
    border: none;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--color-accent);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--border-radius);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   INPUTS
   ======================================== */
input, select, textarea {
    font-family: inherit;
    font-size: var(--font-size-sm);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
select,
textarea {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-card);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   LOADING
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    gap: var(--space-md);
}

.dark-mode .loading-overlay {
    background: rgba(15, 23, 42, 0.9);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   ANIMACIONES
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from { 
        opacity: 0;
        transform: scale(0.9);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fadeIn { animation: fadeIn var(--transition-normal); }
.animate-slideUp { animation: slideUp var(--transition-normal); }
.animate-slideDown { animation: slideDown var(--transition-normal); }
.animate-scaleIn { animation: scaleIn var(--transition-normal); }
.animate-pulse { animation: pulse 2s infinite; }

/* ========================================
   LINKS
   ======================================== */
a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-dark);
}

/* ========================================
   IMAGES
   ======================================== */
img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   SELECTION
   ======================================== */
::selection {
    background: var(--color-accent);
    color: white;
}

/* ========================================
   MOBILE SCROLL FIX
   Permite scroll vertical en dispositivos móviles
   mientras mantiene zero-scroll en desktop
   ======================================== */
@media (max-width: 768px) {
    body,
    .app-layout,
    .main-content,
    .main-wrapper {
        overflow: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: 100vh;
    }
    
    .tab-content {
        overflow: visible !important;
        height: auto !important;
    }
    
    .tab-content.active {
        overflow: visible !important;
        height: auto !important;
    }
}

/* ========================================
   TABLET SCROLL FIX
   ======================================== */
@media (max-width: 1023px) and (min-width: 769px) {
    body,
    .app-layout,
    .main-content,
    .main-wrapper {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}