/* General Styles */
body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: #333;
}

h2,
h3 {
    margin: 0 0 16px 0;
}

/* Container */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f8f9fa;
    margin: 8px;
    border-radius: 8px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-bar h1 {
    margin: 0;
    font-size: 1.5rem;
}

/* Response Area */
.response-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    background: white;
}

/* Input Section */
.input-section {
    padding: 16px;
    margin: 8px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

/* Server Status */
.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-online {
    background-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-offline {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

/* Input Row */
.input-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

.prompt-container {
    position: relative;
    display: flex;
    flex-grow: 1;
}

textarea {
    width: 100%;
    padding: 16px 48px 16px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-size: 16px;
    line-height: 1.4;
    min-height: 54px;
    max-height: 200px;
    box-sizing: border-box;
}

#generate {
    width: 54px;
    height: 54px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

#generate:hover {
    background: #0056b3;
}

#generate:disabled {
    background: #cccccc;
}

/* Controls Row */
.controls-row {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 8px;
}

.model-select-container,
.temperature-container {
    flex: 1;
}

.temperature-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.slider-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

input[type="range"] {
    flex-grow: 1;
}

.temperature-value {
    min-width: 48px;
    text-align: right;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.temperature-value:hover {
    background-color: #f0f0f0;
}

[data-theme="dark"] .temperature-value:hover {
    background-color: #333;
}

#response {
    margin-top: 0;
    padding: 16px;
    background: white;
    border-radius: 8px;
}

.status {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

/* Messages */
.message {
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 8px;
}

.user-message {
    background: #f0f7ff;
    border: 1px solid #cce5ff;
}

.system-message {
    color: #666;
    font-style: italic;
    font-size: 14px;
    margin: 8px 0;
}

.ai-message {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-right: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.theme-toggle:hover {
    background: #eee;
}

[data-theme="dark"] .theme-toggle:hover {
    background: #333;
}

/* Dark Mode Styles */
[data-theme="dark"] {
    background: #1a1a1a;
    color: #fff;
}

[data-theme="dark"] body {
    background: #121212;
}

[data-theme="dark"] .container,
[data-theme="dark"] .response-area,
[data-theme="dark"] #response,
[data-theme="dark"] .ai-message {
    background: #1e1e1e;
    color: #fff;
}

[data-theme="dark"] .status-bar,
[data-theme="dark"] .input-section,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] .model-card,
[data-theme="dark"] .pull-section,
[data-theme="dark"] .context-button {
    background: #2a2a2a;
    border-color: #333;
    color: #fff;
}

[data-theme="dark"] .user-message {
    background: #313d4f;
    border-color: #404b5c;
}

[data-theme="dark"] .system-message {
    color: #888;
}

[data-theme="dark"] textarea::placeholder {
    color: #888;
}

[data-theme="dark"] .model-meta {
    color: #aaa;
}

[data-theme="dark"] .tag {
    background: #404040;
}

[data-theme="dark"] .temperature-value,
[data-theme="dark"] h1,
[data-theme="dark"] #serverStatusText,
[data-theme="dark"] .temperature-container,
[data-theme="dark"] .material-icons {
    color: #fff;
}

/* Icon Button */
.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button .material-icons {
    color: #666;
}

[data-theme="dark"] .icon-button .material-icons {
    color: #fff;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background: white;
    margin: 50px auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    max-height: 80vh;
    overflow-y: auto;
}

[data-theme="dark"] .modal-content {
    background: #1e1e1e;
    color: #fff;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

[data-theme="dark"] .close-button {
    color: #fff;
}

/* Pull Section */
.pull-section {
    margin-bottom: 32px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.pull-input {
    display: flex;
    gap: 8px;
}

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

.model-card {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
}

.model-meta {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 16px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e9ecef;
    border-radius: 4px;
    font-size: 0.8em;
    margin-right: 4px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: #007bff;
    transition: width 0.3s ease;
}

/* Buttons */
.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn:hover {
    opacity: 0.9;
}

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

[data-theme="dark"] .btn-danger .material-icons {
    color: #ff4d4d;
}

/* Image Upload */
.image-upload-button {
    position: absolute;
    right: 16px;
    bottom: 16px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
}

.image-preview {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preview-container {
    position: relative;
    width: 100px;
    height: 100px;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Context Controls */
.context-controls {
    display: flex;
    gap: 4px;
    margin-right: 8px;
}

.context-button {
    padding: 6px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.context-button:hover {
    background: #e9ecef;
}

.context-button.active {
    background: #007bff;
    border-color: #0056b3;
}

[data-theme="dark"] .context-button {
    background: #2a2a2a;
    border-color: #404040;
}

[data-theme="dark"] .context-button:hover {
    background: #333;
}

[data-theme="dark"] .context-button.active {
    background: #0056b3;
    border-color: #004085;
}

/* Conversation Pair */
.conversation-pair {
    position: relative;
    padding-left: 30px;
    margin: 10px 0;
}

.context-checkbox {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* Deselect All Button */
.deselect-all-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    margin-left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deselect-all-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .deselect-all-button:hover {
    background-color: #333;
}

/* Material Icons */
.material-icons {
    font-size: 24px;
    line-height: 1;
    vertical-align: middle;
    color: #666;
}

[data-theme="dark"] .material-icons {
    color: #fff;
}

#generate .material-icons,
.context-button.active .material-icons {
    color: white;
}

.context-button .material-icons,
.deselect-all-button .material-icons {
    font-size: 20px;
}

.remove-image .material-icons {
    font-size: 18px;
}

.btn-danger .material-icons {
    color: #dc3545;
}