* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: 20px;
}

.app-container {
    width: 100%;
    max-width: 800px;
    height: 85vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    max-width: 100%;
    gap: 15px;
    position: relative;
}

.header-text {
    flex: 1;
    text-align: left;
}

.header-icon {
    width: 67px;
    height: 67px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    flex-shrink: 0;
}

.header-icon:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
}

.header-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.app-header p {
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .app-header {
        padding: 15px;
    }
    
    .header-content {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .header-text {
        text-align: left;
    }
    
    .header-icon {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
    }
    
    .header-icon img {
        width: 100%;
        height: 100%;
    }
    
    .app-header h1 {
        font-size: 1.6rem;
    }
    
    .app-header p {
        font-size: 0.85rem;
    }
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    max-width: 85%;
    margin-bottom: 10px;
}

.user-message {
    align-self: flex-end;
}

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

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.bot-message .message-content {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 6px;
}

/* Markdown formatting for bot messages */
.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    color: #2c3e50;
}

.bot-message .message-content h1 { 
    font-size: 1.4em; 
    margin: 16px 0 12px 0;
}
.bot-message .message-content h2 { 
    font-size: 1.3em; 
    margin: 14px 0 10px 0;
}
.bot-message .message-content h3 { 
    font-size: 1.2em; 
    margin: 12px 0 8px 0;
}

/* First header in message shouldn't have top margin */
.bot-message .message-content h1:first-child,
.bot-message .message-content h2:first-child,
.bot-message .message-content h3:first-child {
    margin-top: 0;
}

.bot-message .message-content strong {
    font-weight: 600;
    color: #2c3e50;
}

.bot-message .message-content em {
    font-style: italic;
    color: #34495e;
}

.bot-message .message-content code {
    background: #f1f3f4;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #d73a49;
}

.bot-message .message-content pre {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
}

.bot-message .message-content pre code {
    background: none;
    padding: 0;
    color: #24292e;
    font-size: 0.85em;
}

.bot-message .message-content ul {
    margin: 0;
    padding-left: 20px;
}

.bot-message .message-content ol {
    margin: 16px 0;
    padding-left: 24px;
    list-style-type: decimal;
    /* counter-reset removed - let each <ol> start at 1 by default */
}

/* Numbered lists with sub-bullets get extra spacing */
.bot-message .message-content ol.numbered-with-sub > li {
    margin: 12px 0;
    line-height: 1.6;
}

/* Regular numbered list items */
.bot-message .message-content ol:not(.numbered-with-sub) > li {
    margin: 4px 0;
    line-height: 1.5;
}

/* Regular bullet list items */
.bot-message .message-content ul:not(.sub-bullets) > li {
    margin: 8px 0;
    line-height: 1.5;
}

/* Sub-bullets under numbered items - tighter spacing and more indentation */
.bot-message .message-content ul.sub-bullets {
    margin: 8px 0 8px 0;
    padding-left: 32px; /* More indented than numbers */
}

.bot-message .message-content ul.sub-bullets > li {
    margin: 4px 0; /* Tighter spacing for sub-bullets */
    line-height: 1.4;
}

/* Legacy fallback for simple lists */
.bot-message .message-content li {
    line-height: 1.5;
}

.bot-message .message-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.bot-message .message-content p:first-child {
    margin-top: 0;
}

.bot-message .message-content p:last-child {
    margin-bottom: 0;
}

.bot-message .message-content blockquote {
    margin: 12px 0;
    padding: 10px 15px;
    border-left: 4px solid #667eea;
    background: #f8f9ff;
    font-style: italic;
    color: #555;
}

.bot-message .message-content hr {
    margin: 16px 0;
    border: none;
    border-top: 2px solid #e9ecef;
}

.bot-message .message-content .section-break {
    margin: 16px 0;
    text-align: center;
    color: #667eea;
    font-weight: bold;
    letter-spacing: -1px;
}

.bot-message .message-content .horizontal-line {
    margin: 16px 0;
    text-align: center;
    color: #667eea;
    font-weight: bold;
    letter-spacing: -1px;
}

.welcome-message {
    max-width: 100%;
}

.welcome-message .message-content {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    text-align: center;
    border-radius: 12px;
    font-size: 0.9rem;
}

.welcome-message ul {
    list-style: none;
    margin-top: 10px;
}

.welcome-message li {
    margin: 5px 0;
    padding-left: 20px;
    position: relative;
}

.welcome-message li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #fff;
    font-weight: bold;
}

.welcome-message li.info-item::before {
    content: "ⓘ";
    font-size: 1.1em;
}

.welcome-message li.privacy-item::before {
    content: "ⓘ";
    font-size: 1.1em;
}

.file-attachment {
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.file-attachment img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 8px;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    color: #666;
    font-size: 0.9rem;
    gap: 10px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #667eea;
    animation: loading 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.chat-input-form {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: nowrap;
}

.file-upload-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
}

.file-upload-btn {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.file-upload-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.text-input-container {
    flex: 1;
    display: flex;
    gap: 8px;
    min-width: 0;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
    background: white;
}

#messageInput:focus {
    border-color: #667eea;
}

#sendButton {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 80px;
    justify-content: center;
}

#sendButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.file-preview {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border: 2px dashed #e9ecef;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.file-preview.has-file {
    border-color: #667eea;
    background: #f8f9ff;
}

.file-preview-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-name {
    font-weight: 600;
    color: #333;
}

.file-type {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
}

.remove-file-btn {
    width: 24px;
    height: 24px;
    border-radius: 12px;
    background: #dc3545;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
}

.remove-file-btn:hover {
    background: #c82333;
}

.file-preview-media img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    object-fit: cover;
}

.file-preview-media audio {
    width: 100%;
    margin-top: 10px;
}

    .error-message {
        background: #f8d7da;
        color: #721c24;
        padding: 10px 15px;
        border-radius: 8px;
        margin: 10px 0;
        border: 1px solid #f5c6cb;
    }

@media (max-width: 900px) {
    .input-container {
        gap: 5px;
    }
    
    .file-upload-buttons {
        gap: 3px;
    }
    
    .file-upload-btn {
        width: 32px;
        height: 32px;
        border-radius: 16px;
        font-size: 0.9rem;
    }
    
    #messageInput {
        font-size: 0.9rem;
        padding: 8px 10px;
    }
    
    #sendButton {
        padding: 8px 10px;
        min-width: 55px;
        font-size: 0.85rem;
    }
    
    .text-input-container {
        gap: 4px;
    }
}

@media (max-width: 800px) {
    .input-container {
        gap: 8px;
    }
    
    .file-upload-buttons {
        gap: 5px;
    }
    
    .file-upload-btn {
        width: 36px;
        height: 36px;
        border-radius: 18px;
        font-size: 1rem;
    }
    
    #messageInput {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
    
    #sendButton {
        padding: 10px 14px;
        min-width: 65px;
        font-size: 0.9rem;
    }
    
    .text-input-container {
        gap: 6px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .app-container {
        height: 85vh;
        max-height: 700px;
        border-radius: 15px;
    }
    
    .app-header {
        padding: 15px;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-input-form {
        padding: 15px;
    }
    
    .message {
        max-width: 95%;
    }
    
    .input-container {
        flex-direction: row;
        gap: 4px;
        flex-wrap: nowrap;
    }
    
    .file-upload-buttons {
        gap: 2px;
        flex-shrink: 0;
    }
    
    .file-upload-btn {
        width: 28px;
        height: 28px;
        border-radius: 14px;
        font-size: 0.8rem;
    }
    
    .text-input-container {
        flex: 1;
        min-width: 0;
        gap: 3px;
    }
    
    #messageInput {
        min-width: 0;
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    #sendButton {
        padding: 8px 12px;
        min-width: 50px;
        font-size: 0.8rem;
    }
}