.titan-prd-ai-container-v2 {
    --primary-color: #3b82f6;
    --accent-color: #10b981;
    --bg-color: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --text-light: #6b7280;
    
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 56rem; /* max-w-4xl */
    margin: 0 auto;
    /* padding: 1rem; */
    position: relative;
    
    /* Beautiful gradient background */
    background: linear-gradient(135deg, 
        #2a3257 0%, 
        #322045 25%, 
        #462b49 50%, 
        #3d151b 75%, 
        #163047 100%);
    background-size: 400% 400%;
    /* animation: gradientShift 15s ease infinite; */
    border-radius: 1.5rem;
    /* min-height: 500px; */
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Main Chat Container - Glassmorphism Effect */
.titan-prd-ai-chat-window-v2 {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Chat Header - macOS Style */
.titan-prd-ai-header-v2 {
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.titan-prd-ai-window-controls-v2 {
    display: flex;
    gap: 0.5rem;
}

.titan-prd-ai-window-control-v2 {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    cursor: pointer;
}

.titan-prd-ai-window-control-v2:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.titan-prd-ai-window-control-v2.red {
    background: #ef4444;
    position: relative;
}

.titan-prd-ai-window-control-v2.yellow {
    background: #eab308;
    position: relative;
}

.titan-prd-ai-window-control-v2.green {
    background: #22c55e;
    position: relative;
}

.titan-prd-ai-window-control-v2:hover::after {
    content: '';
    position: absolute;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.7);
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
}

.titan-prd-ai-window-control-v2.red:hover::after {
    content: 'x';
    font-size: 12px;
}

.titan-prd-ai-window-control-v2.yellow:hover::after {
    content: '-';
    font-size: 14px;
}

.titan-prd-ai-window-control-v2.green:hover::after {
    content: '+';
    font-size: 12px;
}

.titan-prd-ai-bot-info-v2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

.titan-prd-ai-avatar-v2 {
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.titan-prd-ai-avatar-v2 svg {
    width: 1rem;
    height: 1rem;
    color: white;
}

.titan-prd-ai-avatar-v2 img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.titan-prd-ai-bot-name-v2 {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
}

.titan-prd-ai-status-indicator-v2 {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--accent-color);
    border-radius: 50%;
    margin-left: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Messages Area */
.titan-prd-ai-messages-v2 {
    height: 24rem; /* h-96 */
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.titan-prd-ai-messages-v2::-webkit-scrollbar {
    width: 6px;
}

.titan-prd-ai-messages-v2::-webkit-scrollbar-track {
    background: transparent;
}

.titan-prd-ai-messages-v2::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.titan-prd-ai-messages-v2::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Message Styling */
.titan-prd-ai-message-v2 {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.titan-prd-ai-user-message-v2 {
    justify-content: flex-end;
}

.titan-prd-ai-user-message-v2 .titan-prd-ai-message-avatar-v2 {
    order: 2;
    margin-left: 0.75rem;
    margin-right: 0;
}

.titan-prd-ai-message-avatar-v2 {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.titan-prd-ai-message-avatar-v2 svg {
    width: 28px;
    height: 28px;
    color: white;
}

.titan-prd-ai-message-avatar-v2 img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.titan-prd-ai-user-message-v2 .titan-prd-ai-message-avatar-v2 {
    background: linear-gradient(135deg, var(--accent-color), #059669);
}

.titan-prd-ai-message-content-v2 {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
    padding: 1rem;
    max-width: 28rem; /* max-w-md */
    color: white;
    line-height: 1.5;
}

.titan-prd-ai-bot-message-v2 .titan-prd-ai-message-content-v2 {
    border-top-left-radius: 0.25rem;
}

.titan-prd-ai-user-message-v2 .titan-prd-ai-message-content-v2 {
    border-top-right-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.15);
}

.titan-prd-ai-message-content-v2 p {
    margin: 0 0 0.5rem 0;
}

.titan-prd-ai-message-content-v2 p:last-child {
    margin-bottom: 0;
}

.titan-prd-ai-message-content-v2 strong {
    font-weight: 600;
}

.titan-prd-ai-message-content-v2 a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
    font-weight: 500;
    transition: all 0.2s ease;
    word-break: break-all;
}

.titan-prd-ai-message-content-v2 a:hover {
    color: white;
    text-decoration-thickness: 2px;
}

#single-post-content .titan-prd-ai-container-v2 .titan-prd-ai-message-content-v2 img.emoji,
.titan-prd-ai-container-v2 .titan-prd-ai-message-content-v2 img.emoji {
    margin-bottom: 0 !important;
    display: inline !important;
    width: 1.2em !important;
    height: 1.2em !important;
    vertical-align: -0.1em !important;
}

/* Input Area */
.titan-prd-ai-input-area-v2 {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.titan-prd-ai-input-wrapper-v2 {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.titan-prd-ai-input-v2 {
    flex: 1;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 0.5rem !important;
    padding: 0.75rem 1rem !important;
    color: white !important;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    min-height: 45px;
    height: 45px;
}

.titan-prd-ai-input-v2::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.titan-prd-ai-input-v2:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5) !important;
}

.titan-prd-ai-send-btn-v2 {
    background: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 0.5rem !important;
    padding: 0.75rem 1.5rem !important;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.titan-prd-ai-send-btn-v2:hover:not(:disabled) {
    background: #2563eb !important;
    transform: translateY(-1px);
}

.titan-prd-ai-send-btn-v2:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.titan-prd-ai-send-btn-v2 svg {
    width: 1rem;
    height: 1rem;
}

p.titan-prd-ai-input-hint-v2,
#single-post-content p.titan-prd-ai-input-hint-v2{
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 14px !important;
    margin: 9px 5px 0 !important;
    line-height: 1.4 !important;
}

/* Loading Animation */
.titan-prd-ai-loading-v2 {
    padding: 1rem 1.5rem;
    text-align: center;
}

/* iMessage-style typing indicator */
.titan-prd-ai-typing-message-v2 {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

.titan-prd-ai-typing-bubble-v2 {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
    border-top-left-radius: 0.25rem;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
}

.titan-prd-ai-typing-dot-v2 {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.titan-prd-ai-typing-dot-v2:nth-child(1) {
    animation-delay: 0s;
}

.titan-prd-ai-typing-dot-v2:nth-child(2) {
    animation-delay: 0.2s;
}

.titan-prd-ai-typing-dot-v2:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.4;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Legacy typing indicator (keeping for compatibility) */
.titan-prd-ai-typing-indicator-v2 {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.titan-prd-ai-typing-indicator-v2 span {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.titan-prd-ai-typing-indicator-v2 span:nth-child(1) {
    animation-delay: -0.32s;
}

.titan-prd-ai-typing-indicator-v2 span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* New Chat Button */
.titan-prd-ai-new-chat-btn-v2 {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 0.5rem !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.titan-prd-ai-new-chat-btn-v2:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px);
}

.titan-prd-ai-new-chat-btn-v2 svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* Footer */
.titan-prd-ai-footer-v2 {
    padding: 0.75rem 1rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.titan-prd-ai-footer-logo-v2 {
    height: 1.25rem;
    opacity: 0.7;
    filter: brightness(0) invert(1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .titan-prd-ai-container-v2 {
        padding: 0.5rem;
        max-width: 100%;
    }
    
    .titan-prd-ai-header-v2 {
        padding: 0.75rem;
    }
    
    .titan-prd-ai-messages-v2 {
        height: 20rem;
        padding: 1rem;
    }
    
    .titan-prd-ai-input-area-v2 {
        padding: 0.75rem;
    }
    
    .titan-prd-ai-message-content-v2 {
        max-width: calc(100vw - 6rem);
    }
    
    .titan-prd-ai-new-chat-btn-v2 {
        position: static;
        margin: 0.5rem;
        align-self: flex-end;
    }
    
    .titan-prd-ai-send-btn-v2 {
        padding: 0.75rem 1rem !important;
    }
    
    .titan-prd-ai-send-btn-v2 span {
        display: none;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .titan-prd-ai-container-v2 {
        --text-color: #f3f4f6;
        --text-light: #d1d5db;
    }
}

/* Focus styles for accessibility */
.titan-prd-ai-send-btn-v2:focus,
.titan-prd-ai-new-chat-btn-v2:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Minimize and Fullscreen States */
.titan-prd-ai-container-v2.minimized .titan-prd-ai-chat-window-v2 {
    display: none;
}

/* Ensure minimized state overrides fullscreen */
.titan-prd-ai-container-v2.minimized.fullscreen {
    position: relative;
    width: auto;
    height: auto;
    z-index: auto;
    margin: auto;
}

.titan-prd-ai-floating-icon-v2 {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 99999999;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.titan-prd-ai-floating-icon-v2:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.titan-prd-ai-floating-icon-v2 svg {
    width: 32px;
    height: 32px;
    color: white;
}

.titan-prd-ai-floating-icon-v2 img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

/* Fullscreen Mode */
.titan-prd-ai-container-v2.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    z-index: 999999999999;
    margin: 0;
    border-radius: 0;
}

.titan-prd-ai-container-v2.fullscreen .titan-prd-ai-chat-window-v2 {
    width: 100%;
    height: 100vh;
    border-radius: 0;
}

.titan-prd-ai-container-v2.fullscreen .titan-prd-ai-messages-v2 {
    height: calc(100vh - 200px);
}

/* Closed State */
.titan-prd-ai-closed-message-v2 {
    padding: 2rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.titan-prd-ai-closed-message-v2 p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    font-size: 1rem;
}
