@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&display=swap');

:root {
    --main-color: #141F33;        /* CMYK: 60_40_0_80 */
    --secondary-color: #00E6FF;   /* CMYK: 100_10_0_0 */
    --main-light: #2A3F5F;        /* Lighter variant of main color */
    --secondary-dark: #00B8CC;     /* Darker variant of secondary color */
}

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

body {
    font-family: 'Titillium Web', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--main-color) 0%, var(--main-light) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 800px;
    height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--main-color) 0%, var(--main-light) 100%);
    color: white;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.header.minimized {
    padding: 10px 20px;
}

.header.minimized .header-content p {
    display: none;
}

.header.minimized .logo-container {
    margin-bottom: 0;
}

.header.minimized .header-content h1 {
    font-size: 1.1rem;
}

.header.minimized .header-logo {
    width: 30px;
    height: 30px;
}

.header.minimized .reset-button {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
    top: 8px;
    right: 8px;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 5px;
}

.header-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    /* Remove filter to show original colors */
}

.header-content h1 {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 700; /* Titillium Bold */
    font-size: 1.4rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}

.header-content p {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 300; /* Titillium Light */
    opacity: 0.9;
    font-size: 1rem;
    margin-bottom: 15px;
}

.reset-button {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400; /* Titillium Regular */
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
}

.reset-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px) rotate(180deg);
}

.reset-button:active {
    transform: translateY(0) rotate(180deg);
    background: rgba(255, 255, 255, 0.1);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    padding-bottom: 80px; /* Increased from 40px to 80px for better bottom spacing */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f8f9fa;
    height: 0; /* Force flex to work properly */
    min-height: 300px; /* Minimum height for scrolling */
    scroll-behavior: smooth; /* Smooth scrolling */
    scrollbar-width: thin; /* Thin scrollbar for better UX */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scroll-padding-bottom: 80px; /* Increased from 40px to 80px to ensure space at bottom */
    box-sizing: border-box; /* Include padding in height calculation */
}

.message {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: messageSlide 0.3s ease-out;
}

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

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-dark) 100%);
    color: white;
}

.bot-message .message-avatar {
    background: #e9ecef;
    color: var(--main-color);
}

.bot-avatar-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-dark) 100%);
    color: white;
}

.message-content p {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400; /* Titillium Regular */
    margin: 0;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Formatted response styles */
.message-text {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400;
    line-height: 1.5;
    word-wrap: break-word;
}

.response-paragraph {
    margin: 0 0 12px 0;
    color: #333;
}

.response-paragraph:last-child {
    margin-bottom: 0;
}

.response-header {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 600;
    color: var(--main-color);
    margin: 16px 0 8px 0;
    line-height: 1.3;
}

.response-header:first-child {
    margin-top: 0;
}

.response-header h1 {
    font-size: 1.3rem;
    margin: 0;
}

.response-header h2 {
    font-size: 1.2rem;
    margin: 0;
}

.response-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.response-list {
    margin: 8px 0 12px 0;
    padding-left: 20px;
    color: #333;
}

.response-list:last-child {
    margin-bottom: 0;
}

.response-bullet {
    margin: 4px 0;
    position: relative;
    color: #333;
}

.response-bullet::marker {
    color: var(--secondary-color);
}

.response-numbered {
    margin: 4px 0;
    color: #333;
}

.response-numbered::marker {
    color: var(--secondary-color);
    font-weight: 600;
}

.message-text strong {
    font-weight: 600;
    color: var(--main-color);
}

.message-text em {
    font-style: italic;
    color: #555;
}

.message-text code {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
}

/* Special styling for bot messages with formatting */
.bot-message .message-text {
    color: #333;
}

.bot-message .response-header {
    color: var(--main-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 4px;
}

.bot-message .response-list {
    color: #333;
}

.bot-message .response-bullet::marker,
.bot-message .response-numbered::marker {
    color: var(--secondary-color);
}

.message-time {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 300; /* Titillium Light */
    font-size: 0.75rem;
    opacity: 0.7;
    display: block;
    margin-top: 5px;
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0; /* Prevent shrinking */
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.attachment-display {
    margin-bottom: 12px;
    animation: attachmentSlideDown 0.3s ease-out;
}

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

.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 16px;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400;
    color: #333;
    position: relative;
}

.attachment-item i {
    color: var(--main-color);
    font-size: 1rem;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.3;
}

.attachment-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.attachment-remove:hover {
    background: #e9ecef;
    color: #666;
}

.attachment-remove i {
    font-size: 0.8rem;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 5px;
    border: 2px solid #e9ecef;
    transition: border-color 0.3s ease;
    position: relative;
}

.chat-input-wrapper:focus-within {
    border-color: var(--secondary-color);
}

#messageInput {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400; /* Titillium Regular */
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 1rem;
    outline: none;
    color: #333;
}

#messageInput::placeholder {
    color: #999;
}

.plus-button {
    width: 45px;
    height: 45px;
    border: none;
    background: #e9ecef;
    color: #666;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.plus-button:hover {
    background: #dee2e6;
    color: #495057;
    transform: scale(1.05);
}

.plus-button:active {
    transform: scale(0.95);
}

.plus-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 8px;
    margin-bottom: 8px;
    min-width: 280px;
    z-index: 1000;
    display: none;
    animation: menuSlideDown 0.2s ease-out;
}

.plus-menu.show {
    display: block;
}

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

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400;
    color: #333;
}

.menu-item:hover {
    background: #f8f9fa;
}

.menu-item i {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--main-color);
}

.menu-item span {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.3;
}

.send-button {
    width: 45px;
    height: 45px;
    border: none;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-dark) 100%);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 230, 255, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

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

.typing-indicator {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 600; /* Titillium Semibold */
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #666;
    font-size: 0.9rem;
}

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

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

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

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Ensure scrolling works on all browsers - consolidated with main rule above */

/* Responsive design */
@media (max-width: 768px) {
    .container {
        height: 90vh;
        margin: 10px;
        border-radius: 15px;
    }
    
    .header-content h1 {
        font-size: 1.1rem;
    }
    
    .header-logo {
        width: 35px;
        height: 35px;
    }
    
    .logo-container {
        gap: 12px;
    }
    
    .reset-button {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        margin: 12px auto 0 auto;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input-wrapper {
        padding: 3px;
    }
    
    #messageInput {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
    
    .plus-button {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
    
    .plus-menu {
        min-width: 260px;
        left: -10px;
    }
    
    .attachment-item {
        padding: 10px 14px;
    }
    
    .attachment-text {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        height: 95vh;
        margin: 5px;
    }
    
    .header {
        padding: 15px;
    }
    
    .header.minimized {
        padding: 8px 15px;
    }
    
    .header.minimized .header-content h1 {
        font-size: 1rem;
    }
    
    .header.minimized .header-logo {
        width: 25px;
        height: 25px;
    }
    
    .header.minimized .reset-button {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
        margin: 6px auto 0 auto;
    }
    
    .chat-messages {
        padding: 15px;
        min-height: 250px; /* Minimum height for mobile scrolling */
    }
    
    .chat-input-container {
        padding: 15px;
    }
}

/* Streaming cursor animation */
.streaming-cursor {
    animation: blink 1s infinite;
    color: var(--secondary-color);
    font-weight: bold;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
