/* ==========================================================================
   DESIGN SYSTEM — Ensenyem ERP
   Modernización global de UI/UX
   Auto-cargado por AssetLoader
   ========================================================================== */

/* ==========================================================================
   1. EXTENDED DESIGN TOKENS
   ========================================================================== */
:root {
    /* Motion System — Transiciones coherentes para todo el producto */
    --transition-fast: 120ms ease-out;
    --transition-base: 200ms ease-out;
    --transition-slow: 280ms ease-out;
    --transition-spring: 320ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Elevation System — Profundidad visual progresiva */
    --elevation-0: none;
    --elevation-1: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --elevation-2: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --elevation-3: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --elevation-4: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

    /* Status Accent Colors — Barras laterales de estado */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #3b82f6;
    --status-pending: #8b5cf6;
    --status-neutral: #94a3b8;

    /* Focus Ring — Accesibilidad moderna */
    --focus-ring: 0 0 0 2px white, 0 0 0 4px var(--primary-400);
    --focus-ring-inset: inset 0 0 0 2px var(--primary-400);

    /* Border Radius Extended */
    --border-radius-xl: 1rem;
    --border-radius-full: 9999px;

    /* Spacing Scale Extended */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
}


/* ==========================================================================
   2. GLOBAL INTERACTIVE TRANSITIONS
   Aplicar movimiento consistente a todos los elementos interactivos
   ========================================================================== */

/* Botones — transición unificada */
.btn {
    transition: 
        background-color var(--transition-fast),
        border-color var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-base),
        transform var(--transition-fast);
}

/* Cards — elevación suave */
.card,
.stat-card,
.action-card,
.contact-card {
    transition: 
        box-shadow var(--transition-base),
        transform var(--transition-base),
        border-color var(--transition-base);
}

/* Links */
a,
.sidebar__nav-link,
.sidebar__submenu-link {
    transition: 
        color var(--transition-fast),
        background-color var(--transition-fast),
        transform var(--transition-fast);
}

/* Badges */
.badge {
    transition: 
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
    transition: 
        border-color var(--transition-fast),
        box-shadow var(--transition-base),
        background-color var(--transition-fast);
}


/* ==========================================================================
   3. BUTTON HIERARCHY — Solid / Outline / Ghost
   ========================================================================== */

/* Primary — dominante, acción principal */
.btn--primary {
    box-shadow: 0 1px 2px rgba(130, 3, 3, 0.2);
}

.btn--primary:hover {
    box-shadow: 0 4px 12px rgba(130, 3, 3, 0.25);
    transform: translateY(-1px);
}

.btn--primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(130, 3, 3, 0.2);
}

/* Secondary — outline, acción secundaria */
.btn--secondary {
    box-shadow: var(--elevation-1);
}

.btn--secondary:hover {
    box-shadow: var(--elevation-2);
    transform: translateY(-1px);
}

.btn--secondary:active {
    transform: translateY(0);
}

/* Ghost — terciaria, sin fondo */
.btn--ghost:active {
    transform: scale(0.98);
}

/* Success — con elevación */
.btn--success {
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.2);
}

.btn--success:hover {
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
    transform: translateY(-1px);
}

.btn--danger {
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.2);
}

.btn--danger:hover {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
    transform: translateY(-1px);
}

/* Outline variant (nuevo) */
.btn--outline-primary {
    background-color: transparent;
    color: var(--primary-500);
    border: 1.5px solid var(--primary-300);
}

.btn--outline-primary:hover {
    background-color: var(--primary-50);
    border-color: var(--primary-500);
    color: var(--primary-700);
}

.btn--outline-danger {
    background-color: transparent;
    color: var(--danger-text);
    border: 1.5px solid var(--danger-border);
}

.btn--outline-danger:hover {
    background-color: var(--danger-bg);
    border-color: var(--danger-text);
}

/* Tamaño consistente */
.btn {
    min-height: 36px;
}

.btn--large {
    min-height: 44px;
}

.btn--small {
    min-height: 28px;
}

/* Ripple container */
.btn {
    position: relative;
    overflow: hidden;
}

.btn__ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple-effect 500ms ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-effect {
    to {
        transform: scale(2.5);
        opacity: 0;
    }
}


/* ==========================================================================
   4. TABLE ROWS — Elevación interactiva + borde de estado
   ========================================================================== */

/* Row hover mejorado */
tbody tr {
    transition: 
        background-color var(--transition-fast),
        box-shadow var(--transition-base);
    position: relative;
}

tbody tr:hover {
    background-color: var(--gray-50);
    box-shadow: inset 0 0 0 1px var(--gray-100);
}

/* Status border left en filas */
tr[data-status="sent"] td:first-child,
tr[data-status="cobrado"] td:first-child,
tr[data-status="completado"] td:first-child,
tr[data-status="confirmado"] td:first-child {
    box-shadow: inset 3px 0 0 var(--status-success);
}

tr[data-status="pending"] td:first-child,
tr[data-status="pendiente"] td:first-child,
tr[data-status="borrador"] td:first-child {
    box-shadow: inset 3px 0 0 var(--status-warning);
}

tr[data-status="error"] td:first-child,
tr[data-status="cancelado"] td:first-child,
tr[data-status="anulado"] td:first-child {
    box-shadow: inset 3px 0 0 var(--status-danger);
}

tr[data-status="emitido"] td:first-child,
tr[data-status="programado"] td:first-child {
    box-shadow: inset 3px 0 0 var(--status-info);
}

/* Row actions — más visible en hover */
.table__actions {
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

tbody tr:hover .table__actions {
    opacity: 1;
}


/* ==========================================================================
   5. BADGES MODERNOS — Con iconos y profundidad
   ========================================================================== */

/* Badge base mejorado */
.badge {
    gap: 0.25rem;
    letter-spacing: 0.01em;
}

/* Badge con icono */
.badge__icon {
    font-size: 0.75em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* Badge pulse — cuando cambia estado */
.badge--pulse {
    animation: badge-pulse 1.5s ease-in-out;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.08); }
    50% { transform: scale(1); }
    75% { transform: scale(1.04); }
}


/* ==========================================================================
   6. KPI / STAT CARDS — Profundidad + iconos circulares
   ========================================================================== */

/* KPI card con sombra en reposo */
.stat-card {
    box-shadow: var(--elevation-1);
    border: 1px solid var(--gray-100);
}

/* Icono con círculo de fondo más definido */
.stat-card__icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.4rem;
}

/* Número grande */
.stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

/* Label más pequeño y separado */
.stat-card__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Count up animation */
.stat-card__value[data-animate] {
    opacity: 0;
    transform: translateY(8px);
    animation: count-reveal 0.5s ease-out forwards;
    animation-delay: var(--delay, 0ms);
}

@keyframes count-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ==========================================================================
   7. SIDEBAR — Indicador activo + hover mejorado
   ========================================================================== */

/* Estado activo limpio sin barra vertical */
.sidebar__nav-link.is-active,
.sidebar__submenu-link.is-active {
    position: relative;
    background-color: var(--primary-50);
    color: var(--primary-700);
}

/* Hover con desplazamiento sutil */
.sidebar__nav-link:hover {
    transform: translateX(2px);
}

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

/* Submenu links — hover más suave */
.sidebar__submenu-link {
    position: relative;
    transition:
        color var(--transition-fast),
        background-color var(--transition-fast),
        padding-left var(--transition-fast);
}

.sidebar__submenu-link:hover {
    padding-left: calc(2.25rem + 4px);
    background-color: var(--gray-50);
}

/* Iconos sidebar ligeramente más grandes */
.sidebar__nav-icon {
    font-size: 1.2rem;
    transition: color var(--transition-fast);
}

/* Group title — tracking leve */
.sidebar__group-title {
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-bottom: 0.25rem;
}


/* ==========================================================================
   8. INPUTS MODERNOS — Estilo "app moderna"
   ========================================================================== */

/* Input con fondo gris suave */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
    background-color: var(--gray-50);
    border: 1.5px solid transparent;
}

/* Borde solo en focus */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    background-color: white;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(130, 3, 3, 0.08);
}

/* Hover state para inputs */
input[type="text"]:hover:not(:focus),
input[type="email"]:hover:not(:focus),
input[type="password"]:hover:not(:focus),
input[type="date"]:hover:not(:focus),
input[type="number"]:hover:not(:focus),
input[type="search"]:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--gray-300);
}

/* Search input con icono integrado */
.input-search {
    position: relative;
}

.input-search__icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1rem;
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-search input,
.input-search .input-search__field {
    padding-left: 2.5rem;
}

.input-search:focus-within .input-search__icon {
    color: var(--primary-500);
}


/* ==========================================================================
   9. EXPANDABLE BLOCKS — Fade + Slide
   ========================================================================== */

/* Animación genérica para contenido expandible */
.expand-enter {
    animation: expand-in var(--transition-slow) ease-out forwards;
}

.expand-exit {
    animation: expand-out var(--transition-fast) ease-in forwards;
}

@keyframes expand-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 2000px;
    }
}

@keyframes expand-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* Fade in genérico para paneles */
.fade-in {
    animation: ds-fade-in 0.3s ease-out forwards;
}

@keyframes ds-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation para listas */
.stagger-item {
    opacity: 0;
    animation: ds-fade-in 0.3s ease-out forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }
.stagger-item:nth-child(5) { animation-delay: 200ms; }
.stagger-item:nth-child(6) { animation-delay: 250ms; }
.stagger-item:nth-child(7) { animation-delay: 300ms; }
.stagger-item:nth-child(8) { animation-delay: 350ms; }


/* ==========================================================================
   10. TOAST — Posición top-right para feedback moderno
   ========================================================================== */

/* Override posición: top-right en vez de bottom-right */
.toast-container {
    top: calc(var(--header-height) + 1rem);
    right: 1.5rem;
    bottom: auto;
}

/* Toast con entrada desde arriba */
.toast {
    transform: translateX(120%) translateY(-10px);
    border-radius: var(--border-radius-lg);
}

.toast.is-visible {
    transform: translateX(0) translateY(0);
}

/* Progress bar de auto-dismiss */
.toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    animation: toast-progress 3s linear forwards;
}

.toast--success .toast__progress { background-color: var(--status-success); }
.toast--error .toast__progress { background-color: var(--status-danger); }
.toast--warning .toast__progress { background-color: var(--status-warning); }
.toast--info .toast__progress { background-color: var(--status-info); }

@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0; }
}


/* ==========================================================================
   11. EMPTY STATES — Para tablas y listas vacías
   ========================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--gray-400);
}

.empty-state__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state__title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.empty-state__description {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    max-width: 400px;
    margin-bottom: 1.5rem;
}


/* ==========================================================================
   12. LOADING STATES
   ========================================================================== */

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--border-radius-sm);
}

.skeleton--text {
    height: 1em;
    width: 80%;
    margin-bottom: 0.5rem;
}

.skeleton--title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton--circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton--card {
    height: 80px;
    width: 100%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner--sm { width: 14px; height: 14px; border-width: 2px; }
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }

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

/* Button loading state */
.btn.is-loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.is-loading .btn__icon {
    animation: spin 0.6s linear infinite;
}


/* ==========================================================================
   13. SCROLLBAR CUSTOMIZATION
   ========================================================================== */
.sidebar::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--gray-300);
    border-radius: var(--border-radius-full);
}

.sidebar::-webkit-scrollbar-thumb:hover,
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: var(--gray-400);
}


/* ==========================================================================
   14. UTILITY CLASSES
   ========================================================================== */

/* Truncate text */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Screen reader only */
.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;
}

/* Flex helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Width helpers */
.w-full { width: 100%; }

/* Divider */
.divider {
    height: 1px;
    background-color: var(--gray-200);
    margin: var(--space-4) 0;
    border: none;
}
