/* ===== MEJORAS DE ACCESIBILIDAD UX/UI ===== */
/* Fecha: 26 de Noviembre de 2024 */
/* Cumplimiento: WCAG 2.1 AA */

/* ===== 1. SKIP TO MAIN CONTENT ===== */
.skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 12px 24px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    text-decoration: none;
    z-index: 10000;
    border: 3px solid #fff;
    transition: top 0.2s;
}

.skip-to-main:focus {
    top: 0;
}

/* ===== 2. FOCUS STATES VISIBLES ===== */
/* Reset focus outline para todos los elementos */
*:focus {
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* Solo mostrar outline cuando navegando con teclado */
*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.1);
}

/* Focus para botones */
.btn:focus-visible,
button:focus-visible {
    outline: 3px solid #000;
    outline-offset: 4px;
    box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.2);
}

/* Focus para links de navegación */
.nav-link:focus-visible {
    background: #f0f0f0;
    outline: 3px solid #000;
    outline-offset: -3px;
    position: relative;
    z-index: 100;
}

.dropdown-link:focus-visible {
    background: #f0f0f0;
    outline: 3px solid #000;
    outline-offset: -3px;
}

/* Focus para inputs */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
    border-color: #000;
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 5px rgba(0, 0, 0, 0.1);
}

/* Focus para checkboxes y radios */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid #000;
    outline-offset: 3px;
}

/* ===== 3. INDICADOR DE NAVEGACIÓN ACTIVA ===== */
.nav-link.active {
    background: #000;
    color: #fff;
    font-weight: 700;
    border: 3px solid #000;
    position: relative;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 4px;
    background: #000;
}

.dropdown-link.active {
    background: #000;
    color: #fff;
    border-left: 5px solid #fff;
    font-weight: 700;
}

/* ===== 4. VALIDACIÓN DE FORMULARIOS ===== */
.input-error {
    border-color: #e74c3c !important;
    border-width: 3px !important;
    background: #ffe5e5;
    animation: shake 0.3s;
}

.input-valid {
    border-color: #27ae60 !important;
    border-left: 5px solid #27ae60 !important;
    background: #e8f8f0;
}

.input-warning {
    border-color: #f39c12 !important;
    border-left: 5px solid #f39c12 !important;
    background: #fff8e5;
}

.error-message {
    color: #e74c3c;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 5px;
    padding: 8px 12px;
    background: #ffe5e5;
    border: 2px solid #e74c3c;
    border-radius: 0;
    font-family: 'JetBrains Mono', monospace;
    display: none;
}

.input-error ~ .error-message,
.has-error .error-message {
    display: block;
}

.success-message {
    color: #27ae60;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 5px;
    padding: 8px 12px;
    background: #e8f8f0;
    border: 2px solid #27ae60;
    font-family: 'JetBrains Mono', monospace;
}

.warning-message {
    color: #f39c12;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 5px;
    padding: 8px 12px;
    background: #fff8e5;
    border: 2px solid #f39c12;
    font-family: 'JetBrains Mono', monospace;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ===== 5. ESTADOS VACÍOS ===== */
.empty-state {
    text-align: center;
    padding: 80px 40px;
    background: #fff;
    border: 4px solid #000;
    box-shadow: 6px 6px 0 rgba(0,0,0,0.1);
    margin: 40px 0;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

.empty-state-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #000;
}

.empty-state-description {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    color: #595959; /* Contraste 6.1:1 ✅ */
    margin-bottom: 30px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.empty-state-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ===== 6. LOADING STATES ===== */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid currentColor;
    border-top-color: transparent;
    border-radius: 0;
    animation: pixel-spin 0.8s steps(8) infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes pixel-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.btn-loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
    position: relative;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

/* Skeleton screens */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border: 3px solid #ddd;
    min-height: 50px;
    margin-bottom: 10px;
}

.skeleton-text {
    height: 20px;
    margin-bottom: 10px;
}

.skeleton-title {
    height: 30px;
    width: 60%;
    margin-bottom: 15px;
}

.skeleton-button {
    height: 44px;
    width: 150px;
}

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

/* ===== 7. MENSAJES DE ERROR MEJORADOS ===== */
.error-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

.error-toast {
    background: #fff;
    border: 4px solid #e74c3c;
    box-shadow: 8px 8px 0 rgba(231, 76, 60, 0.2);
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 15px;
}

.success-toast {
    background: #fff;
    border: 4px solid #27ae60;
    box-shadow: 8px 8px 0 rgba(39, 174, 96, 0.2);
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 15px;
}

.warning-toast {
    background: #fff;
    border: 4px solid #f39c12;
    box-shadow: 8px 8px 0 rgba(243, 156, 18, 0.2);
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 15px;
}

.toast-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.toast-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.error-toast .toast-title {
    color: #e74c3c;
}

.success-toast .toast-title {
    color: #27ae60;
}

.warning-toast .toast-title {
    color: #f39c12;
}

.toast-message {
    font-size: 0.9rem;
    margin-bottom: 12px;
    line-height: 1.5;
    color: #333;
}

.toast-details {
    font-size: 0.8rem;
    color: #666;
    background: #f8f9fa;
    padding: 8px;
    margin-bottom: 12px;
}

.error-toast .toast-details {
    border-left: 3px solid #e74c3c;
}

.success-toast .toast-details {
    border-left: 3px solid #27ae60;
}

.warning-toast .toast-details {
    border-left: 3px solid #f39c12;
}

.toast-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== 8. BREADCRUMBS ===== */
.breadcrumb {
    background: #f5f5f5;
    padding: 12px 20px;
    border-bottom: 3px solid #000;
    margin-bottom: 20px;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    list-style: none;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.breadcrumb-item a {
    color: #000;
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 8px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.breadcrumb-item a:hover {
    background: #000;
    color: #fff;
    border-color: #000;
}

.breadcrumb-item a:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
}

.breadcrumb-current {
    color: #666;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 400;
}

.breadcrumb-separator {
    color: #999;
    font-size: 1.2rem;
    user-select: none;
}

/* ===== 9. TOOLTIPS FUNCIONALES ===== */
/* Tooltips deshabilitados en submenús de herramientas */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
    display: none;
}

/* ===== 10. CONTRASTE DE COLORES MEJORADO ===== */
/* Todos los textos grises actualizados para cumplir WCAG AA (4.5:1) */
.user-dropdown-email-nav,
.nav-user-dropdown-email {
    color: #666; /* Contraste 5.7:1 ✅ */
}

input::placeholder,
select::placeholder,
textarea::placeholder {
    color: #757575; /* Contraste 4.6:1 ✅ */
    opacity: 1;
}

.filter-info-text,
.section-description,
.help-text {
    color: #595959; /* Contraste 6.1:1 ✅ */
}

.muted-text,
.secondary-text {
    color: #666; /* Contraste 5.7:1 ✅ */
}

/* ===== 11. TOUCH TARGETS MÍNIMOS (44x44px) ===== */
@media (max-width: 768px) {
    .btn,
    .nav-link,
    .dropdown-link,
    button,
    a.btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    .tutorial-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
        font-size: 0.85rem;
    }
    
    /* Espaciado entre botones */
    .btn + .btn,
    button + button {
        margin-top: 12px;
        margin-left: 0;
    }
    
    /* Iconos táctiles */
    .btn-icon {
        width: 20px;
        height: 20px;
    }
    
    /* Dropdown items */
    .dropdown-link {
        padding: 16px 20px;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    /* Form inputs */
    input,
    select,
    textarea,
    .filter-select {
        min-height: 44px;
        font-size: 16px; /* Previene zoom en iOS */
        padding: 12px;
    }
    
    /* Checkboxes y radios más grandes */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
    }
}

/* ===== 12. RESPONSIVE UTILITIES ===== */
@media (max-width: 768px) {
    .empty-state {
        padding: 60px 20px;
    }
    
    .empty-state-actions {
        flex-direction: column;
    }
    
    .empty-state-actions .btn {
        width: 100%;
    }
    
    .error-container {
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-width: none;
    }
    
    .breadcrumb {
        padding: 10px 15px;
    }
    
    .breadcrumb-list {
        font-size: 0.8rem;
    }
    
    [data-tooltip]::before {
        white-space: normal;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .empty-state {
        padding: 40px 15px;
    }
    
    .empty-state-icon {
        font-size: 3rem;
    }
    
    .empty-state-title {
        font-size: 1.2rem;
    }
    
    .error-toast,
    .success-toast,
    .warning-toast {
        padding: 15px;
    }
    
    .toast-actions {
        flex-direction: column;
    }
    
    .toast-actions .btn {
        width: 100%;
    }
}

/* ===== 13. PRINT STYLES ===== */
@media print {
    .skip-to-main,
    .header,
    .nav,
    .tutorial-btn,
    .error-container,
    .breadcrumb {
        display: none;
    }
    
    .section {
        page-break-inside: avoid;
    }
    
    .btn,
    button {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}

/* ===== 14. ANIMACIONES REDUCIDAS (Respeto a prefers-reduced-motion) ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
    
    .empty-state-icon {
        animation: none;
    }
}

/* ===== 15. HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .btn,
    button {
        border-width: 4px;
    }
    
    input,
    select,
    textarea {
        border-width: 3px;
    }
    
    .input-error {
        border-width: 4px !important;
    }
    
    *:focus-visible {
        outline-width: 4px;
    }
}
