/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #2c3e50;
    color: white;
    border-bottom: 3px solid #34495e;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

.model-selector-container {
    display: none; /* Hide model selector */
    align-items: center;
    gap: 0.5rem;
}

.model-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #ecf0f1;
}

.model-select {
    background-color: #34495e;
    color: white;
    border: 1px solid #5a6c7d;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.model-select:hover {
    background-color: #3e5368;
}

.model-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.clear-chat-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.clear-chat-btn:hover {
    background-color: #2980b9;
}

.clear-chat-btn:active {
    transform: translateY(1px);
}

/* Main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

/* Chat history */
.chat-history {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    color: #666;
    margin: 2rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

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

.message.assistant {
    align-items: flex-start;
}

.message-content {
    white-space: normal;              /* let HTML flow normally */
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;                 /* prevent weird overflow from margins */
}

.message-content ul,
.message-content ol {
  margin: 0.5em 0;
  padding-left: 1.25em;          /* space for the marker */
  list-style-position: inside;   /* marker is inside the box */
}

.message-content li {
  margin: 0.25em 0;
}

.message-content {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
    /*white-space: pre-wrap; */
}

.message.user .message-content {
    background-color: #3498db;
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-content {
    background-color: #ecf0f1;
    color: #2c3e50;
    border-bottom-left-radius: 6px;
}

.message-timestamp {
    font-size: 0.75rem;
    color: #95a5a6;
    margin: 0.25rem 0.5rem;
}

/* Thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin: 0 1rem;
    background-color: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #f39c12;
}

.thinking-dots {
    display: flex;
    margin-right: 0.5rem;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background-color: #f39c12;
    border-radius: 50%;
    margin-right: 4px;
    animation: thinking 1.4s infinite ease-in-out;
}

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

@keyframes thinking {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.thinking-text {
    color: #f39c12;
    font-style: italic;
    font-size: 0.9rem;
}

/* Chat form */
.chat-form {
    border-top: 1px solid #e0e0e0;
    background-color: white;
}

.input-container {
    display: flex;
    align-items: flex-end;
    padding: 1rem;
    gap: 0.75rem;
}

.message-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: #3498db;
}

.message-input::placeholder {
    color: #95a5a6;
}

.send-btn {
    width: 44px;
    height: 44px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.send-btn:hover {
    background-color: #2980b9;
}

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

.send-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-width: 100%;
    }

    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .header-controls {
        gap: 0.75rem;
    }

    .model-label {
        font-size: 0.8rem;
    }

    .model-select {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }

    .clear-chat-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .chat-history {
        padding: 0.75rem;
    }

    .message-content {
        max-width: 90%;
        padding: 0.6rem 0.8rem;
    }

    .input-container {
        padding: 0.75rem;
    }

    .message-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .model-selector-container {
        justify-content: center;
    }

    .message-content {
        max-width: 95%;
    }

    .input-container {
        padding: 0.5rem;
    }
}

/* Scrollbar styling */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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