:root {
    --bg-dark: #09090b;
    --bg-panel: #18181b;
    --bg-input: #27272a;
    --border: #3f3f46;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent: #8b5cf6;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 400px;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.logo i {
    color: var(--primary);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-input);
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.message.user .avatar {
    background-color: var(--primary);
    color: white;
    border: none;
}

.content {
    background-color: var(--bg-panel);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 85%;
    border: 1px solid var(--border);
}

.message.user .content {
    background-color: var(--primary);
    color: white;
    border: none;
}

/* Input Area */
.input-area {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background-color: var(--bg-dark);
}

.input-wrapper {
    position: relative;
    background-color: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

textarea {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-main);
    padding: 0.75rem 3rem 0.75rem 0.75rem;
    resize: none;
    height: 60px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
}

#send-btn {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    background-color: var(--primary);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#send-btn:disabled {
    background-color: var(--bg-panel);
    color: var(--text-muted);
    cursor: not-allowed;
}

#send-btn:not(:disabled):hover {
    background-color: var(--primary-hover);
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #000;
}

.preview-header {
    background-color: var(--bg-panel);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-dark);
    padding: 0.25rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.tab.active {
    background-color: var(--bg-panel);
    color: var(--text-main);
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.preview-content {
    flex: 1;
    background-color: white; /* Iframe bg */
    position: relative;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Code View */
.code-content {
    flex: 1;
    display: flex;
    background-color: var(--bg-dark);
    overflow: hidden;
}

.file-explorer {
    width: 200px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

#file-list {
    list-style: none;
    padding: 0.5rem;
}

#file-list li {
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#file-list li:hover, #file-list li.active {
    background-color: var(--bg-input);
    color: var(--text-main);
}

.code-editor {
    flex: 1;
    padding: 1rem;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #e4e4e7;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--bg-panel);
    width: 400px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 4px;
    color: var(--text-main);
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Loading Spinner */
.loader {
    border: 2px solid var(--bg-input);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
