/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff6b35;
    --secondary-color: #ff8c42;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffa726;
    --info-color: #ff9e40;
    --light-color: #fff8f4;
    --dark-color: #2d1810;
    --white: #ffffff;
    --black: #000000;
    
    --bg-primary: #fff8f4;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ffede3;
    
    --text-primary: #2d1810;
    --text-secondary: #8b4513;
    --text-muted: #b8860b;
    
    --border-color: #ffd4b3;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
    
    --animation-speed: 0.3s;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-family: var(--font-family);
    /* background: linear-gradient(135deg, #ff9a56 0%, #ff6b35 100%); */
    background: #000000;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Chat Container */
.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    min-height: 600px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Chat Header */
.chat-header {
    /* background: linear-gradient(0deg, var(--primary-color), #e55100); */
    background: var(--primary-color);  
    color: var(--white);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Logo image styling */
.logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0;
    max-width: none;
    border-radius: 0;
    background: transparent;
}

/* Logo in header avatar */
.avatar .logo-img {
    padding: 0;
}

/* Logo in welcome avatar */
.welcome-avatar .logo-img {
    padding: 0;
}

/* Logo in message avatars */
.message-avatar .logo-img {
    padding: 0;
    filter: none;
}

/* Logo in assistant message avatar - keep original colors */
.message.assistant .message-avatar .logo-img {
    filter: none;
    background: transparent;
    border-radius: 0;
}

.header-text h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
}

.header-text p {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

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

.header-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    cursor: pointer;
    transition: all var(--animation-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Pretext Panel */
.pretext-panel {
    width: 300px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--animation-speed);
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
}

.pretext-panel.active {
    transform: translateX(0);
}

.pretext-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pretext-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-pretext {
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--border-radius-sm);
    transition: all var(--animation-speed);
}

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

.pretext-categories {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.pretext-category {
    margin-bottom: 20px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.category-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.pretext-message {
    padding: 12px 15px;
    margin: 5px 0;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--animation-speed);
    font-size: 14px;
    line-height: 1.4;
}

.pretext-message:hover {
    border-color: var(--primary-color);
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.pretext-message .text {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.pretext-message .description {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Messages Area */
.messages-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.messages-area::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

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

/* Welcome Message */
.welcome-message {
    /* background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary)); */
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.welcome-avatar {
    width: 60px;
    height: 60px;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: var(--text-primary);
    font-size: 24px;
}

.welcome-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    line-height: 1.6;
}

.welcome-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-btn {
    padding: 12px 20px;
    border: 2px solid var(--primary-color);
    background: var(--white);
    color: var(--primary-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--animation-speed);
    display: flex;
    align-items: center;
    gap: 8px;
}

.welcome-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Chat Messages */
.message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn var(--animation-speed) ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--success-color), #20c997);
    color: var(--white);
    border-radius: 50%;
}

.message.assistant .message-avatar {
    background: transparent;
    color: var(--text-primary);
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.message-bubble {
    padding: 15px 18px;
    border-radius: var(--border-radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary-color), #e55100);
    color: var(--white);
    border-bottom-right-radius: 6px;
}

.message.assistant .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.message-status {
    font-size: 10px;
}

.message-status.sent {
    color: var(--text-muted);
}

.message-status.delivered {
    color: var(--info-color);
}

.message-status.read {
    color: var(--success-color);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    /* background: var(--bg-primary); */
    /* border-top: 1px solid var(--border-color); */
    font-size: 13px;
    color: var(--text-secondary);
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingDot 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 typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 20px;
}

.input-area {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px 50px 12px 15px;
    transition: all var(--animation-speed);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#message-input {
    width: 100%;
    border: none;
    background: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    max-height: 120px;
    min-height: 20px;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.input-actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 5px;
}

.input-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--animation-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-btn:hover {
    color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
}

.send-btn {
    width: 50px;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), #e55100);
    color: var(--white);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--animation-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.character-count {
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    padding-right: 5px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--white);
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 16px;
    font-weight: 500;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    min-width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn var(--animation-speed) ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px 20px 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal {
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--border-radius-sm);
    transition: all var(--animation-speed);
}

.close-modal:hover {
    color: var(--error-color);
    background: rgba(220, 53, 69, 0.1);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px 20px;
    text-align: right;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--animation-speed);
    font-size: 14px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}



/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-tertiary: #404040;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --text-muted: #808080;
        --border-color: #404040;
    }
    
    body {
        /* background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%); */
        background: #000000;
    }
    
    .message.assistant .message-bubble {
        background: var(--bg-tertiary);
        border-color: var(--border-color);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.action-btn:focus,
.input-btn:focus,
.send-btn:focus,
.welcome-btn:focus,
.pretext-message:focus,
.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

#message-input:focus {
    outline: none;
}

/* Small media screens */


/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
    
    .message-bubble {
        border: 2px solid currentColor;
    }
}