/* ===================================
   Chatbot UI Styles - AdSense Optimized
   =================================== */

.chatbot-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

.chatbot-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-xl);
    align-items: start;
}

.chatbot-main {
    min-width: 0;
}

.chatbot-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    position: sticky;
    top: calc(72px + var(--space-lg));
}

/* Chat Container */
.chat-container {
    width: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color-light);
    min-height: 600px;
    max-height: calc(100vh - 200px);
}

.chat-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--text-inverse);
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h1 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-inverse);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-base);
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-xl);
    background: var(--bg-secondary);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 300px;
}

.message {
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.message:last-child {
    margin-bottom: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-bubble {
    max-width: 75%;
    width: fit-content;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-xl);
    word-wrap: break-word;
    word-break: break-word;
    line-height: var(--line-height-relaxed);
    font-size: var(--font-size-base);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #ffffff !important;
    border-bottom-right-radius: var(--radius-sm);
    font-weight: var(--font-weight-semibold);
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.message.user .message-bubble p {
    color: #ffffff !important;
    margin-bottom: 0.5rem;
}

.message.user .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.user .message-bubble * {
    color: #ffffff !important;
}

.message.user .message-bubble strong {
    color: #ffffff !important;
    font-weight: var(--font-weight-bold);
}

.message.user .message-bubble a {
    color: #ffffff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    text-decoration: underline;
}

.message.assistant .message-bubble {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.message.assistant .message-bubble p {
    margin-bottom: var(--space-md);
}

.message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
    margin: var(--space-md) 0;
    padding-left: var(--space-xl);
}

.message.assistant .message-bubble li {
    margin-bottom: var(--space-sm);
}

.message.assistant .message-bubble strong {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.message.assistant .message-bubble a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(37, 99, 235, 0.3);
    transition: all var(--transition-fast);
}

.message.assistant .message-bubble a:hover {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}

.message.assistant .message-bubble code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

.message.assistant .message-bubble pre {
    background: var(--bg-tertiary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-md) 0;
    border: 1px solid var(--border-color);
}

.message.assistant .message-bubble pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.streaming-cursor {
    display: inline-block;
    animation: blink 1s step-end infinite;
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.node-status {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: var(--font-size-sm);
}

.thinking-process {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-sm) 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.loading {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
}

.loading-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-primary);
    border-radius: 50%;
    animation: loadingBounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input-container {
    padding: var(--space-lg) var(--space-xl);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color-light);
    flex-shrink: 0;
}

.chat-input-form {
    display: flex;
    gap: var(--space-md);
}

.chat-input {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-family: var(--font-family-sans);
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: all var(--transition-base);
    resize: none;
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: var(--bg-primary);
}

.chat-input::placeholder {
    color: var(--text-tertiary);
}


/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-secondary);
}

.welcome-message h2 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.welcome-message p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--space-sm);
}

/* Responsive */
@media (max-width: 1024px) {
    .chatbot-layout {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }
    
    .chatbot-sidebar {
        order: -1;
        position: relative;
        top: 0;
    }
    
    .chat-container {
        max-height: calc(100vh - 150px);
    }
}

@media (max-width: 768px) {
    .chatbot-wrapper {
        padding: var(--space-md);
    }
    
    .chat-header {
        padding: var(--space-md) var(--space-lg);
    }
    
    .chat-header h1 {
        font-size: var(--font-size-lg);
    }
    
    .chat-messages {
        padding: var(--space-lg);
    }
    
    .chat-input-container {
        padding: var(--space-md) var(--space-lg);
        padding-bottom: max(var(--space-md), calc(var(--space-md) + env(safe-area-inset-bottom, 0px)));
    }
    
    .chat-input {
        font-size: 16px; /* iOS zoom 방지 */
        padding: var(--space-sm) var(--space-md);
    }
    
    .send-btn {
        padding: var(--space-sm) var(--space-md);
        font-size: var(--font-size-sm);
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: var(--font-size-sm);
    }
}

/* Thinking Process Styles */
.thinking-process {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.thinking-process.collapsed .thinking-content {
    display: none;
}

.thinking-process.expanded .thinking-content {
    display: block;
}

.thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.thinking-title {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.thinking-toggle {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    transition: transform var(--transition-base);
}

.thinking-step {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color-light);
}

.thinking-step:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.thinking-step-title {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
    margin-bottom: var(--space-xs);
}

.thinking-step-content {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    margin-top: var(--space-xs);
}

.thinking-links {
    margin-top: var(--space-sm);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.thinking-link {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    color: var(--color-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    transition: all var(--transition-base);
    border: 1px solid var(--border-color-light);
}

.thinking-link:hover {
    background: var(--color-primary);
    color: var(--text-inverse);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.node-status-container {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-secondary);
}

.empty-state h2 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.empty-state p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
}

/* FAQ Image Styles */
.faq-image-container {
    margin: var(--space-md) 0;
    text-align: center;
}

.faq-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin: var(--space-sm) 0;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.faq-image-error {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin: var(--space-sm) 0;
}

.faq-image-error a {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Send Button */
.send-btn {
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .chatbot-wrapper {
        padding: var(--space-sm);
    }
    
    .chat-header h1 {
        font-size: var(--font-size-base);
    }
    
    .clear-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--font-size-xs);
    }
    
    .chat-input-container {
        padding-bottom: max(var(--space-sm), calc(var(--space-sm) + env(safe-area-inset-bottom, 20px)));
    }
}
