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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1e1e1e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #5C6AC4 0%, #4a5ac4 100%);
  color: white;
  padding: 15px 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header h1 {
  font-size: 24px;
  margin-bottom: 5px;
}

.header p {
  font-size: 12px;
  opacity: 0.9;
}

.container {
  display: flex;
  height: calc(100vh - 80px);
  gap: 0;
}

.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #252526;
  border-right: 2px solid #3e3e42;
}

.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  gap: 0;
  padding: 0;
  min-height: 0;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #2d2d30;
  border-bottom: 1px solid #3e3e42;
}

.file-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.file-tab {
  padding: 8px 12px;
  background: #3e3e42;
  color: #ccc;
  border: none;
  cursor: pointer;
  border-radius: 3px 3px 0 0;
  font-size: 12px;
  white-space: nowrap;
}

.file-tab.active {
  background: #1e1e1e;
  color: #fff;
}

#languageSelect {
  padding: 6px 10px;
  background: #3e3e42;
  color: #ccc;
  border: 1px solid #555;
  border-radius: 3px;
  font-size: 12px;
}

/* File Explorer */
.file-explorer {
  flex: 0 0 150px;
  display: flex;
  flex-direction: column;
  background: #252526;
  border-bottom: 1px solid #3e3e42;
  overflow: hidden;
}

.explorer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #2d2d30;
  border-bottom: 1px solid #3e3e42;
  flex-shrink: 0;
}

.explorer-header h4 {
  font-size: 12px;
  margin: 0;
}

.explorer-actions {
  display: flex;
  gap: 5px;
}

.icon-btn {
  background: none;
  border: 1px solid #3e3e42;
  color: #ccc;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 3px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #3e3e42;
  color: #fff;
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
  font-size: 12px;
}

.file-item {
  padding: 6px 8px;
  margin: 2px 0;
  background: #3e3e42;
  color: #ccc;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item:hover {
  background: #4e4e54;
  color: #fff;
}

.file-item.active {
  background: #5C6AC4;
  color: white;
}

#codeEditor {
  flex: 1;
  padding: 15px;
  background: #1e1e1e;
  color: #d4d4d4;
  border: none;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  min-height: 0;
}

#codeEditor::placeholder {
  color: #6a6a6a;
}

.editor-actions {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #2d2d30;
  border-top: 1px solid #3e3e42;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  background: #3e3e42;
  color: #ccc;
  transition: all 0.2s;
}

.btn:hover {
  background: #555;
  color: #fff;
}

.btn-primary {
  background: #5C6AC4;
  color: white;
}

.btn-primary:hover {
  background: #4a5ac4;
}

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

.btn-danger:hover {
  background: #e36d58;
}

.preview-section {
  flex: 0 1 45%;
  display: flex;
  flex-direction: column;
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 10px 5px 10px;
  min-height: 0;
}

.preview-section h3 {
  padding: 10px;
  background: #2d2d30;
  font-size: 12px;
  border-bottom: 1px solid #3e3e42;
  flex-shrink: 0;
}

.preview-box {
  flex: 1;
  padding: 15px;
  overflow: auto;
  background: white;
  color: #000;
  font-size: 13px;
  min-height: 0;
}

.console {
  padding: 10px;
  background: #1e1e1e;
  color: #4ec9b0;
  border: none;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  height: 60px;
  resize: none;
  flex-shrink: 0;
}

.ai-section {
  flex: 0 1 45%;
  display: flex;
  flex-direction: column;
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 3px;
  overflow: hidden;
  margin: 5px 10px 10px 10px;
  min-height: 0;
  transition: flex 0.3s ease;
}

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #2d2d30;
  border-bottom: 1px solid #3e3e42;
  flex-shrink: 0;
}

.ai-header h3 {
  font-size: 12px;
  margin: 0;
  flex: 1;
}

.ai-header-buttons {
  display: flex;
  gap: 5px;
}

.expand-btn {
  background: none;
  border: none;
  color: #5C6AC4;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

.expand-btn:hover {
  color: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-message {
  padding: 8px 12px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.4;
  word-wrap: break-word;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-message.user {
  background: #5C6AC4;
  color: white;
  align-self: flex-end;
  max-width: 80%;
}

.chat-message.ai {
  background: #3e3e42;
  color: #d4d4d4;
  align-self: flex-start;
  max-width: 80%;
}

.chat-input-area {
  display: flex;
  gap: 5px;
  padding: 10px;
  background: #2d2d30;
  border-top: 1px solid #3e3e42;
  flex-shrink: 0;
}

#aiPrompt {
  flex: 1;
  padding: 8px;
  background: #3e3e42;
  border: 1px solid #555;
  color: #ccc;
  border-radius: 3px;
  font-size: 12px;
}

#aiPrompt::placeholder {
  color: #6a6a6a;
}

#sendBtn {
  padding: 8px 16px;
  flex-shrink: 0;
}

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

.chat-modal.hidden {
  display: none;
}

.chat-modal-content {
  background: #252526;
  border: 2px solid #3e3e42;
  border-radius: 8px;
  width: 80%;
  height: 80%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.chat-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: #2d2d30;
  border-bottom: 1px solid #3e3e42;
  flex-shrink: 0;
}

.chat-modal-header h2 {
  font-size: 18px;
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
}

.close-btn:hover {
  color: #5C6AC4;
}

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

.expanded-chat-messages .chat-message {
  max-width: 100%;
}

.expanded-chat-input {
  display: flex;
  gap: 10px;
  padding: 15px;
  background: #2d2d30;
  border-top: 1px solid #3e3e42;
  flex-shrink: 0;
}

#expandedAiPrompt {
  flex: 1;
  padding: 10px;
  background: #3e3e42;
  border: 1px solid #555;
  color: #ccc;
  border-radius: 3px;
  font-size: 13px;
}

#expandedAiPrompt::placeholder {
  color: #6a6a6a;
}

#expandedSendBtn {
  padding: 10px 20px;
  flex-shrink: 0;
}

/* Item Modal (Add File/Folder) */
.item-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1001;
}

.item-modal.hidden {
  display: none;
}

.item-modal-content {
  background: #252526;
  border: 2px solid #3e3e42;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 400px;
}

.item-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.item-modal-header h3 {
  font-size: 16px;
  color: #fff;
  margin: 0;
}

.item-modal-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#itemInput, #chatNameInput {
  padding: 10px;
  background: #3e3e42;
  border: 1px solid #555;
  color: #ccc;
  border-radius: 3px;
  font-size: 13px;
}

#itemInput::placeholder, #chatNameInput::placeholder {
  color: #6a6a6a;
}

.modal-buttons {
  display: flex;
  gap: 10px;
}

.modal-buttons .btn {
  flex: 1;
}

@media (max-width: 1024px) {
  .container {
    flex-direction: column;
  }

  .left-panel, .right-panel {
    flex: 1;
  }

  .preview-section {
    flex: 1;
    margin: 5px;
  }

  .ai-section {
    flex: 1;
    margin: 5px;
  }

  .file-explorer {
    flex: 0 0 100px;
  }
}