/* ===== VARIABLES CSS ===== */
:root {
    /* Colores principales */
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    
    /* Colores de estado */
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --error-color: #f56565;
    --info-color: #4299e1;
    
    /* Colores neutros */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Tema claro (default) */
    --bg-primary: var(--white);
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-400);
    --border-color: var(--gray-200);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --card-bg: var(--white);
    
    /* Espaciado */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Bordes */
    --border-radius-sm: 0.375rem;
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;
    --border-radius-xl: 1rem;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 var(--shadow-color);
    --shadow: 0 1px 3px 0 var(--shadow-color), 0 1px 2px 0 var(--shadow-color);
    --shadow-md: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
    --shadow-lg: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -2px var(--shadow-color);
    --shadow-xl: 0 20px 25px -5px var(--shadow-color), 0 10px 10px -5px var(--shadow-color);
    
    /* Transiciones */
    --transition-fast: 150ms ease-in-out;
    --transition: 200ms ease-in-out;
    --transition-slow: 300ms ease-in-out;
    
    /* Typography */
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', Consolas, monospace;
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal: 1040;
    --z-popover: 1050;
    --z-tooltip: 1060;
}

/* Tema oscuro */
[data-theme="dark"] {
    --bg-primary: var(--gray-900);
    --bg-secondary: var(--gray-800);
    --bg-tertiary: var(--gray-700);
    --text-primary: var(--gray-100);
    --text-secondary: var(--gray-300);
    --text-muted: var(--gray-500);
    --border-color: var(--gray-700);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-bg: var(--gray-800);
}

/* ===== RESET Y BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    transition: color var(--transition), background-color var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===== UTILIDADES ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-lg);
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: var(--space-lg) 0;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-md);
}

.header__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header__icon {
    width: 2.5rem;
    height: 2.5rem;
    opacity: 0.9;
}

.header__title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.theme-toggle,
.view-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transition: all var(--transition);
    backdrop-filter: blur(10px);
}

.theme-toggle:hover,
.view-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.theme-toggle__icon,
.view-toggle__icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* ===== NAVEGACIÓN ===== */
.nav {
    background: var(--bg-primary);
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--border-color);
}

.nav__content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

@media (min-width: 768px) {
    .nav__content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Barra de búsqueda */
.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box__icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box__input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition);
}

.search-box__input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-box__clear {
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition);
}

.search-box__input:not(:placeholder-shown) + .search-box__clear {
    opacity: 1;
}

.search-box__clear:hover {
    color: var(--text-secondary);
}

/* Filtros */
.filters {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-select {
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 150px;
    transition: all var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== MAIN CONTENT ===== */
.main {
    flex: 1;
    padding: var(--space-2xl) 0;
}

/* Estadísticas */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: var(--card-bg);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow);
    transition: all var(--transition);
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card__icon {
    width: 3rem;
    height: 3rem;
    padding: var(--space-md);
    border-radius: var(--border-radius-lg);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.stat-card__content {
    display: flex;
    flex-direction: column;
}

.stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card__label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Sección de dashboards */
.dashboards-section {
    animation-delay: 0.2s;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-title i {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--primary-color);
}

.results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius);
    font-weight: 500;
}

/* Estados de carga */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-2xl);
}

.loading__spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading__text {
    color: var(--text-secondary);
    font-weight: 500;
}

.error-message,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-2xl);
    text-align: center;
}

.error-message i,
.empty-state i {
    width: 4rem;
    height: 4rem;
    color: var(--text-muted);
}

.error-message {
    color: var(--error-color);
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: var(--space-sm);
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
}

/* Grid de dashboards */
.dashboards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.dashboards-grid--list {
    grid-template-columns: 1fr;
}

/* Cards de dashboard */
.dashboard-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.5s ease-out backwards;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.dashboard-card__header {
    padding: var(--space-xl);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    position: relative;
    overflow: hidden;
}

.dashboard-card__header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(30px, -30px);
}

.dashboard-card__date {
    font-size: 0.75rem;
    opacity: 0.8;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.dashboard-card__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.dashboard-card__subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

.dashboard-card__body {
    padding: var(--space-xl);
}

.dashboard-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.dashboard-card__filename {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--border-radius-sm);
}

.dashboard-card__size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dashboard-card__description {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

.dashboard-card__actions {
    display: flex;
    gap: var(--space-sm);
}

.dashboard-card__button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all var(--transition);
}

.dashboard-card__button--primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.dashboard-card__button--primary:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.dashboard-card__button--secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.dashboard-card__button--secondary:hover {
    background: var(--border-color);
}

.dashboard-card__button i {
    width: 1rem;
    height: 1rem;
}

/* Vista de lista */
.dashboard-card--list {
    display: flex;
    flex-direction: row;
}

.dashboard-card--list .dashboard-card__header {
    min-width: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dashboard-card--list .dashboard-card__body {
    flex: 1;
    display: flex;
    align-items: center;
}

.dashboard-card--list .dashboard-card__actions {
    margin-left: auto;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: var(--space-xl) 0;
    margin-top: auto;
}

.footer__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.footer__text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer__links {
    display: flex;
    gap: var(--space-md);
}

.footer__button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all var(--transition);
}

.footer__button:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.footer__button i {
    width: 1rem;
    height: 1rem;
}

/* ===== ANIMACIONES ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-stagger > * {
    animation-delay: calc(var(--animation-order, 0) * 0.1s);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767px) {
    .header__title {
        font-size: 1.25rem;
    }
    
    .header__icon {
        width: 2rem;
        height: 2rem;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
    
    .dashboards-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-card--list {
        flex-direction: column;
    }
    
    .dashboard-card--list .dashboard-card__header {
        min-width: auto;
    }
    
    .dashboard-card--list .dashboard-card__body {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dashboard-card--list .dashboard-card__actions {
        margin-left: 0;
        margin-top: var(--space-md);
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .footer__content {
        flex-direction: column;
        text-align: center;
    }
}

/* ===== ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para navegación por teclado */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Mejores contrastes para tema oscuro */
[data-theme="dark"] .dashboard-card__button--secondary {
    background: var(--gray-700);
    border-color: var(--gray-600);
}

[data-theme="dark"] .dashboard-card__button--secondary:hover {
    background: var(--gray-600);
}

/* Enlaces rápidos */
.links-section {
    margin-bottom: var(--space-lg);
}

.links-list {
    display: block;
}

.links-list-inner {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: stretch;
}

.simple-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: .6rem;
    min-width: 220px;
    max-width: 420px;
    color: var(--text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    overflow: hidden;
}

.simple-link:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(90deg, rgba(102,126,234,0.06), rgba(118,75,162,0.03));
}

.link-left {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    flex: 0 0 36px;
}

.link-icon,
.link-external {
    width: 1rem;
    height: 1rem;
}

.link-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.link-filename {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.link-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .links-list-inner {
        gap: .4rem;
    }
    .simple-link {
        min-width: 100%;
        max-width: 100%;
    }
}