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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: #2a2a2a;
    padding: 1rem 2rem;
    border-bottom: 1px solid #3a3a3a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 1.5rem;
    color: #4CAF50;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-panel,
.viewer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-panel {
    border-right: 1px solid #3a3a3a;
    background-color: #1e1e1e;
}

.viewer-panel {
    background-color: #252525;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
}

.panel-header h2 {
    font-size: 1.1rem;
    color: #b0b0b0;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

#code-editor {
    flex: 1;
    width: 100%;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: none;
    padding: 1.5rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
}

#code-editor:focus {
    background-color: #1f1f1f;
}

.btn-primary,
.btn-secondary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

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

.btn-secondary {
    background-color: #555;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background-color: #666;
}

#viewer-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(26, 26, 26, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 10;
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #3a3a3a;
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #b0b0b0;
    font-size: 1rem;
}

.viewer-info {
    padding: 0.8rem 1.5rem;
    background-color: #2a2a2a;
    border-top: 1px solid #3a3a3a;
    font-size: 0.85rem;
    color: #888;
}

.error-message {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    background-color: #f44336;
    color: white;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.error-message.active {
    padding: 1rem 1.5rem;
    max-height: 200px;
    border-top: 1px solid #d32f2f;
}

#model-info {
    margin: 0;
}

/* Chat Panel Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-chat {
    padding: 0.6rem 1.2rem;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-chat:hover {
    background-color: #1976D2;
    transform: translateY(-1px);
}

.chat-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background-color: #2a2a2a;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    z-index: 1000;
}

.chat-panel.open {
    right: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #1e1e1e;
    border-bottom: 1px solid #3a3a3a;
}

.chat-header h3 {
    color: #2196F3;
    font-size: 1.2rem;
}

.btn-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close:hover {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

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

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

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

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

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

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    word-wrap: break-word;
}

.chat-message.user .message-content {
    background-color: #2196F3;
    color: white;
}

.chat-message.assistant .message-content {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

.message-content p {
    margin: 0 0 0.5rem 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

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

.message-content code {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85em;
}

.message-content pre {
    background-color: #1e1e1e;
    padding: 0.8rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.code-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-apply-code,
.btn-copy-code {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-apply-code {
    background-color: #4CAF50;
    color: white;
}

.btn-apply-code:hover {
    background-color: #45a049;
}

.btn-copy-code {
    background-color: #555;
    color: #e0e0e0;
}

.btn-copy-code:hover {
    background-color: #666;
}

.chat-input-container {
    padding: 1rem;
    background-color: #1e1e1e;
    border-top: 1px solid #3a3a3a;
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 0.8rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    outline: none;
}

#chat-input:focus {
    border-color: #2196F3;
}

.btn-send {
    padding: 0.8rem 1.5rem;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-send:hover {
    background-color: #1976D2;
}

.btn-send:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.8rem 1rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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


/* Settings Button and Header Buttons */
.header-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-settings {
    padding: 0.6rem 1.2rem;
    background-color: #555;
    color: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-settings:hover {
    background-color: #666;
    transform: translateY(-1px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: #2a2a2a;
    border-radius: 8px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #1e1e1e;
    border-bottom: 1px solid #3a3a3a;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    color: #4CAF50;
    font-size: 1.2rem;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background-color: #1e1e1e;
    border-top: 1px solid #3a3a3a;
    border-radius: 0 0 8px 8px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-of-type {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #b0b0b0;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    background-color: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    border-color: #4CAF50;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.field-hint {
    display: block;
    margin-top: 0.35rem;
    color: #666;
    font-size: 0.8rem;
}

/* Settings Status Indicator */
.settings-status {
    padding: 0;
    margin-top: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s;
}

.settings-status.visible {
    padding: 0.75rem;
    max-height: 100px;
}

.settings-status.success {
    background-color: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border: 1px solid #4CAF50;
}

.settings-status.error {
    background-color: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid #f44336;
}

.settings-status.info {
    background-color: rgba(33, 150, 243, 0.2);
    color: #2196F3;
    border: 1px solid #2196F3;
}

/* Form validation states */
.form-group.error input,
.form-group.error select {
    border-color: #f44336;
}

.form-group .error-text {
    color: #f44336;
    font-size: 0.8rem;
    margin-top: 0.35rem;
    display: none;
}

.form-group.error .error-text {
    display: block;
}
