/* =============================================================
   UX ENHANCEMENTS - Mejoras visuales y de experiencia
   ============================================================= */

/* ----- LOADING STATES & SKELETONS ----- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 60%; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.skeleton-row .skeleton-text { margin-bottom: 0; }

/* Loading overlay for cards/panels */
.loading-overlay {
    position: relative;
}
.loading-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: inherit;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.loading-overlay.is-loading::after {
    opacity: 1;
    pointer-events: auto;
}

/* Spinner */
.spinner-archidoc {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary-color, #2563eb);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- ENHANCED STAT CARDS ----- */
.stat-card-enhanced {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f0f0f0;
    position: relative;
    overflow: hidden;
}
.stat-card-enhanced:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: transparent;
}
.stat-card-enhanced .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}
.stat-card-enhanced .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
}
.stat-card-enhanced .stat-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 2px;
    font-weight: 500;
}
.stat-card-enhanced .stat-trend {
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}
.stat-card-enhanced .stat-trend.up { color: #10b981; }
.stat-card-enhanced .stat-trend.down { color: #ef4444; }

/* Color variants */
.stat-card-enhanced.blue .stat-icon { background: #eff6ff; color: #2563eb; }
.stat-card-enhanced.green .stat-icon { background: #ecfdf5; color: #10b981; }
.stat-card-enhanced.amber .stat-icon { background: #fffbeb; color: #f59e0b; }
.stat-card-enhanced.red .stat-icon { background: #fef2f2; color: #ef4444; }
.stat-card-enhanced.purple .stat-icon { background: #faf5ff; color: #8b5cf6; }
.stat-card-enhanced.cyan .stat-icon { background: #ecfeff; color: #06b6d4; }

/* ----- ENHANCED TABLES ----- */
.table-enhanced {
    border-collapse: separate;
    border-spacing: 0;
}
.table-enhanced thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.table-enhanced tbody tr {
    transition: background-color 0.15s;
}
.table-enhanced tbody tr:hover {
    background-color: #f1f5f9;
}
.table-enhanced tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 14px;
}
.table-enhanced tbody tr:last-child td {
    border-bottom: none;
}

/* Row selection */
.table-enhanced tbody tr.selected {
    background-color: #eff6ff;
}
.table-enhanced .row-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color, #2563eb);
}

/* ----- ENHANCED STATUS BADGES ----- */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge-status.submitted { background: #fff7ed; color: #c2410c; }
.badge-status.submitted::before { background: #f97316; }
.badge-status.processing { background: #eff6ff; color: #1d4ed8; }
.badge-status.processing::before { background: #3b82f6; animation: pulse-dot 2s infinite; }
.badge-status.approved { background: #f0fdf4; color: #15803d; }
.badge-status.approved::before { background: #22c55e; }
.badge-status.completed { background: #ecfdf5; color: #047857; }
.badge-status.completed::before { background: #10b981; }
.badge-status.denied, .badge-status.rejected { background: #fef2f2; color: #b91c1c; }
.badge-status.denied::before, .badge-status.rejected::before { background: #ef4444; }
.badge-status.cancelled { background: #f8fafc; color: #64748b; }
.badge-status.cancelled::before { background: #94a3b8; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Urgency badges */
.badge-urgency {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-urgency.normal { background: #f1f5f9; color: #475569; }
.badge-urgency.high, .badge-urgency.urgent { background: #fef2f2; color: #dc2626; }
.badge-urgency.critical { background: #dc2626; color: #fff; }
.badge-urgency.low { background: #f0fdf4; color: #166534; }

/* ----- ENHANCED EMPTY STATES ----- */
.empty-state-enhanced {
    text-align: center;
    padding: 48px 24px;
}
.empty-state-enhanced .empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
    color: #94a3b8;
}
.empty-state-enhanced .empty-title {
    font-size: 18px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}
.empty-state-enhanced .empty-description {
    font-size: 14px;
    color: #64748b;
    max-width: 360px;
    margin: 0 auto 20px;
    line-height: 1.5;
}
.empty-state-enhanced .empty-action {
    margin-top: 8px;
}

/* ----- ENHANCED BUTTONS ----- */
.btn-enhanced {
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.5;
}
.btn-enhanced:active {
    transform: scale(0.97);
}
.btn-enhanced.btn-primary-e {
    background: var(--primary-color, #2563eb);
    color: #fff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}
.btn-enhanced.btn-primary-e:hover {
    background: var(--primary-dark, #1d4ed8);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.btn-enhanced.btn-secondary-e {
    background: #f1f5f9;
    color: #475569;
}
.btn-enhanced.btn-secondary-e:hover {
    background: #e2e8f0;
    color: #334155;
}
.btn-enhanced.btn-success-e {
    background: #10b981;
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.3);
}
.btn-enhanced.btn-success-e:hover {
    background: #059669;
}
.btn-enhanced.btn-danger-e {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.3);
}
.btn-enhanced.btn-danger-e:hover {
    background: #dc2626;
}

/* Button with loading state */
.btn-enhanced.is-loading {
    pointer-events: none;
    opacity: 0.7;
}
.btn-enhanced.is-loading .btn-text { visibility: hidden; }
.btn-enhanced.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ----- ENHANCED CARDS ----- */
.card-enhanced {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.card-enhanced:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.card-enhanced .card-header-e {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-enhanced .card-header-e .card-title-e {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-enhanced .card-body-e {
    padding: 20px;
}
.card-enhanced .card-footer-e {
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

/* ----- ENHANCED BREADCRUMB ----- */
.breadcrumb-enhanced {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 20px;
    font-size: 14px;
    list-style: none;
    background: none;
}
.breadcrumb-enhanced li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
}
.breadcrumb-enhanced li + li::before {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 9px;
    color: #cbd5e1;
}
.breadcrumb-enhanced li a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.15s;
}
.breadcrumb-enhanced li a:hover {
    color: var(--primary-color, #2563eb);
}
.breadcrumb-enhanced li.active {
    color: #1e293b;
    font-weight: 500;
}

/* ----- ENHANCED PAGE HEADER ----- */
.page-header-enhanced {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header-enhanced .page-title {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    font-family: 'Inter', sans-serif;
}
.page-header-enhanced .page-subtitle {
    font-size: 14px;
    color: #64748b;
    margin-top: 4px;
}
.page-header-enhanced .page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ----- ENHANCED FILTER PANEL ----- */
.filter-panel {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px 20px;
    margin-bottom: 20px;
}
.filter-panel .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.filter-panel .filter-group {
    flex: 1;
    min-width: 150px;
}
.filter-panel .filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.filter-panel .filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* ----- ENHANCED FORM CONTROLS ----- */
.form-control-enhanced {
    border-radius: 8px;
    border: 1.5px solid #e2e8f0;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.2s;
    background: #fff;
}
.form-control-enhanced:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}
.form-control-enhanced.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.form-control-enhanced.is-valid {
    border-color: #10b981;
}

/* ----- ENHANCED WIZARD STEPS ----- */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
    padding: 0 20px;
}
.wizard-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    position: relative;
    flex-shrink: 0;
}
.wizard-step .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    background: #e2e8f0;
    color: #64748b;
    transition: all 0.3s;
    flex-shrink: 0;
}
.wizard-step .step-label {
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    transition: color 0.3s;
    white-space: nowrap;
}
.wizard-step.active .step-number {
    background: var(--primary-color, #2563eb);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}
.wizard-step.active .step-label {
    color: #1e293b;
    font-weight: 600;
}
.wizard-step.completed .step-number {
    background: #10b981;
    color: #fff;
}
.wizard-step.completed .step-label {
    color: #475569;
}
.wizard-connector {
    flex: 1;
    height: 2px;
    background: #e2e8f0;
    min-width: 24px;
    transition: background 0.3s;
}
.wizard-connector.completed {
    background: #10b981;
}

/* ----- TIMELINE ENHANCED ----- */
.timeline-enhanced {
    position: relative;
    padding-left: 28px;
}
.timeline-enhanced::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}
.timeline-item-e {
    position: relative;
    padding-bottom: 24px;
}
.timeline-item-e:last-child { padding-bottom: 0; }
.timeline-item-e .timeline-dot {
    position: absolute;
    left: -22px;
    top: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #94a3b8;
    z-index: 1;
}
.timeline-item-e .timeline-dot.success { border-color: #10b981; background: #ecfdf5; }
.timeline-item-e .timeline-dot.warning { border-color: #f59e0b; background: #fffbeb; }
.timeline-item-e .timeline-dot.error { border-color: #ef4444; background: #fef2f2; }
.timeline-item-e .timeline-dot.info { border-color: #3b82f6; background: #eff6ff; }
.timeline-item-e .timeline-content {
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 12px 16px;
}
.timeline-item-e .timeline-date {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
}
.timeline-item-e .timeline-text {
    font-size: 14px;
    color: #334155;
}

/* ----- MOBILE RESPONSIVE ENHANCEMENTS ----- */
@media (max-width: 768px) {
    .stat-card-enhanced { padding: 16px; }
    .stat-card-enhanced .stat-value { font-size: 22px; }
    .page-header-enhanced { flex-direction: column; align-items: flex-start; }
    .page-header-enhanced .page-actions { width: 100%; }
    .filter-panel .filter-row { flex-direction: column; }
    .filter-panel .filter-group { min-width: 100%; }
    .wizard-step .step-label { display: none; }
    .wizard-steps { gap: 0; padding: 0; }

    /* Card-style table rows on mobile */
    .table-responsive-cards thead { display: none; }
    .table-responsive-cards tbody tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        padding: 12px;
        background: #fff;
    }
    .table-responsive-cards tbody td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border: none;
    }
    .table-responsive-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 12px;
        text-transform: uppercase;
    }
}

/* ----- ANIMATIONS ----- */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Success checkmark animation */
.success-check {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ecfdf5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.success-check i {
    color: #10b981;
    font-size: 24px;
}
@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* ----- TOOLTIPS ----- */
[data-tooltip] {
    position: relative;
    cursor: help;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #1e293b;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.15s ease;
    z-index: 100;
}
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ----- NOTIFICATION DOT ----- */
.notification-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

/* ----- SCROLLBAR STYLING ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ----- PRINT STYLES ----- */
@media print {
    #aside, #header, #footer, .no-print, .page-actions { display: none !important; }
    #middle { margin: 0 !important; padding: 0 !important; }
    .card-enhanced { box-shadow: none; border: 1px solid #ddd; }
    .table-enhanced th { background: #f5f5f5 !important; }
}
