/* 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;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Header */
h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.5em;
    flex-shrink: 0; /* Prevent header from shrinking */
}

/* Chat area */
.chat-area {
    flex: 1;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex child scrolling */
}

#conversation-display {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Prevent height changes */
    min-height: 0;
    /* Always show scrollbar to prevent layout shifts */
    scrollbar-gutter: stable;
}

/* Custom scrollbar styling to ensure consistent appearance */
#conversation-display::-webkit-scrollbar {
    width: 8px;
}

#conversation-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#conversation-display::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#conversation-display::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Messages */
.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

.message.user {
    text-align: right;
}

.message.assistant {
    text-align: left;
}

.speaker {
    font-weight: bold;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.message.user .speaker {
    color: #3498db;
}

.message.assistant .speaker {
    color: #27ae60;
}

.text {
    display: inline-block;
    background: #f0f0f0;
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 70%;
    word-wrap: break-word;
}

.message.user .text {
    background: #3498db;
    color: white;
}

.message.assistant .text {
    background: #ecf0f1;
    color: #2c3e50;
}

/* Controls */
.controls {
    text-align: center;
    flex-shrink: 0; /* Prevent controls from shrinking */
    padding: 10px 0;
}

.btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1em;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.active {
    background: #e74c3c;
}

.btn-primary.active:hover {
    background: #c0392b;
}

/* Status */
.status {
    margin-top: 15px;
    color: #7f8c8d;
    font-size: 0.9em;
    min-height: 20px;
}

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

/* Model Loading UI */
.model-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.model-loading.hidden {
    display: none;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.loading-content h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.loading-content p {
    color: #7f8c8d;
    margin-bottom: 25px;
    line-height: 1.6;
}

.progress-container {
    width: 100%;
    height: 20px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Translation tooltip */
.translatable {
    position: relative;
    cursor: help;
    border-bottom: 1px dashed #3498db;
}

.translatable:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.translation-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    white-space: nowrap;
    max-width: 300px;
    white-space: normal;
    word-wrap: break-word;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    margin-bottom: 5px;
}


/* Adjust message text positioning for tooltip */
.message.assistant .text {
    position: relative;
    margin-bottom: 10px;
}

/* Responsive design */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .chat-area {
        padding: 15px;
    }
    
    .text {
        max-width: 85%;
    }
    
    .btn-primary {
        padding: 12px 30px;
        font-size: 1em;
    }
    
    .loading-content {
        padding: 20px;
    }
    
    .translation-tooltip {
        max-width: 250px;
        font-size: 0.8em;
        left: 10px;
        transform: none;
    }
    
}