/* style.css */

/* Reset and base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Poppins', sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  transition: background-color 0.35s ease, color 0.35s ease;
}

:root {
  --bg: #1e1e2f;
  --fg: #e0def4;
  --accent: #9ccfd8;
  --panel-bg: #2e2e42;
  --border: #44475a;
  --input-bg: #313140;
  --input-fg: #e0def4;
  --btn-bg: #4a4a70;
  --btn-fg: #e0def4;
  --btn-hover-bg: #64718b;
  --toast-bg: #44475a;
  --toast-fg: #f8f8f2;
  --shadow-color: rgba(146, 145, 176, 0.6);
}

body.light {
  --bg: #f8f9fb;
  --fg: #2d2d33;
  --accent: #4169e1;
  --panel-bg: #ffffff;
  --border: #d2d6dc;
  --input-bg: #fafbfc;
  --input-fg: #2d2d33;
  --btn-bg: #e7e9ef;
  --btn-fg: #2d2d33;
  --btn-hover-bg: #cfd3db;
  --toast-bg: #6e72bb;
  --toast-fg: #f7f7f7;
  --shadow-color: rgba(0,0,0,0.15);
}

body.vibrant {
  --bg: #111311;
  --fg: #f0d9e0;
  --accent: #f72585;
  --panel-bg: #231523;
  --border: #560bad;
  --input-bg: #330f38;
  --input-fg: #f0d9e0;
  --btn-bg: #720026;
  --btn-fg: #f0d9e0;
  --btn-hover-bg: #aa1155;
  --toast-bg: #69005f;
  --toast-fg: #ffd3f4;
  --shadow-color: rgba(246, 37, 133, 0.4);
}

/* Layout */

header {
  padding: 1rem 1.5rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px var(--shadow-color);
}

header h1 {
  font-weight: 500;
  font-size: 1.4rem;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.controls label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
}

.controls select,
.controls button {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: 0 2px 6px var(--shadow-color);
  transition: background-color 0.3s ease;
}

.controls select:focus,
.controls button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.controls button:hover {
  background: var(--btn-hover-bg);
}

main {
  height: calc(100vh - 80px);
  display: flex;
  overflow: hidden;
}

#container {
  display: flex;
  flex: 1;
  height: 100%;
  background: var(--panel-bg);
  box-shadow: inset 0 0 10px var(--shadow-color);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  background: var(--input-bg);
  border-right: 1px solid var(--border);
  font-size: 1rem;
}

#editorPanel {
  flex-basis: 50%;
  min-width: 300px;
  max-width: 70%;
  display: flex;
  flex-direction: column;
}

.output {
  flex-basis: 50%;
  max-width: 70%;
  min-width: 320px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.panel-header {
  flex-shrink: 0;
  padding: 0.8rem 1.2rem;
  background: var(--panel-bg);
  color: var(--accent);
  font-weight: 600;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

#markdownInput {
  flex-grow: 1;
  padding: 1rem 1.1rem;
  border: none;
  resize: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--input-fg);
  line-height: 1.45;
  outline: none;
  transition: background-color 0.3s, color 0.3s;
}

/* Resizer */

#resizer {
  width: 10px;
  cursor: ew-resize;
  background: transparent;
  position: relative;
}

#resizer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  width: 4px;
  background: var(--border);
  border-radius: 2px;
  opacity: 0.4;
  transition: opacity 0.3s;
}
#resizer:hover::before,
#resizer:focus-visible::before {
  opacity: 0.8;
}

/* Output Tabs */

.output-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  user-select: none;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 0.75rem 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: color 0.3s, border-bottom-color 0.3s;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  border-bottom: 3px solid var(--accent);
  color: var(--fg);
  font-weight: 700;
}

.tab-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tab content */

.tab-content {
  flex-grow: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0 0 8px 8px;
  box-shadow: inset 0 0 15px var(--shadow-color);
  -webkit-overflow-scrolling: touch;
}

.preview-panel {
  word-wrap: break-word;
}

.code-panel {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 1rem 1.1rem;
  background: var(--input-bg);
  color: var(--input-fg);
  white-space: pre-wrap;
  border-radius: 0 0 8px 8px;
}

/* Toast */

#toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: var(--toast-bg);
  color: var(--toast-fg);
  padding: 0.65rem 1.15rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px var(--shadow-color);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 100;
}

#toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Preview style variants */

.md-preview-style.article {
  background: #fef6e4;
  color: #4a352e;
  font-family: Georgia, serif;
  padding: 2rem 3rem;
  border-radius: 10px;
  line-height: 1.7;
  box-shadow: 0 0 18px rgba(255, 194, 122, 0.45);
}

.md-preview-style.article h1, .md-preview-style.article h2 {
  color: #b5651d;
  font-weight: 600;
}

.md-preview-style.article blockquote {
  border-left: 5px solid #b5651d;
  color: #7d5a50;
  margin: 0 0 1.5rem 0;
  padding-left: 1rem;
  font-style: italic;
}

.md-preview-style.technical {
  font-family: 'JetBrains Mono', monospace;
  background: #1a1a2e;
  color: #a0e7e5;
  padding: 1.5rem 2rem;
  border-radius: 8px;
}

.md-preview-style.technical a {
  color: #00f7ff;
  text-decoration: underline;
}

.md-preview-style.technical pre, .md-preview-style.technical code {
  background: #0f3460;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.9rem;
}

.md-preview-style.elegant {
  font-family: 'Merriweather', serif;
  color: #4f3f2f;
  background: #faf5f0;
  padding: 2rem 3rem;
  border-radius: 12px;
  font-style: normal;
}

.md-preview-style.elegant h1,
.md-preview-style.elegant h2 {
  font-weight: 700;
  color: #ab6e3d;
}

.md-preview-style.elegant blockquote {
  font-style: italic;
  border-left: 3px solid #ab6e3d;
  color: #7e6a53;
  margin-left: 0;
  padding-left: 1rem;
}

/* Responsive */

@media (max-width: 850px) {
  main {
    height: auto;
  }

  #container {
    flex-direction: column;
    height: auto;
  }

  #editorPanel,
  .output {
    flex-basis: auto;
    width: 100%;
    max-width: none;
    min-width: auto;
    height: 300px;
  }

  #resizer {
    width: 100%;
    height: 10px;
    cursor: ns-resize;
    border-right: none;
    border-top: 1px solid var(--border);
  }

  #resizer::before {
    width: 40px;
    height: 4px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 2px;
    background-color: var(--border);
    opacity: 0.5;
  }
}
