/* SEMERGEN Backoffice - Main Styles (AdminLTE 3.2 + Bootstrap 4) */

:root {
    /* Sistema de espaciado consistente */
    --space-section: 1.5rem;
    --space-element: 1rem;
    --space-compact: 0.5rem;
    
    /* Colores con mejor contraste (WCAG AA) */
    --text-muted: #5a6268;
    --text-white-muted: rgba(255, 255, 255, 0.85);
}

/* Tables */
.table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    color: #6c757d;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

/* Cards */
.card {
    border-radius: 0.5rem;
}

.card-header {
    border-bottom: 1px solid rgba(0,0,0,.05);
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Forms */
.form-control:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Campos obligatorios */
.required-field::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* Focus visible mejorado (Accesibilidad) */
*:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.btn:focus-visible {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.5);
}

.form-control:focus-visible {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Mantener estilo nativo solo para mouse */
:focus:not(:focus-visible) {
    outline: none;
}

/* Contraste mejorado para texto secundario */
.text-muted {
    color: var(--text-muted) !important;
}

.text-white-50 {
    color: var(--text-white-muted) !important;
}

/* Wizard Steps */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 0;
    list-style: none;
}

.wizard-steps li {
    flex: 1;
    text-align: center;
    position: relative;
}

.wizard-steps li::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #e9ecef;
    z-index: 0;
}

.wizard-steps li:first-child::before {
    left: 50%;
}

.wizard-steps li:last-child::before {
    right: 50%;
}

.wizard-steps .step-number {
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 50%;
    background-color: #e9ecef;
    color: #6c757d;
    display: inline-block;
    position: relative;
    z-index: 1;
    font-weight: 600;
    font-size: 0.875rem;
}

.wizard-steps li.active .step-number {
    background-color: #0d6efd;
    color: white;
}

.wizard-steps li.completed .step-number {
    background-color: #198754;
    color: white;
}

.wizard-steps .step-label {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.wizard-steps li.active .step-label {
    color: #0d6efd;
    font-weight: 500;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e9ecef;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #6c757d;
    border: 2px solid white;
}

.timeline-item.current::before {
    background-color: #0d6efd;
}

/* File Upload Zone */
.file-upload-zone {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload-zone:hover,
.file-upload-zone.dragover {
    border-color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.05);
}

.file-upload-zone .icon {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

/* Notification dropdown */
#notifications-dropdown .notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

#notifications-dropdown .notification-item:hover {
    background-color: #f8f9fa;
}

#notifications-dropdown .notification-item.unread {
    background-color: #f0f7ff;
}

/* Comparison View */
.comparison-panel {
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
}

.comparison-panel .highlight {
    background-color: #fff3cd;
    padding: 0.1rem 0.2rem;
}

/* Stats cards */
.stat-card-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 1.5rem;
}

/* Loading states */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Print styles */
@media print {
    .main-sidebar,
    .main-header,
    .main-footer,
    .btn {
        display: none !important;
    }
    
    .content-wrapper {
        margin: 0 !important;
        min-width: 100%;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    /* Targets táctiles mínimo 44px (WCAG) */
    .btn-sm {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem 0.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .pagination .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Ocultar columnas secundarias en tablas */
    .table .d-mobile-none {
        display: none !important;
    }
    
    /* Wizard steps compacto */
    .wizard-steps {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .wizard-steps li {
        min-width: 60px;
        flex-shrink: 0;
    }
    
    .wizard-steps .step-label {
        font-size: 0.65rem;
        white-space: nowrap;
    }
}

/* Skip link para accesibilidad */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: 0.75rem 1rem;
    background: #0d6efd;
    color: white;
    text-decoration: none;
    z-index: 9999;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* Indicador de carga para búsqueda */
.search-indicator {
    display: none;
}

.htmx-request .search-indicator {
    display: inline-block;
}

.htmx-request .search-icon {
    display: none;
}

/* Dropdown de resultados de búsqueda */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
}

.search-results-dropdown.show {
    display: block;
}

.search-results-dropdown .search-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.search-results-dropdown .search-item:hover {
    background-color: #f8f9fa;
}

.search-results-dropdown .search-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

/* Auth card responsive (Medio 6.3) */
.auth-card {
    width: 100%;
    max-width: min(450px, 90vw);
}

/* Notification dropdown */
.notification-dropdown {
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-dropdown [role="menuitem"] {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.notification-dropdown [role="menuitem"]:focus {
    background-color: #f0f7ff;
    outline: none;
}

/* Badge naranja para cambios solicitados */
.bg-orange {
    background-color: #fd7e14 !important;
}

/* Landscape móvil - AdminLTE handles sidebar collapse */

/* Autosave indicator */
#autosave-status {
    transition: opacity 0.3s ease;
}

#autosave-status.htmx-request {
    opacity: 1;
}

/* Keyboard focus improvements for dropdown items */
.dropdown-item:focus-visible,
.list-group-item:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .text-muted {
        color: #495057 !important;
    }
    
    .btn-outline-secondary {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
