/**
 * TAZDUCA Enhanced UI Components
 * Componentes UI mejorados con efectos visuales modernos
 */

/* ========================================
   CHATBOT STYLES
======================================== */

.chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 110px;
    width: 380px;
    max-height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
    z-index: 999998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    opacity: 1;
    transform: scale(1) translateY(0);
}

.chatbot-container.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    visibility: hidden;
}

.chatbot-container.minimized {
    max-height: 80px;
}

.chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border-bottom: 1px solid #e5e7eb;
}

.chatbot-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    border: 2px solid white;
}

.status-indicator.online {
    background: var(--secondary-green);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3); }
}

.chatbot-info {
    flex: 1;
}

.chatbot-info h3 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin: 0;
    line-height: var(--leading-tight);
}

.chatbot-info .status-text {
    font-size: var(--text-xs);
    opacity: 0.8;
    margin: var(--space-1) 0 0 0;
    line-height: var(--leading-none);
}

.chatbot-controls {
    display: flex;
    gap: var(--space-1);
}

.chatbot-controls button {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.chatbot-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chatbot-messages {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    max-height: 400px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: var(--radius-full);
}

.message {
    margin-bottom: var(--space-4);
    display: flex;
    animation: slideInUp 0.3s ease-out;
}

.bot-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    position: relative;
}

.bot-message .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--text-inverse);
    border-bottom-right-radius: var(--radius-sm);
}

.message-content p {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.message-time {
    font-size: var(--text-xs);
    opacity: 0.7;
    margin-top: var(--space-2);
    text-align: right;
}

.quick-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
    flex-wrap: wrap;
}

.quick-action {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    background: var(--primary-blue-subtle);
    color: var(--primary-blue-dark);
    border: 1px solid var(--primary-blue);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-action:hover {
    background: var(--primary-blue);
    color: var(--text-inverse);
    transform: translateY(-1px);
}

.message-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
    flex-wrap: wrap;
}

.action-btn {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.typing-indicator {
    justify-content: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: var(--space-4);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--gray-400);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.6; }
    40% { transform: scale(1); opacity: 1; }
}

.chatbot-input-area {
    border-top: 1px solid var(--border-primary);
    padding: var(--space-4);
    background: var(--bg-secondary);
}

.input-container {
    display: flex;
    gap: var(--space-2);
    align-items: stretch;
}

.input-container input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    outline: none;
    transition: all var(--transition-base);
}

.input-container input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-container button {
    width: 44px;
    height: 44px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.input-container button:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.input-suggestions {
    margin-top: var(--space-2);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.suggestion {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.suggestion:hover {
    background: var(--primary-blue-subtle);
    color: var(--primary-blue-dark);
    border-color: var(--primary-blue);
}

.chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 110px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: chatbotPulse 2s infinite;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.6);
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

@keyframes chatbotPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(37, 99, 235, 0.8), 0 0 0 10px rgba(37, 99, 235, 0.1);
    }
}

.chatbot-toggle.active {
    background: var(--secondary-green);
}

.toggle-content {
    position: relative;
    z-index: 2;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce 2s infinite;
}

.toggle-tooltip {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: var(--gray-800);
    color: var(--text-inverse);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-base);
    pointer-events: none;
}

.chatbot-toggle:hover .toggle-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.toggle-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 15px;
    border: 5px solid transparent;
    border-top-color: var(--gray-800);
}




.card-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all var(--transition-slow);
}

.card-badge {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    background: var(--accent-orange);
    color: var(--text-inverse);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    box-shadow: var(--shadow-md);
}

.card-content {
    padding: var(--space-5);
}

.card-content h4 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    line-height: var(--leading-tight);
}

.card-description {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-3);
}

.card-price {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--primary-blue);
    margin-bottom: var(--space-3);
}

.card-explanation {
    background: var(--bg-secondary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.card-explanation small {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    font-style: italic;
}

.card-actions {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.widget-header h4 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

.widget-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.widget-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.widget-content {
    padding: var(--space-4);
}

.widget-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.widget-item:hover {
    background: var(--bg-secondary);
}

.widget-item img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.item-info {
    flex: 1;
}

.item-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.item-price {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: var(--font-semibold);
}

/* ========================================
   PRICING OPTIMIZER STYLES
======================================== */

.price-updating {
    position: relative;
    overflow: hidden;
}

.price-updating::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(37, 99, 235, 0.2), 
        transparent
    );
    animation: shimmer 1s ease-in-out;
}

@keyframes shimmer {
    to { left: 100%; }
}

.price-increased {
    animation: priceUp 0.6s ease-out;
}

.price-decreased {
    animation: priceDown 0.6s ease-out;
}

@keyframes priceUp {
    0% { transform: scale(1); color: var(--text-primary); }
    50% { transform: scale(1.1); color: var(--secondary-green); }
    100% { transform: scale(1); color: var(--text-primary); }
}

@keyframes priceDown {
    0% { transform: scale(1); color: var(--text-primary); }
    50% { transform: scale(1.1); color: var(--accent-orange); }
    100% { transform: scale(1); color: var(--text-primary); }
}

.promotional-badge {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    color: var(--text-inverse);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    animation: pulse 2s infinite;
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 10;
}

/* ========================================
   ENHANCED FORM COMPONENTS
======================================== */

.form-floating {
    position: relative;
}

.form-floating .form-control {
    padding: var(--space-4) var(--space-4) var(--space-2) var(--space-4);
}

.form-floating label {
    position: absolute;
    top: 0;
    left: var(--space-4);
    height: 100%;
    padding: var(--space-4) 0 0 0;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: all var(--transition-base);
    color: var(--text-tertiary);
}

.form-floating .form-control:focus ~ label,
.form-floating .form-control:not(:placeholder-shown) ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-1rem) translateX(0.15rem);
}

.form-control-icon {
    position: relative;
}

.form-control-icon .form-control {
    padding-left: var(--space-10);
}

.form-control-icon .form-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    z-index: 10;
}

.form-control:focus + .form-icon {
    color: var(--border-focus);
}

/* File Upload Styles */
.file-upload {
    position: relative;
    display: inline-block;
    cursor: pointer;
    width: 100%;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-content {
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    text-align: center;
    transition: all var(--transition-base);
    background: var(--bg-secondary);
}

.file-upload:hover .file-upload-content,
.file-upload-content.dragover {
    border-color: var(--primary-blue);
    background: var(--primary-blue-subtle);
}

.file-upload-icon {
    font-size: var(--text-4xl);
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
}

.file-upload-content.dragover .file-upload-icon {
    color: var(--primary-blue);
    animation: bounce 1s infinite;
}

.file-upload-text {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.file-upload-text strong {
    color: var(--primary-blue);
}

/* ========================================
   NOTIFICATION ENHANCEMENTS
======================================== */

#tazduca-notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast);
    max-width: 400px;
}

.tazduca-notification {
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-3);
    overflow: hidden;
    transform: translateX(400px);
    opacity: 0;
    transition: all var(--transition-base);
    animation: slideInRight 0.3s ease-out forwards;
}

.notification-content {
    padding: var(--space-4);
    position: relative;
}

.notification-content h4 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
}

.notification-content p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
    line-height: var(--leading-relaxed);
}

.notification-close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.notification-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ========================================
   LOADING STATES
======================================== */

.skeleton {
    background: linear-gradient(90deg, 
        var(--gray-200) 25%, 
        var(--gray-100) 50%, 
        var(--gray-200) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite ease-in-out;
    border-radius: var(--radius-md);
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: var(--space-2);
}

.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }
.skeleton-text.w-1\/4 { width: 25%; }

.skeleton-circle {
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
}

.skeleton-rect {
    width: 100%;
    height: 200px;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-blue);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

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

/* ========================================
   RESPONSIVE ENHANCEMENTS
======================================== */

@media (max-width: 768px) {
    .chatbot-toggle {
        right: 80px;
    }
    
    .chatbot-container {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
        max-height: 70vh;
    }
    
    #tazduca-notifications {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .chatbot-toggle {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 80px;
    }
    
    .chatbot-container {
        width: calc(100vw - 30px);
        right: 15px;
        left: 15px;
        bottom: 80px;
        max-height: 60vh;
    }
}
    
    .card-actions {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .card-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
======================================== */

/* Focus visible para teclado */
.chatbot-container:focus-within {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .chatbot-toggle:hover {
        transform: scale(1.05);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-primary: #000000;
        --border-secondary: #000000;
        --text-secondary: #000000;
        --text-tertiary: #333333;
    }
    
    .btn {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-blue);
    color: var(--text-inverse);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    text-decoration: none;
    z-index: var(--z-modal);
    transition: all var(--transition-base);
}

.skip-link:focus {
    top: 6px;
}
