:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #ec4899;
    --bg-dark: #0f172a;
    --bg-darker: #0a0f1e;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    direction: rtl;
}

.studio-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.studio-header {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.header-left i {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.project-info {
    background: var(--bg-light);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.project-info i {
    color: var(--accent-color);
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--bg-lighter);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.studio-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.left-panel {
    width: 60%;
    background: var(--bg-dark);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-tabs {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

.preview-toolbar {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-selector {
    display: flex;
    gap: 0.25rem;
}

.btn-sm {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sm:hover {
    background: var(--bg-lighter);
    transform: translateY(-1px);
}

.btn-sm.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-sm.btn-primary:hover {
    background: var(--secondary-color);
}

.preview-frame-container {
    flex: 1;
    background: var(--bg-light);
    position: relative;
    overflow: hidden;
}

.preview-frame-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.files-toolbar {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.5rem;
}

.file-explorer {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.file-item {
    background: var(--bg-light);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.file-item:hover {
    background: var(--bg-lighter);
    transform: translateX(-4px);
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.file-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.file-item:hover .file-actions {
    opacity: 1;
}

.file-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.editor-header {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

#codeEditor {
    flex: 1;
    font-family: 'Fira Code', monospace;
    background: var(--bg-darker);
    color: var(--text-primary);
    border: none;
    padding: 1rem;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
}

.CodeMirror {
    height: 100%;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
}

.components-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.component-category {
    margin-bottom: 2rem;
}

.component-category h4 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.component-btn {
    width: 100%;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
    text-align: right;
}

.component-btn:hover {
    background: var(--bg-lighter);
    border-color: var(--primary-color);
    transform: translateX(-4px);
}

.component-btn i {
    color: var(--primary-color);
    font-size: 1.25rem;
}

.resizer {
    width: 4px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background 0.2s;
}

.resizer:hover {
    background: var(--primary-color);
}

.right-panel {
    width: 40%;
    background: var(--bg-darker);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    background: var(--bg-light);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.6;
}

.message.user-message {
    justify-content: flex-end;
}

.message.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.message.assistant-message .message-content {
    background: var(--bg-light);
}

.message.system-message .message-content {
    background: var(--bg-lighter);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message.system-message i {
    color: var(--accent-color);
    font-size: 1.5rem;
}

.chat-input-container {
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.quick-btn {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quick-btn:hover {
    background: var(--bg-lighter);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#chatInput {
    flex: 1;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    resize: none;
    transition: border-color 0.2s;
    max-height: 150px;
}

#chatInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.send-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.send-btn:active {
    transform: translateY(0);
}

.input-footer {
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-large {
    max-width: 1200px;
}

.modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
}

.modal-header {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
}

.modal-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.schema-editor {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.schema-toolbar {
    display: flex;
    gap: 0.5rem;
}

.schema-container {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 400px;
}

.visual-editor {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.visual-toolbar {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toolbar-section label {
    font-weight: 600;
    color: var(--text-secondary);
}

.toolbar-section input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.toolbar-section select {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
}

.visual-canvas {
    flex: 1;
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-muted {
    color: var(--text-muted);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-lighter);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

@media (max-width: 1024px) {
    .left-panel {
        width: 50%;
    }
    
    .right-panel {
        width: 50%;
    }
}

@media (max-width: 768px) {
    .studio-main {
        flex-direction: column;
    }
    
    .left-panel,
    .right-panel {
        width: 100%;
        height: 50%;
    }
    
    .resizer {
        display: none;
    }
}
