:root {
    /* Palette: Slate & Indigo */
    --bg-body: #f8fafc;
    /* Slate 50 */
    --bg-sidebar: #0f172a;
    /* Slate 900 */
    --text-sidebar: #94a3b8;
    /* Slate 400 */
    --text-primary: #1e293b;
    /* Slate 800 */
    --text-secondary: #64748b;
    /* Slate 500 */

    /* Indigo Brand Defaults */
    --brand-primary: #4f46e5;
    /* Indigo 600 - Better contrast than 500 */
    --brand-light: #e0e7ff;
    /* Indigo 100 */
    --brand-hover: #4338ca;
    /* Indigo 700 */

    /* Status Colors */
    --success-soft: #dcfce7;
    --success-text: #166534;
    --warning-soft: #fef9c3;
    --warning-text: #854d0e;
    --danger-soft: #fee2e2;
    --danger-text: #991b1b;

    /* UI Elements */
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    background-color: var(--bg-body);
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* --- BOOTSTRAP OVERRIDES (Indigo Theme) --- */
.text-primary {
    color: var(--brand-primary) !important;
}

.bg-primary {
    background-color: var(--brand-primary) !important;
}

.border-primary {
    border-color: var(--brand-primary) !important;
}

.btn-primary {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--brand-hover) !important;
    border-color: var(--brand-hover) !important;
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    background: transparent;
    font-weight: 500;
    border-radius: 8px;
}

.btn-outline-primary:hover {
    background-color: var(--brand-primary) !important;
    color: white !important;
}

.nav-link.active {
    color: white !important;
    background-color: rgba(99, 102, 241, 0.1) !important;
    border-left-color: var(--brand-primary) !important;
}

.nav-link.active i {
    color: var(--brand-primary) !important;
    /* Force icon color */
    opacity: 1 !important;
}

/* --- COMPONENT STYLES --- */

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        width: 16.666667%;
        /* Matched to col-lg-2 */
    }

    .col-md-3.sidebar {
        width: 25%;
        /* Matched to col-md-3 */
    }

    .col-lg-2.sidebar {
        width: 16.666667%;
        /* Matched to col-lg-2 */
    }

    .main-content {
        margin-left: auto;
        /* Required by Bootstrap col- offset */
    }
}

.brand {
    padding: 32px 24px;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-size: 1.1rem;
    font-weight: 700;
    /* letter-spacing: -0.02em; Removed to match site style */
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand i {
    color: var(--brand-primary);
    font-size: 1.4rem;
}

.nav-link {
    color: var(--text-sidebar);
    padding: 14px 24px;
    font-weight: 500;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link:hover {
    color: #f1f5f9;
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-link i {
    width: 20px;
    text-align: center;
    opacity: 0.8;
}

.text-sidebar {
    color: var(--text-sidebar) !important;
}

/* Main Content */
.main-content {
    padding: 40px;
}

@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }
}

/* --- UNIFIED BADGE SYSTEM V2.0 --- */

/* Base Badge Styles */
.badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

/* Badge Variants by Purpose */

/* Status Badges (for booking/order status) */
.badge-status {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-status-success {
    background-color: var(--success-soft);
    color: var(--success-text);
    border: 1px solid rgba(22, 101, 52, 0.2);
}

.badge-status-warning {
    background-color: var(--warning-soft);
    color: var(--warning-text);
    border: 1px solid rgba(133, 77, 14, 0.2);
}

.badge-status-danger {
    background-color: var(--danger-soft);
    color: var(--danger-text);
    border: 1px solid rgba(153, 27, 27, 0.2);
}

.badge-status-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid rgba(30, 64, 175, 0.2);
}

/* Intent Tags (for conversation priority) */
.badge-intent {
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

.badge-intent-hot {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35);
}

.badge-intent-warm {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: white;
    box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
}

.badge-intent-cold {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    color: #475569;
    box-shadow: 0 2px 6px rgba(100, 116, 139, 0.15);
}

/* Pill Style (rounded) */
.badge-pill {
    border-radius: 20px !important;
    padding-left: 14px;
    padding-right: 14px;
}

/* Soft Variants (backward compatibility) */
.badge-soft-success {
    background-color: var(--success-soft);
    color: var(--success-text);
    border: 1px solid rgba(22, 101, 52, 0.15);
}

.badge-soft-warning {
    background-color: var(--warning-soft);
    color: var(--warning-text);
    border: 1px solid rgba(133, 77, 14, 0.15);
}

.badge-soft-danger {
    background-color: var(--danger-soft);
    color: var(--danger-text);
    border: 1px solid rgba(153, 27, 27, 0.15);
}

.badge-soft-primary {
    background-color: var(--brand-light);
    color: var(--brand-primary);
    border: 1px solid rgba(79, 70, 229, 0.15);
}

/* Neutral Badge (for counts, metadata) */
.badge-neutral {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    font-weight: 500;
}

/* Hover Effects */
.badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Cards & Tables */
.card-premium {
    background: white;
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

.table-premium thead th {
    background-color: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px;
}

.table-premium td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.table-premium tr:last-child td {
    border-bottom: none;
}

/* Header Utilities */
.header-context {
    background: white;
    padding: 8px 16px;
    border-radius: 50px;
    box-shadow: var(--card-shadow);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Background color theIA — solo cuando checked */
.theIA:checked {
    background-color: #4f46e5 !important;
    border-color: #4f46e5 !important;
}

/* --- INBOX SPECIFIC --- */
.conversation-item {
    padding: 16px 0;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    background: transparent;
    position: relative;
}

.conversation-item:hover {
    background-color: #f8fafc;
}

.conversation-item.active {
    background-color: #f1f5f9 !important;
    /* Subtle gray bg */
}

/* Elegant Indicator bar (Selection) */
.conversation-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 4px;
    background-color: var(--brand-primary);
    border-radius: 0 4px 4px 0;
    z-index: 10;
}

/* Status Indicators (Right side) - Less invasive */
.conversation-item.intent-danger::after,
.conversation-item.intent-success::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    z-index: 5;
}

.conversation-item.intent-danger::after {
    background-color: #ef4444;
    /* Rojo suave */
}

.conversation-item.intent-success::after {
    background-color: #22c55e;
    /* Verde suave */
}


/* Hover effect on avatar */
.conversation-item:hover .rounded-circle {
    transform: scale(1.05);
}

/* Badge pulsante URGENTE (Track E: Retention Alert) */
@keyframes urgente-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* --- SKELETON LOADERS --- */
.skeleton {
    background: linear-gradient(
        90deg,
        #f1f5f9 0px,
        #e2e8f0 40px,
        #f1f5f9 80px
    );
    background-size: 600px;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-text {
    height: 12px;
    margin: 8px 0;
}

.skeleton-text.large {
    height: 16px;
}

.skeleton-text.small {
    height: 10px;
    width: 60%;
}

@keyframes shimmer {
    0% { background-position: -600px 0; }
    100% { background-position: 600px 0; }
}

.skeleton-conversation-item {
    padding: 16px 0;
    border-bottom: 1px solid #f1f5f9;
    opacity: 0.7;
}

/* --- MOBILE MODERNIZATION (2026) --- */

/* 1. iOS Safe Areas Utility */
.safe-area-pb {
    padding-bottom: 1rem;
    /* Fallback */
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.safe-area-mb {
    margin-bottom: 1rem;
    /* Fallback */
    margin-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* 2. Glassmorphism Utilities */
.glass-header {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.glass-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

/* 3. Mobile Bottom Navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-left: 1rem;
    padding-right: 1rem;
}

.mobile-nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
    width: 64px;
}

.mobile-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 2px;
    transition: transform 0.2s;
}

.mobile-nav-item.active {
    color: var(--brand-primary);
    background: rgba(99, 102, 241, 0.05);
}

.mobile-nav-item.active i {
    transform: translateY(-2px);
}

/* 4. Horizontal Scroll Snap (KPIs) */
@media (max-width: 768px) {
    .mobile-scroll-container {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 16px;
        padding-bottom: 16px;
        /* Space for scrollbar/shadow */
        margin-right: -1rem;
        /* Bleed to edge */
        padding-right: 1rem;
        /* Spacer */
        -webkit-overflow-scrolling: touch;
    }

    .mobile-scroll-item {
        min-width: 85vw;
        /* Show mostly one card, hint next */
        scroll-snap-align: center;
        flex-shrink: 0;
    }

    /* Adjust content padding to prevent nav overlap */
    .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }

    /* Force Offcanvas above Bottom Nav (1050) and Chat Input */
    .offcanvas {
        z-index: 1060 !important;
    }

    .offcanvas-backdrop {
        z-index: 1055 !important;
        background-color: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    /* === MOBILE TOUCH TARGETS OPTIMIZATION === */

    /* All buttons minimum 44x44px (Apple HIG + WCAG 2.5.5) */
    .btn,
    .btn-sm,
    .mobile-nav-item,
    button {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Specific button types */
    .btn-sm {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
    }

    /* Form controls optimized for mobile */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    textarea {
        min-height: 48px !important;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 12px 16px !important;
    }

    /* Textarea specific */
    textarea.form-control {
        min-height: 100px !important;
    }

    /* Navigation items */
    .nav-link {
        min-height: 48px !important;
        padding: 14px 24px !important;
    }

    /* Conversation items (clickable area) */
    .conversation-item {
        min-height: 72px !important;
        padding: 16px 12px !important;
    }

    /* Filter buttons in inbox */
    .btn-filter {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 10px 14px !important;
    }

    /* Icon-only buttons need extra care */
    button[class*="btn-close"],
    button[data-bs-toggle] {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Modal buttons */
    .modal-footer .btn {
        min-height: 48px !important;
        padding: 12px 24px !important;
    }

    /* Increase tap area for small icons */
    .bi {
        padding: 4px;
    }

    /* Table action buttons */
    .table .btn-sm {
        min-height: 40px !important; /* Slightly smaller in tables for density */
        min-width: 40px !important;
    }
}

/* ============================================
   FASE 3: VISUAL POLISH (2026)
   Mejoras puramente visuales - No afecta funcionalidad
   ============================================ */

/* --- TYPOGRAPHY SCALE (Sistema de 6 niveles) --- */
.text-display {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.text-heading-1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.text-heading-2 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.text-heading-3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: -0.005em;
    color: var(--text-primary);
}

.text-body-large {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0;
    color: var(--text-primary);
}

.text-body {
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0;
    color: var(--text-primary);
}

.text-body-small {
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
}

.text-caption {
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Weight Utilities */
.fw-regular { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }

/* --- ENHANCED SHADOWS (3 niveles) --- */
.shadow-xs {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.shadow-soft {
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.08), 0 1px 4px -1px rgba(0, 0, 0, 0.04);
}

.shadow-elevated {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

.shadow-floating {
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.12), 0 8px 16px -8px rgba(0, 0, 0, 0.08);
}

/* --- MICRO-ANIMATIONS --- */

/* Smooth Transitions Base */
.transition-all {
    transition: all 0.2s ease;
}

.transition-fast {
    transition: all 0.15s ease;
}

.transition-slow {
    transition: all 0.3s ease;
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1);
}

/* Hover Glow Effect (para badges y botones) */
.hover-glow {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    transform: scale(1.02);
}

/* Pulse Animation (para notificaciones, typing indicator) */
@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse-soft {
    animation: pulse-soft 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Shake Animation (para validaciones) */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.animate-shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Fade In (para elementos dinámicos) */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

/* Scale In (para modales, tooltips) */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.animate-scaleIn {
    animation: scaleIn 0.2s ease-out;
}

/* --- IMPROVED CONVERSATION HOVER STATES --- */
.conversation-item {
    transition: all 0.2s ease;
}

.conversation-item:hover {
    background-color: #f8fafc;
    border-left: 3px solid rgba(79, 70, 229, 0.2);
    padding-left: 13px; /* Compensar el border */
}

/* --- TOOLTIP ENHANCEMENTS (Bootstrap Override) --- */
.tooltip {
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.tooltip-inner {
    background-color: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 240px;
}

.tooltip .tooltip-arrow::before {
    border-top-color: #1e293b !important;
    border-bottom-color: #1e293b !important;
}

/* --- BADGE MICRO-ANIMATIONS --- */
.badge-intent,
.badge-status {
    transition: all 0.2s ease;
}

.badge-intent:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

/* --- BUTTON REFINEMENTS --- */
.btn {
    transition: all 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* --- GLASSMORPHISM ENHANCEMENTS --- */
.glass-modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* --- FOCUS STATES (Accesibilidad) --- */
*:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* --- LOADING STATES --- */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spinner 0.6s linear infinite;
}

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

/* --- SCROLL BEHAVIOR --- */
.smooth-scroll {
    scroll-behavior: smooth;
}

/* Custom Scrollbar (webkit) */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   MEJORA ADICIONAL: FORM VALIDATION FEEDBACK
   ============================================ */

/* Enhanced Form Validation (Bootstrap Override) */
.form-control.is-valid,
.form-select.is-valid {
    border-color: #22c55e;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2322c55e' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 0.25rem rgba(34, 197, 94, 0.25);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #ef4444;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23ef4444' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 0.25rem rgba(239, 68, 68, 0.25);
}

/* Validation Feedback Messages */
.valid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #22c55e;
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #ef4444;
}

.was-validated .form-control:valid ~ .valid-feedback,
.was-validated .form-select:valid ~ .valid-feedback,
.form-control.is-valid ~ .valid-feedback,
.form-select.is-valid ~ .valid-feedback {
    display: block;
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
    display: block;
}

/* Form Group with Validation */
.form-group.has-validation .form-control {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* ============================================
   MEJORA ADICIONAL: GLOBAL LOADING INDICATOR
   ============================================ */

/* Global HTMX Loading Bar (NProgress style) */
#htmx-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-hover));
    box-shadow: 0 0 10px var(--brand-primary), 0 0 5px var(--brand-primary);
    z-index: 9999;
    transition: width 0.4s ease-out, opacity 0.3s ease;
    opacity: 0;
}

#htmx-loading-bar.htmx-request {
    opacity: 1;
    width: 70%;
}

#htmx-loading-bar.htmx-request.complete {
    width: 100%;
    opacity: 0;
    transition: width 0.2s ease-out, opacity 0.3s ease 0.2s;
}

/* Global Spinner Overlay (for longer operations) */
#htmx-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#htmx-spinner-overlay.show {
    display: flex;
    opacity: 1;
}

.htmx-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

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

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

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

/* Button Loading State */
.btn.htmx-request {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.htmx-request::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spinner 0.6s linear infinite;
}
/* === DROPDOWN MENU PREMIUM STYLES === */
.dropdown-menu {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.dropdown-item {
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.875rem;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    color: #1e293b;
    transform: translateX(2px);
}

.dropdown-item:active {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    color: #0f172a;
}

.dropdown-item:last-child {
    margin-bottom: 0;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-top: 1px solid #e2e8f0;
}
