/* ==========================================================================
   IPHI CODING LAB - CODING WORKSPACE & IDE STYLESHEET
   Dedicated IDE Layout, Code Editors, Split-Pane, Preview, Console Drawer
   ========================================================================== */

.workspace-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  background: #0f172a; /* IDE Dark theme by default for focused coding */
  color: #f8fafc;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   WORKSPACE TOP CONTROLS TOOLBAR
   ========================================================================== */
.ws-toolbar {
  height: 52px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}

.ws-project-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ws-project-title-input {
  background: transparent;
  border: 1px solid transparent;
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  max-width: 200px;
  transition: all var(--transition-fast);
}

.ws-project-title-input:hover {
  border-color: #475569;
  background: rgba(255, 255, 255, 0.05);
}

.ws-project-title-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #0f172a;
}

.ws-status-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: #334155;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: pulseStatusDot 2s infinite ease-in-out;
}

@keyframes pulseStatusDot {
  0% { transform: scale(0.95); opacity: 0.85; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.85; }
}

.ws-status-badge.dirty .ws-status-dot {
  background: #f59e0b;
}

.ws-actions-primary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-run-code {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.btn-run-code:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
}

.btn-ws-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #334155;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.btn-ws-icon:hover {
  background: #475569;
  color: #fff;
}

.btn-ws-icon.active {
  background: var(--primary);
  color: #fff;
}

.btn-ws-icon:active {
  transform: scale(0.92);
}

.ws-mobile-only-btn {
  display: none;
}

.ws-desktop-tool {
  display: inline-flex;
}

@media (max-width: 768px) {
  .ws-mobile-only-btn {
    display: inline-flex;
  }
  .ws-desktop-tool {
    display: none !important;
  }
}

/* ==========================================================================
   MOBILE QUICK SYMBOL TOOLBAR (CODING ASSIST)
   ========================================================================== */
.ws-mobile-symbol-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #090d16;
  border-bottom: 1px solid #1e293b;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

.ws-mobile-symbol-bar::-webkit-scrollbar {
  display: none;
}

.ws-symbol-btn {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  background: #1e293b;
  color: #38bdf8;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, background 0.15s ease;
  touch-action: manipulation;
}

.ws-symbol-btn:hover {
  background: #334155;
  color: #ffffff;
}

.ws-symbol-btn:active {
  background: var(--primary);
  color: #ffffff;
  transform: scale(0.90);
}

.ws-preview-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   WORKSPACE MAIN SPLIT PANE
   ========================================================================== */
.ws-main-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
  position: relative;
  background: #0f172a;
}

/* Layout variants */
.ws-main-split.layout-editor-only {
  grid-template-columns: 1fr 0px;
}
.ws-main-split.layout-editor-only .ws-preview-pane {
  display: none;
}

.ws-main-split.layout-preview-only {
  grid-template-columns: 0px 1fr;
}
.ws-main-split.layout-preview-only .ws-editor-pane {
  display: none;
}

/* ==========================================================================
   EDITOR PANE
   ========================================================================== */
.ws-editor-pane {
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border-right: 1px solid #334155;
  min-height: 0;
  position: relative;
}

.ws-editor-tabs-bar {
  height: 42px;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #334155;
  padding: 0 8px;
}

.ws-lang-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.ws-lang-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 100%;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.ws-lang-tab:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.03);
}

.ws-lang-tab.active {
  color: #38bdf8;
  background: #0f172a;
  border-bottom-color: #38bdf8;
}

.tab-tag-html { color: #f97316; }
.tab-tag-css { color: #38bdf8; }
.tab-tag-js { color: #facc15; }

.ws-editor-tab-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Editor Body & Fallback Engine */
.ws-editor-views-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0f172a;
}

.editor-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

.editor-layer.active {
  display: flex;
}

/* Fallback & Custom Editor Component */
.simple-code-editor-container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  background: #0b1120;
}

.editor-gutter {
  width: 50px;
  background: #090d16;
  color: #475569;
  text-align: right;
  padding: 12px 10px 12px 0;
  user-select: none;
  border-right: 1px solid #1e293b;
  overflow: hidden;
  font-size: inherit;
  line-height: inherit;
}

.editor-gutter-line {
  display: block;
}

.editor-textarea-wrap {
  flex: 1;
  position: relative;
  height: 100%;
}

.editor-code-textarea {
  width: 100%;
  height: 100%;
  background: transparent;
  color: #f1f5f9;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 16px;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  -moz-tab-size: 2;
}

.editor-code-textarea::selection {
  background: rgba(56, 189, 248, 0.25);
}

/* CodeMirror adjustments if loaded */
.CodeMirror {
  width: 100% !important;
  height: 100% !important;
  font-family: var(--font-mono) !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  background: #0b1120 !important;
  color: #f8fafc !important;
}

.CodeMirror-gutters {
  background: #090d16 !important;
  border-right: 1px solid #1e293b !important;
}

.CodeMirror-linenumber {
  color: #475569 !important;
}

/* Editor Status Bar */
.ws-editor-statusbar {
  height: 28px;
  background: #090d16;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 0.75rem;
  color: #64748b;
  user-select: none;
}

.ws-statusbar-left, .ws-statusbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ==========================================================================
   PREVIEW PANE
   ========================================================================== */
.ws-preview-pane {
  display: flex;
  flex-direction: column;
  background: #1e293b;
  min-height: 0;
  position: relative;
}

.ws-preview-bar {
  height: 42px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.ws-preview-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ws-preview-size-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ws-preview-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  overflow: hidden;
  position: relative;
  transition: all var(--transition-normal);
}

.preview-frame-container {
  width: 100%;
  height: 100%;
  background: #ffffff;
  transition: width 0.3s ease;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
}

.preview-frame-container.device-tablet {
  width: 768px;
  height: 94%;
  border-radius: var(--radius-md);
  border: 4px solid #334155;
}

.preview-frame-container.device-mobile {
  width: 375px;
  height: 92%;
  border-radius: var(--radius-lg);
  border: 6px solid #334155;
}

#previewIframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
  display: block;
}

/* ==========================================================================
   INTERACTIVE IN-APP CONSOLE DRAWER
   ========================================================================== */
.ws-console-drawer {
  height: 160px;
  background: #090d16;
  border-top: 1px solid #334155;
  display: flex;
  flex-direction: column;
  transition: height var(--transition-fast);
}

.ws-console-drawer.collapsed {
  height: 32px;
}

.ws-console-header {
  height: 32px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}

.ws-console-logs-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.console-log-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.console-log-row.log-info { color: #38bdf8; }
.console-log-row.log-warn { color: #facc15; }
.console-log-row.log-error { color: #f87171; background: rgba(239, 68, 68, 0.1); }
.console-log-row.log-system { color: #a855f7; font-style: italic; }

/* Fullscreen Preview Overlay */
.fullscreen-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  background: #ffffff;
  display: none;
  flex-direction: column;
}

.fullscreen-preview-modal.active {
  display: flex;
}

.fullscreen-preview-topbar {
  height: 48px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
