/* ==========================================================================
   EduCode Studio - Modern Dark Theme & Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Palette - HSL Tailored */
  --bg-main: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  
  --border-color: #30363d;
  --border-focus: #58a6ff;

  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  --accent-primary: #3fb950;
  --accent-primary-hover: #2ea043;
  --accent-blue: #58a6ff;
  --accent-purple: #bc8cff;
  --accent-orange: #f0883e;
  --accent-red: #f85149;
  --accent-yellow: #d29922;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', Consolas, Monaco, 'Andale Mono', monospace;

  --header-height: 56px;
  --statusbar-height: 28px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Main App Container Layout
   ========================================================================== */

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header Navbar */
.navbar {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.4);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  background: linear-gradient(90deg, #f0f6fc, #bc8cff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand-badge {
  font-size: 0.75rem;
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(88, 166, 255, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* Navbar Actions Controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.select-wrapper select {
  appearance: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 32px 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.select-wrapper select:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.select-wrapper select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.select-icon {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--text-secondary);
  width: 14px;
  height: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(63, 185, 80, 0.3);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(63, 185, 80, 0.4);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.btn-icon-only {
  padding: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.btn-icon-only:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-icon-only.active {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  background: rgba(88, 166, 255, 0.1);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  transition: .3s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: rgba(63, 185, 80, 0.2);
  border-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(16px);
  background-color: var(--accent-primary);
}

/* Split Workspace Body */
.workspace-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Left Pane: Code Editor Section */
.pane-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 250px;
  min-height: 0;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

/* Code Editor Tab Bar */
.tab-bar {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
  align-items: center;
  justify-content: space-between;
  padding-right: 8px;
}

.tabs-group {
  display: flex;
  align-items: center;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-color);
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--text-primary);
  background: var(--bg-main);
  border-bottom-color: var(--accent-blue);
  font-weight: 600;
}

.tab-btn .tab-icon {
  width: 14px;
  height: 14px;
}

.tab-btn[data-tab="html"].active .tab-icon { color: var(--accent-orange); }
.tab-btn[data-tab="css"].active .tab-icon { color: var(--accent-blue); }
.tab-btn[data-tab="js"].active .tab-icon { color: var(--accent-yellow); }

.tab-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* CodeMirror Container & Theme Customizations */
.editor-container {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#monaco-editor-element {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  outline: none;
}

.CodeMirror {
  width: 100% !important;
  height: 100% !important;
  font-family: 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  background-color: #0d1117 !important;
}

.CodeMirror-gutters {
  background-color: #161b22 !important;
  border-right: 1px solid #30363d !important;
}

.CodeMirror-linenumber {
  color: #484f58 !important;
  padding: 0 8px 0 4px !important;
}

.CodeMirror-cursor {
  border-left: 2px solid #58a6ff !important;
}

.CodeMirror-focused .CodeMirror-selected {
  background: rgba(88, 166, 255, 0.25) !important;
}

/* Pane Resizer Splitter */
.pane-resizer {
  width: 8px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  cursor: col-resize;
  position: relative;
  z-index: 5;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pane-resizer:hover, .pane-resizer.dragging {
  background: var(--accent-blue);
}

.pane-resizer::after {
  content: "";
  width: 2px;
  height: 24px;
  background: var(--text-muted);
  border-radius: 2px;
}

.pane-resizer:hover::after, .pane-resizer.dragging::after {
  background: #ffffff;
}

/* Vertical layout resizer adjustments */
.workspace-body.layout-vertical {
  flex-direction: column;
}

.workspace-body.layout-vertical .pane-resizer {
  width: 100%;
  height: 8px;
  cursor: row-resize;
  border-left: none;
  border-right: none;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.workspace-body.layout-vertical .pane-resizer::after {
  width: 24px;
  height: 2px;
}

/* Right Pane: Preview & Virtual Console */
.pane-preview-console {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 250px;
  background: var(--bg-main);
  position: relative;
}

/* Preview Header */
.preview-header {
  height: 41px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =============================================
   Simulated Browser Chrome
   ============================================= */

.browser-chrome {
  background: #1a1b26;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
  flex-shrink: 0;
}

/* Browser Tab Bar */
.browser-tabs {
  display: flex;
  align-items: flex-end;
  padding: 6px 8px 0;
  gap: 2px;
  background: #13141c;
}

.browser-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--font-sans);
  border-radius: 8px 8px 0 0;
  max-width: 220px;
  min-width: 60px;
  cursor: default;
  transition: background 0.15s ease;
}

.browser-tab.active {
  background: #1a1b26;
  color: var(--text-primary);
}

.browser-tab-favicon {
  flex-shrink: 0;
  border-radius: 2px;
}

.browser-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 500;
}

.browser-tab-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  transition: all 0.15s;
}

.browser-tab-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.browser-tab-new {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.browser-tab-new:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* Browser Navigation Bar */
.browser-navbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 8px;
}

.browser-nav-buttons {
  display: flex;
  align-items: center;
  gap: 2px;
}

.browser-nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.browser-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.browser-url-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: border-color 0.2s;
}

.browser-url-bar:hover {
  border-color: var(--text-muted);
}

.browser-url-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-family: var(--font-sans);
}

/* Preview iFrame Wrapper */
.iframe-container {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #ffffff;
  position: relative;
}

#preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

/* Console Pane */
.console-pane {
  height: 180px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: height 0.2s ease;
}

.console-pane.collapsed {
  height: 32px !important;
}

.console-header {
  height: 32px;
  background: var(--bg-tertiary);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
  cursor: pointer;
}

.console-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.console-badge {
  background: var(--bg-hover);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.console-badge.has-error {
  background: rgba(248, 81, 73, 0.2);
  color: var(--accent-red);
}

.console-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.console-log-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  word-break: break-all;
}

.console-log-line.log { color: var(--text-primary); }
.console-log-line.info { color: var(--accent-blue); }
.console-log-line.warn { color: var(--accent-yellow); background: rgba(210, 153, 34, 0.1); }
.console-log-line.error { color: var(--accent-red); background: rgba(248, 81, 73, 0.1); }

.console-log-line .timestamp {
  color: var(--text-muted);
  font-size: 0.75rem;
  user-select: none;
}

/* Footer Status Bar */
.statusbar {
  height: var(--statusbar-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  user-select: none;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Modal Overlay & Dialogs */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}
