/* ========================================
   NEXT GEN CHAT - QUARKIA 2025
   Design ultra-moderno per widget chat
   ======================================== */

/* CSS Variables */
:root,
.nextgen-chat-widget,
.ngc-container {
    --ngc-primary: #0f172a;
    --ngc-primary-light: #1e293b;
    --ngc-primary-lighter: #334155;
    --ngc-accent: #3b82f6;
    --ngc-accent-light: #60a5fa;
    --ngc-success: #10b981;
    --ngc-bg: #ffffff;
    --ngc-bg-secondary: #f8fafc;
    --ngc-text: #0f172a;
    --ngc-text-muted: #64748b;
    --ngc-border: #e2e8f0;
    --ngc-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --ngc-radius: 20px;
    --ngc-radius-sm: 12px;
    --ngc-radius-xs: 8px;
}

.nextgen-chat-widget {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Container */
.ngc-container {
    width: 380px;
    height: 560px;
    background: var(--ngc-bg);
    border-radius: var(--ngc-radius);
    box-shadow: var(--ngc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Slide Mode - Full height panel */
.nextgen-chat-widget.slide-mode,
.chat-style-slide.nextgen-chat-widget {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    width: 350px !important;
    border-radius: 0 !important;
    right: 0 !important;
    left: auto !important;
}

/* Slide Left Position */
.nextgen-chat-widget.slide-mode.slide-left,
.chat-style-slide.nextgen-chat-widget[data-slide-position="left"] {
    left: 0 !important;
    right: auto !important;
}

.nextgen-chat-widget.slide-mode .ngc-container,
.chat-style-slide .ngc-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
}

/* Slide Left - shadow on right side */
.nextgen-chat-widget.slide-mode.slide-left .ngc-container {
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
}

/* Glass Effect */
.ngc-container.glass-effect {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Header */
.ngc-header {
    background: linear-gradient(135deg, var(--ngc-primary) 0%, var(--ngc-primary-light) 50%, var(--ngc-primary-lighter) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
}

.ngc-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

.ngc-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ngc-avatar-wrapper {
    position: relative;
}

.ngc-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.ngc-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--ngc-success);
    border-radius: 50%;
    border: 3px solid var(--ngc-primary);
    animation: ngc-pulse 2s infinite;
}

@keyframes ngc-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.ngc-header-info {
    display: flex;
    flex-direction: column;
}

.ngc-title {
    color: #ffffff;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.ngc-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin-top: 2px;
}

.ngc-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ngc-btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ngc-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: scale(1.05);
}

.ngc-btn-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Messages Area */
.ngc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--ngc-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ngc-messages::-webkit-scrollbar {
    width: 6px;
}

.ngc-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ngc-messages::-webkit-scrollbar-thumb {
    background: var(--ngc-border);
    border-radius: 3px;
}

/* Welcome Card */
.ngc-welcome-card {
    background: linear-gradient(135deg, var(--ngc-primary) 0%, var(--ngc-primary-light) 100%);
    border-radius: var(--ngc-radius-sm);
    padding: 24px;
    text-align: center;
    color: #ffffff;
    margin-bottom: 8px;
}

.ngc-welcome-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
}

.ngc-welcome-card h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.ngc-welcome-card p {
    font-size: 14px;
    opacity: 0.8;
    margin: 0;
}

/* Quick Actions */
.ngc-quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 8px;
}

.ngc-quick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--ngc-bg);
    border: 1px solid var(--ngc-border);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ngc-text);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ngc-quick-btn i {
    color: var(--ngc-accent);
    font-size: 14px;
}

.ngc-quick-btn:hover {
    background: #0f172a !important;
    color: #ffffff !important;
    border-color: #0f172a !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.ngc-quick-btn:hover i,
.ngc-quick-btn:hover span {
    color: #ffffff !important;
}

/* Stati active e focus - testo sempre visibile */
.ngc-quick-btn:active,
.ngc-quick-btn:focus {
    background: #1e293b !important;
    color: #ffffff !important;
    border-color: #1e293b !important;
    outline: none;
}

.ngc-quick-btn:active i,
.ngc-quick-btn:active span,
.ngc-quick-btn:focus i,
.ngc-quick-btn:focus span {
    color: #ffffff !important;
}

/* Stato selezionato (quando ha classe .selected o .active) */
.ngc-quick-btn.selected,
.ngc-quick-btn.active {
    background: #0f172a !important;
    color: #ffffff !important;
    border-color: #0f172a !important;
}

.ngc-quick-btn.selected i,
.ngc-quick-btn.selected span,
.ngc-quick-btn.active i,
.ngc-quick-btn.active span {
    color: #ffffff !important;
}

/* Messages */
.ngc-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: ngc-slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ngc-slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ngc-message-bot {
    align-self: flex-start;
}

.ngc-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ngc-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--ngc-primary);
}

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

.ngc-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ngc-message-user .ngc-message-content {
    align-items: flex-end;
}

.ngc-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.ngc-message-bot .ngc-bubble {
    background: var(--ngc-bg);
    color: var(--ngc-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ngc-message-user .ngc-bubble {
    background: linear-gradient(135deg, var(--ngc-primary) 0%, var(--ngc-primary-light) 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ngc-message-time {
    font-size: 11px;
    color: var(--ngc-text-muted);
    padding: 0 4px;
}

/* Suggestions */
.ngc-suggestions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-left: 42px;
}

.ngc-chip {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--ngc-border);
    border-radius: 100px;
    font-size: 13px;
    color: var(--ngc-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ngc-chip:hover {
    background: var(--ngc-primary);
    color: #ffffff;
    border-color: var(--ngc-primary);
}

/* Typing Indicator */
.ngc-typing {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ngc-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--ngc-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.ngc-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--ngc-text-muted);
    border-radius: 50%;
    animation: ngc-bounce 1.4s infinite;
}

.ngc-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ngc-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ngc-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* Footer */
.ngc-footer {
    padding: 12px 16px;
    background: var(--ngc-bg);
    border-top: 1px solid var(--ngc-border);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.ngc-input-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--ngc-bg-secondary);
    border: 1px solid var(--ngc-border);
    border-radius: 100px;
    padding: 4px 8px;
    transition: all 0.2s ease;
}

.ngc-input-wrapper:focus-within {
    border-color: var(--ngc-primary);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.ngc-input-wrapper .ngc-btn-icon {
    width: 32px;
    height: 32px;
    background: transparent;
    color: var(--ngc-text-muted);
}

.ngc-input-wrapper .ngc-btn-icon:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--ngc-primary);
}

.ngc-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--ngc-text);
    outline: none;
    padding: 8px 4px;
}

.ngc-input::placeholder {
    color: var(--ngc-text-muted);
}

.ngc-btn-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ngc-primary) 0%, var(--ngc-primary-light) 100%);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.3);
}

.ngc-btn-send:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.4);
}

.ngc-btn-send:active {
    transform: scale(0.95);
}

/* Powered By */
.ngc-powered {
    text-align: center;
    padding: 8px;
    background: var(--ngc-bg);
    font-size: 11px;
    color: var(--ngc-text-muted);
    border-top: 1px solid var(--ngc-border);
}

.ngc-powered strong {
    color: var(--ngc-primary);
    font-weight: 600;
}

/* FAB Button */
.ngc-fab {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--ngc-primary) 0%, var(--ngc-primary-light) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ngc-fab:hover {
    transform: scale(1.08);
}

.ngc-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--ngc-primary) 0%, var(--ngc-primary-light) 100%);
    opacity: 0.4;
    animation: ngc-fabPulse 2s infinite;
}

@keyframes ngc-fabPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

.ngc-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

/* ========================================
   THEME VARIATIONS
   ======================================== */

/* Ocean Theme */
.ngc-container[data-theme="ocean"] .ngc-header,
.ngc-container[data-theme="ocean"] .ngc-welcome-card,
.ngc-container[data-theme="ocean"] .ngc-message-user .ngc-bubble,
.ngc-container[data-theme="ocean"] .ngc-btn-send {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
}

/* Forest Theme */
.ngc-container[data-theme="forest"] .ngc-header,
.ngc-container[data-theme="forest"] .ngc-welcome-card,
.ngc-container[data-theme="forest"] .ngc-message-user .ngc-bubble,
.ngc-container[data-theme="forest"] .ngc-btn-send {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

/* Sunset Theme */
.ngc-container[data-theme="sunset"] .ngc-header,
.ngc-container[data-theme="sunset"] .ngc-welcome-card,
.ngc-container[data-theme="sunset"] .ngc-message-user .ngc-bubble,
.ngc-container[data-theme="sunset"] .ngc-btn-send {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
}

/* Royal Theme */
.ngc-container[data-theme="royal"] .ngc-header,
.ngc-container[data-theme="royal"] .ngc-welcome-card,
.ngc-container[data-theme="royal"] .ngc-message-user .ngc-bubble,
.ngc-container[data-theme="royal"] .ngc-btn-send {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
}

/* Rose Theme */
.ngc-container[data-theme="rose"] .ngc-header,
.ngc-container[data-theme="rose"] .ngc-welcome-card,
.ngc-container[data-theme="rose"] .ngc-message-user .ngc-bubble,
.ngc-container[data-theme="rose"] .ngc-btn-send {
    background: linear-gradient(135deg, #e11d48 0%, #fb7185 100%);
}

/* Midnight Theme (default) */
.ngc-container[data-theme="midnight"] .ngc-header,
.ngc-container[data-theme="midnight"] .ngc-welcome-card,
.ngc-container[data-theme="midnight"] .ngc-message-user .ngc-bubble,
.ngc-container[data-theme="midnight"] .ngc-btn-send {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}
