/**
 * ============================================
 * CHATBOT STYLES v1.0
 * ============================================
 * Themeable CSS for decision-tree chatbot
 * Uses CSS variables for easy customization
 * ============================================
 */

/* ============================================
   CSS VARIABLES (Theme Colors)
   ============================================ */
:root {
    --primary: #2d5f8d;
    --primary-light: #4a8cc7;
    --accent: #e85d75;
    --text-dark: #1a2332;
    --text-light: #5c6b7f;
    --bg-light: #f8fafb;
    --bg-white: #ffffff;
    --border: #e1e6eb;
    --shadow-sm: 0 1px 3px rgba(29, 47, 71, 0.08);
    --shadow-md: 0 4px 12px rgba(29, 47, 71, 0.12);
    --shadow-lg: 0 8px 24px rgba(29, 47, 71, 0.15);
    --demo-warning: #f59e0b;
}

/* ============================================
   CHAT BUTTON (Floating)
   ============================================ */
.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(45, 95, 141, 0.4);
}

/* ============================================
   CHAT WINDOW
   ============================================ */
.chat-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 420px;
    height: 650px;
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease-out;
    resize: both;
    min-width: 320px;
    max-width: 800px;
    min-height: 400px;
    max-height: 90vh;
    z-index: 1000;
}

.chat-window.active {
    display: flex;
}

/* Size Variants */
.chat-window.chat-small {
    width: 380px;
    height: 550px;
}

.chat-window.chat-medium {
    width: 420px;
    height: 650px;
}

.chat-window.chat-large {
    width: 520px;
    height: 750px;
}

.chat-window.chat-xlarge {
    width: 650px;
    height: 850px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   CHAT HEADER
   ============================================ */
.chat-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-left {
    flex: 1;
}

.chat-header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.size-control {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.3s;
    font-weight: 500;
}

.size-control:hover {
    background: rgba(255, 255, 255, 0.3);
}

.size-control.active {
    background: rgba(255, 255, 255, 0.4);
}

.chat-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.95;
    margin-top: 0.25rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.status-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s;
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   TOPIC MENU BAR
   ============================================ */
.topic-menu,
.topic-tabs {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    flex-shrink: 0;
}

.topic-btn {
    background: var(--bg-light);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-dark);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.topic-btn:hover,
.topic-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================
   CHAT MESSAGES AREA
   ============================================ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-light);
}

.message {
    margin-bottom: 1rem;
    animation: fadeIn 0.4s ease-out;
}

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

.message-content {
    max-width: 90%;
    padding: 0.875rem 1.125rem;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.9375rem;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-content {
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-content a {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 600;
}

.bot-message .message-content a:hover {
    color: var(--primary-light);
}

/* ============================================
   TYPING INDICATOR
   ============================================ */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 1rem 1.25rem;
    background: var(--bg-white);
    border-radius: 16px;
    width: fit-content;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
    opacity: 0.6;
}

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

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

@keyframes typing {
    0%, 60%, 100% { 
        transform: translateY(0); 
        opacity: 0.4; 
    }
    30% { 
        transform: translateY(-8px); 
        opacity: 1; 
    }
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.action-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.action-btn:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn.secondary {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.action-btn.secondary:hover {
    background: var(--border);
}

/* ============================================
   CHAT INPUT AREA
   ============================================ */
.chat-input-area {
    padding: 1rem;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-family: inherit;
    font-size: 0.9375rem;
    resize: none;
    max-height: 100px;
    transition: border-color 0.3s;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.send-button {
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.send-button:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

/* ============================================
   DISCLAIMER
   ============================================ */
.disclaimer {
    font-size: 0.7rem;
    color: var(--text-light);
    text-align: center;
    padding: 0.5rem 1rem;
    background: #fff3cd;
    border-top: 2px solid var(--demo-warning);
    line-height: 1.3;
    flex-shrink: 0;
}

.disclaimer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.disclaimer a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 2rem);
        height: calc(100vh - 8rem);
        right: 1rem;
        bottom: 5rem;
    }
    
    .chat-window.chat-small,
    .chat-window.chat-medium,
    .chat-window.chat-large,
    .chat-window.chat-xlarge {
        width: calc(100vw - 2rem);
        height: calc(100vh - 8rem);
    }
    
    .topic-btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.875rem;
    }
}

/* ============================================
   SCROLLBAR STYLING (Optional)
   ============================================ */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
