@import url("./shared.css");
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap");

/* ── TOKENS ── */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #141414;
  --bg-tertiary: #1a1a1a;
  --bg-surface: #202020;
  --bg-hover: #2a2a2a;
  --border: #2e2e2e;
  --border-light: #383838;
  --text-primary: #f0f0f0;
  --text-muted: #666;
  --text-dim: #888;
  --accent: #ffac1c;
  --accent-dim: rgba(255, 172, 28, 0.12);
  --accent-hover: #ffc04d;
  --header-h: 44px;
  --status-h: 26px;
  --resizer-w: 6px;
  --font: "Montserrat", sans-serif;
  --font-mono: "Consolas", "Fira Code", "Monaco", monospace;
  --radius: 8px;
}

/* light mode overrides */
body.light-mode {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ebebeb;
  --bg-tertiary: #e0e0e0;
  --bg-surface: #ffffff;
  --bg-hover: #d8d8d8;
  --border: #d0d0d0;
  --border-light: #c0c0c0;
  --text-primary: #1a1a1a;
  --text-muted: #999;
  --text-dim: #777;
}

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

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #555;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}

/* ── BODY ── */
body {
  font-family: var(--font);
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition:
    background 0.25s,
    color 0.25s;
}

body.wrapped {
  flex-direction: column;
}

/* ── PANEL WRAPPER ── */
.panel-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  transition:
    width 0.2s ease,
    height 0.2s ease;
}

#editor-wrapper {
  width: 42%;
  min-width: 280px;
  max-width: calc(100% - 280px);
}

#preview-wrapper {
  width: 58%;
}
body.wrapped #editor-wrapper,
body.wrapped #preview-wrapper {
  width: 100% !important;
  max-width: 100%;
  height: 50%;
}

/* ── PANEL HEADER ── */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
  gap: 10px;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.2s;
}

.panel-title:hover {
  opacity: 0.8;
}

.panel-title svg {
  width: 15px;
  height: 15px;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Make resizer touch-friendly */
.resizer {
  min-height: 12px;  
  min-width: 12px;  
  touch-action: none;
}
/* Back Button */
.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.back-btn svg {
  width: 14px;
  height: 14px;
}

.back-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}
/* ── PANEL BUTTONS ── */
.panel-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.panel-btn svg {
  width: 14px;
  height: 14px;
}

.panel-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

/* theme toggle button */
.header-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  transition: all 0.2s;
  white-space: nowrap;
}

.header-toggle-btn svg {
  width: 13px;
  height: 13px;
}

.header-toggle-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* ── PANEL CONTENT ── */
.panel-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── EDITOR ── */
#editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  height: 100%;
}

.editor-container {
  flex: 1;
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-tertiary);
  transition: border-color 0.2s;
}

.editor-container:focus-within {
  box-shadow: 0 0 0 2px rgba(255, 172, 28, 0.08);
}

.editor-scroll-wrapper {
  display: flex;
  flex: 1;
  overflow: auto;
}

.line-numbers {
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 10px 10px 10px 8px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  user-select: none;
  min-width: 42px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  white-space: pre;
  flex-shrink: 0;
}

#sourceCode {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 2;
  caret-color: var(--accent);
  transition:
    background 0.25s,
    color 0.25s;
}

#sourceCode::placeholder {
  color: #444;
}
body.light-mode #sourceCode::placeholder {
  color: #bbb;
}

/* ── STATUS BAR ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--status-h);
  padding: 0 14px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

.status-divider {
  width: 1px;
  height: 12px;
  background: var(--border-light);
}

/* ── RESIZER ── */
.resizer {
  width: var(--resizer-w);
  background: var(--border);
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  position: relative;
  margin-right: 12px;
}

.resizer:hover,
.resizer.active {
  background: var(--accent);
}

.resizer-handle {
  width: 2px;
  height: 32px;
  background: var(--border-light);
  border-radius: 999px;
  transition: background 0.2s;
}

.resizer:hover .resizer-handle {
  background: #000;
}

body.wrapped .resizer {
  width: 100%;
  height: var(--resizer-w);
  cursor: row-resize;
}

body.wrapped .resizer-handle {
  width: 32px;
  height: 2px;
}

/* ── PREVIEW PANEL ── */
#preview-container {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.preview-wrapper {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* chrome-style browser bar */
.chrome-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-shape {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-shape svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--accent);
}

#preview {
  flex: 1;
  border: none;
  display: block;
  width: 100%;
  background: #fff;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  body:not(.wrapped) {
    flex-direction: column;
  }
  body:not(.wrapped) #editor-wrapper,
  body:not(.wrapped) #preview-wrapper {
    width: 100% !important;
    max-width: 100%;
    height: 50%;
  }
  body:not(.wrapped) .resizer {
    width: 100%;
    height: var(--resizer-w);
    cursor: row-resize;
  }
  body:not(.wrapped) .resizer-handle {
    width: 32px;
    height: 2px;
  }
}
