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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 30px;
}

nav a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

nav a:hover {
    color: #667eea;
}

nav a:hover::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 30px auto;
    padding: 0 20px;
}

/* Settings Panel */
.settings-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 25px;
    margin-bottom: 20px;
}

.setting-section {
    margin-bottom: 30px;
}

.setting-section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.section-header h3 {
    margin: 0;
    color: #667eea;
    font-size: 18px;
    font-weight: bold;
}

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

.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-container input[type="checkbox"] {
    width: 40px;
    height: 20px;
    appearance: none;
    background: #ddd;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-container input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.toggle-container input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.toggle-container input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 13px;
    font-weight: bold;
    color: #555;
    white-space: nowrap;
}

.adaptive-info {
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left: 3px solid #667eea;
    border-radius: 8px;
    margin-bottom: 12px;
}

.adaptive-status {
    font-size: 13px;
    color: #667eea;
    font-weight: 600;
}

.header-actions select {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease;
    min-width: 200px;
}

.header-actions select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.save-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    font-size: 13px;
    white-space: nowrap;
}

.save-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.save-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.manage-link {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: all 0.2s ease;
    font-size: 13px;
    white-space: nowrap;
}

.manage-link:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Prompt Info and Editor */
.prompt-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.prompt-name {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.prompt-desc {
    color: #666;
    font-size: 12px;
    font-style: italic;
}

.setting-section textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
    transition: border-color 0.3s ease;
    line-height: 1.5;
}

.setting-section textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-section textarea:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    color: #999;
}

/* Model Grid */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.model-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.model-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.model-card.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.model-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.model-name {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.model-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.model-badge.recommended {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.model-badge.preview {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
}

.model-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.model-desc {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.model-pricing {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pricing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.pricing-label {
    font-weight: bold;
    color: #555;
}

.pricing-value {
    color: #333;
    font-family: 'Courier New', monospace;
}

@media (max-width: 768px) {
    .model-grid {
        grid-template-columns: 1fr;
    }

    .header-actions {
        flex-wrap: wrap;
    }

    .header-actions select {
        min-width: 150px;
    }
}

/* Chat Container */
.chat-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.chat-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 600px;
    overflow: hidden;
}

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

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

.message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    background: #667eea;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.other {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.system {
    background: #e3f2fd;
    color: #1976d2;
    align-self: center;
    font-size: 14px;
    text-align: center;
    max-width: 90%;
}

.message.loading {
    background: #f0f0f0;
    color: #999;
    align-self: flex-start;
}

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '•';
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 49%, 100% {
        opacity: 0.3;
    }
    50%, 99% {
        opacity: 1;
    }
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.chat-input-area input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input-area button {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.chat-input-area button:hover {
    transform: scale(1.05);
}

.chat-input-area button:active {
    transform: scale(0.95);
}

.ai-btn {
    padding: 10px 16px !important;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%) !important;
    font-size: 14px;
}

.ai-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e91e63 100%) !important;
}

/* Recommendations */
.recommendations {
    max-height: 250px;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recommendations.hidden {
    display: none;
}

.rec-header {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 14px;
}

.rec-option {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    color: #333;
}

.rec-option:hover {
    background: #f0f0ff;
    border-color: #667eea;
    transform: translateX(5px);
}

.loading-text {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

/* Sample Scenarios */
.sample-scenarios {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 25px;
    margin-top: 30px;
}

.sample-scenarios h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 18px;
    text-align: center;
}

.sample-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.sample-btn {
    padding: 14px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.sample-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

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

/* Adaptive Mode Sample Buttons - Special Style */
#sampleDataContainer .sample-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 16px 20px;
    border-radius: 12px;
    text-align: left;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    display: block;
    width: 100%;
    margin-bottom: 10px;
}

#sampleDataContainer .sample-btn:hover {
    transform: translateX(5px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

#sampleDataContainer .sample-btn div:first-child {
    font-weight: 600;
    margin-bottom: 4px;
}

/* API Test */
.api-test-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

.test-section {
    margin-bottom: 30px;
}

.test-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 18px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    min-height: 150px;
    transition: border-color 0.3s ease;
}

.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.button-group button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.button-group button:hover {
    transform: scale(1.05);
}

.button-group button.secondary {
    background: #666;
}

.response-box {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.response-box.success {
    border-left: 4px solid #4caf50;
    background: #f1f8f4;
}

.response-box.error {
    border-left: 4px solid #f44336;
    background: #fdeaea;
    color: #c62828;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    color: #666;
    text-align: center;
    padding: 30px 20px;
    margin-top: auto;
    border-top: 1px solid #eee;
    font-size: 14px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-links {
    margin-bottom: 15px;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    margin: 0 15px;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #764ba2;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
    }

    .chat-box {
        height: 400px;
    }

    nav ul {
        gap: 15px;
    }

    .header-container {
        height: 60px;
    }

    .logo {
        font-size: 18px;
    }

    .api-test-container {
        padding: 20px;
    }
}

/* Utility Classes */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

.success {
    color: #4caf50;
}

.error {
    color: #f44336;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

.badge.success {
    background: #4caf50;
    color: white;
}

.badge.error {
    background: #f44336;
    color: white;
}

.badge.info {
    background: #2196f3;
    color: white;
}
/* Notification */
.notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* API Key Section */
.api-key-container {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.api-key-info {
    margin-bottom: 20px;
    padding: 12px 0;
}

.api-key-info .info-text {
    color: #444;
    font-size: 14px;
    margin: 8px 0;
    line-height: 1.6;
}

.api-key-info .info-text:first-child {
    font-weight: 600;
    color: #222;
    font-size: 14px;
}

.api-key-info .info-text.small {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.api-key-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.api-key-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    background: white;
    transition: all 0.3s ease;
    color: #333;
}

.api-key-input:hover {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.api-key-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.api-key-input::placeholder {
    color: #999;
    font-family: 'Segoe UI', sans-serif;
    font-size: 13px;
}

.api-key-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.api-key-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

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

.api-key-btn.secondary {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.api-key-btn.secondary:hover {
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.api-key-status {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: none;
    animation: slideDown 0.3s ease-out;
    margin-top: 8px;
}

@keyframes slideDown {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.api-key-status.success {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.api-key-status.info {
    display: block;
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

.api-key-status.warning {
    display: block;
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffb74d;
}

.api-key-status.error {
    display: block;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Responsive */
@media (max-width: 768px) {
    .api-key-input-group {
        flex-direction: column;
    }

    .api-key-input {
        min-width: 100%;
    }

    .api-key-btn {
        justify-content: center;
        width: 100%;
    }
}