/* ===========================
   HTMLab — Workspace Styles
   =========================== */

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

:root {
  --bg-deep:     #0a0a0c;
  --bg-base:     #111114;
  --bg-surface:  #18181d;
  --bg-hover:    #1f1f26;
  --bg-active:   #25252e;
  --border:      rgba(255,255,255,0.07);
  --border-mid:  rgba(255,255,255,0.12);
  --border-hi:   rgba(255,255,255,0.2);
  --accent:      #7c6fcd;
  --accent-glow: rgba(124,111,205,0.25);
  --accent-hi:   #a89de8;
  --text-primary:   #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted:     #55556a;
  --green:   #4ade80;
  --red:     #f87171;
  --font-ui:   'Syne', sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --sidebar-w: 230px;
  --topbar-h:  52px;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
}

/* ===========================
   SIDEBAR
   =========================== */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.logo-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.sidebar-search input:focus {
  border-color: var(--accent);
}

.sidebar-search input::placeholder { color: var(--text-muted); }

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}

.empty-state {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 16px;
  line-height: 1.6;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 6px;
  transition: background 0.12s;
  position: relative;
  group: 1;
}

.file-item:hover { background: var(--bg-hover); }
.file-item.active { background: var(--bg-active); }
.file-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.file-icon {
  color: var(--accent);
  flex-shrink: 0;
  font-size: 13px;
}

.file-name {
  flex: 1;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.file-item.active .file-name { color: var(--accent-hi); }

.file-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: opacity 0.12s;
  flex-shrink: 0;
}

.file-item:hover .file-delete { opacity: 1; }

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===========================
   MAIN
   =========================== */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===========================
   TOPBAR
   =========================== */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.current-file {
  font-family: var(--font-code);
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===========================
   WORKSPACE (split panels)
   =========================== */

.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===========================
   PANELS
   =========================== */

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.panel-editor { flex: 1; }
.panel-preview { flex: 1; border-left: 1px solid var(--border); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 38px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.panel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===========================
   CODE EDITOR
   =========================== */

#code-editor {
  flex: 1;
  resize: none;
  background: var(--bg-base);
  border: none;
  outline: none;
  padding: 16px;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  caret-color: var(--accent);
}

#code-editor::placeholder { color: var(--text-muted); }

.editor-status {
  display: flex;
  gap: 16px;
  padding: 5px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===========================
   PREVIEW
   =========================== */

.preview-container {
  flex: 1;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.preview-empty {
  text-align: center;
  color: var(--text-muted);
}

.preview-empty-icon {
  margin-bottom: 16px;
  opacity: 0.3;
}

.preview-empty p { font-size: 13px; line-height: 1.6; }
.preview-empty strong { color: var(--text-secondary); }

.iframe-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: padding 0.2s ease;
}

.iframe-wrapper[data-view="desktop"] { padding: 0; }
.iframe-wrapper[data-view="tablet"]  { padding: 16px; }
.iframe-wrapper[data-view="mobile"]  { padding: 24px; }

#preview-frame {
  border: none;
  background: #fff;
  transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}

.iframe-wrapper[data-view="desktop"] #preview-frame {
  width: 100%; height: 100%; border-radius: 0;
}

.iframe-wrapper[data-view="tablet"] #preview-frame {
  width: 768px; max-width: 100%; height: 100%;
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--border-mid), 0 20px 60px rgba(0,0,0,0.5);
}

.iframe-wrapper[data-view="mobile"] #preview-frame {
  width: 390px; max-width: 100%; height: 100%;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border-mid), 0 20px 60px rgba(0,0,0,0.6);
}

/* ===========================
   RESIZE HANDLE
   =========================== */

.resize-handle {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: var(--accent);
}

/* ===========================
   BUTTONS
   =========================== */

.btn-icon {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-mid);
}

.btn-icon-sm {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
}
.btn-icon-sm:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon-sm.active { color: var(--accent); }

.view-btn { color: var(--text-muted); }
.view-btn.active { color: var(--accent-hi); background: var(--accent-glow); }

.separator {
  width: 1px; height: 18px;
  background: var(--border-mid);
  margin: 0 4px;
}

.btn-outline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 30px;
  background: none;
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.btn-outline:hover {
  border-color: var(--border-hi);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 30px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hi); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-ghost {
  width: 100%;
  padding: 7px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ===========================
   TOAST
   =========================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 1000;
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { border-color: rgba(74,222,128,0.4); color: var(--green); }
.toast.error   { border-color: rgba(248,113,113,0.4); color: var(--red); }

/* ===========================
   SCROLLBAR
   =========================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 768px) {
  .workspace { flex-direction: column; }
  .panel-preview { border-left: none; border-top: 1px solid var(--border); }
  .resize-handle { display: none; }
  .btn-outline span { display: none; }
}
