/* Modern CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 25%, #45b7d1 50%, #96ceb4 75%, #feca57 100%);
    background-size: 400% 400%;
    animation: monsterGradient 15s ease infinite;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

@keyframes monsterGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

/* Header */
.chat-header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 50%, #ff8a80 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="25" cy="25" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="1" fill="rgba(255,255,255,0.15)"/><circle cx="90" cy="40" r="1.2" fill="rgba(255,255,255,0.1)"/><circle cx="15" cy="60" r="0.8" fill="rgba(255,255,255,0.12)"/></svg>');
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
    z-index: 1;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
    backdrop-filter: blur(10px);
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Model Controls Section */
.model-controls-section {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: 15px 20px 5px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 5;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.model-filter, .model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.model-filter label, .model-selector label {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

#price-filter, #category-filter, #model-select {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #333;
    min-width: 200px;
    cursor: pointer;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

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

/* Tab Content */
.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tab-panel.active {
    display: flex;
}

/* Evaluation Tab */
.evaluation-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    padding: 40px;
}

.evaluation-placeholder {
    text-align: center;
    max-width: 600px;
    background: white;
    padding: 60px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.placeholder-icon {
    font-size: 4rem;
    color: #4f46e5;
    margin-bottom: 20px;
}

.evaluation-placeholder h2 {
    color: #1e293b;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.evaluation-placeholder p {
    color: #64748b;
    margin-bottom: 40px;
    font-size: 1.1rem;
}

.placeholder-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 10px;
    font-weight: 500;
    color: #475569;
}

.feature-item i {
    color: #4f46e5;
    font-size: 1.2rem;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.welcome-icon {
    font-size: 4rem;
    color: #4f46e5;
    margin-bottom: 20px;
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #1e293b;
}

.welcome-message p {
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.model-info {
    background: rgba(79, 70, 229, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
}

/* Enhanced Model Info Card Styles */
.model-info-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.9));
    border: 2px solid rgba(79, 70, 229, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-top: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.model-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(79, 70, 229, 0.1);
}

.creature-name {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.provider-badge {
    background: linear-gradient(135deg, #feca57, #ff9ff3);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(254, 202, 87, 0.3);
}

.model-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

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

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: #1e293b;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4f46e5;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.capabilities, .safety-info, .description {
    margin-bottom: 15px;
}

.capability-tags, .safety-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.capability-tag {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

.safety-badge {
    background: linear-gradient(135deg, #96ceb4, #85c1a5);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(150, 206, 180, 0.3);
}

.safety-badge.moderated {
    background: linear-gradient(135deg, #feca57, #ff9ff3);
    box-shadow: 0 2px 8px rgba(254, 202, 87, 0.3);
}

.description-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #475569;
    background: rgba(248, 250, 252, 0.8);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #4f46e5;
}

.show-more-btn {
    background: transparent;
    border: 1px solid #4f46e5;
    color: #4f46e5;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.3s ease;
}

.show-more-btn:hover {
    background: #4f46e5;
    color: white;
}

.external-links {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(79, 70, 229, 0.1);
}

.hf-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.hf-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    color: white;
    text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .model-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .model-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .creature-name {
        text-align: center;
        font-size: 1.1rem;
    }
    
    .provider-badge {
        text-align: center;
    }
}

.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 100%;
}

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

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

.message.user .message-avatar {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.message-content {
    background: white;
    padding: 15px 20px;
    border-radius: 18px;
    max-width: 70%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
}

.message.assistant .message-content {
    background: white;
    border: 1px solid #e2e8f0;
}

.message-text {
    line-height: 1.6;
    word-wrap: break-word;
}

/* Rich text formatting for AI responses */
.message-text h1, .message-text h2, .message-text h3 {
    margin: 15px 0 10px 0;
    color: #1e293b;
}

.message-text h1 { font-size: 1.3em; }
.message-text h2 { font-size: 1.2em; }
.message-text h3 { font-size: 1.1em; }

.message-text p {
    margin: 10px 0;
    line-height: 1.6;
}

.message-text ul, .message-text ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message-text li {
    margin: 5px 0;
}

.message-text blockquote {
    border-left: 4px solid #4f46e5;
    margin: 15px 0;
    padding: 10px 15px;
    background: #f8fafc;
    border-radius: 0 8px 8px 0;
}

.message-text code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    color: #e11d48;
}

.message-text pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.message-text strong {
    font-weight: 600;
    color: #1e293b;
}

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

.message-text a {
    color: #4f46e5;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    font-size: 0.9em;
}

.message-text th, .message-text td {
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    text-align: left;
}

.message-text th {
    background: #f8fafc;
    font-weight: 600;
}

/* User message styling - keep simple */
.message.user .message-text {
    white-space: pre-wrap;
}

.message.user .message-text h1,
.message.user .message-text h2,
.message.user .message-text h3,
.message.user .message-text strong {
    color: white;
}

.message.user .message-text code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message.user .message-text pre {
    background: rgba(0, 0, 0, 0.3);
    color: white;
}

/* Streaming cursor animation */
.streaming-cursor {
    color: #4ecdc4;
    font-weight: bold;
    animation: blink 1s infinite;
}

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

.message-info {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-style: italic;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #64748b;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    background: white;
    padding: 20px;
    border-top: 1px solid #e2e8f0;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 15px;
    transition: all 0.3s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #4f46e5;
    background: white;
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 120px;
    min-height: 24px;
}

.send-btn {
    background: linear-gradient(135deg, #feca57, #ff9ff3);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(254, 202, 87, 0.3);
}

.send-btn:not(:disabled):hover {
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 8px 25px rgba(254, 202, 87, 0.4);
    background: linear-gradient(135deg, #ff9ff3, #feca57);
}

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

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #64748b;
}

.token-count {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 500;
}

.status {
    font-weight: 500;
}

.status.ready {
    color: #10b981;
}

.status.thinking {
    color: #f59e0b;
}

.status.error {
    color: #ef4444;
}

/* Pricing Badges */
.free-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white !important;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.paid-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white !important;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 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;
    z-index: 1000;
}

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

.loading-spinner {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.loading-spinner i {
    font-size: 3rem;
    color: #4f46e5;
    margin-bottom: 15px;
}

.loading-spinner p {
    font-size: 1.1rem;
    color: #64748b;
    font-weight: 500;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .chat-container {
        height: 95vh;
        border-radius: 15px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .chat-header h1 {
        font-size: 1.3rem;
        text-align: center;
    }

    .tab-navigation {
        order: 2;
        justify-content: center;
    }

    .header-controls {
        order: 3;
        justify-content: center;
    }
    
    .model-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .model-filter, .model-selector {
        justify-content: center;
        width: 100%;
    }
    
    #price-filter, #category-filter, #model-select {
        min-width: 200px;
        flex: 1;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .welcome-message {
        padding: 40px 20px;
    }
    
    .welcome-icon {
        font-size: 3rem;
    }
    
    .welcome-message h2 {
        font-size: 1.5rem;
    }
}