/* ========================================================================
   Code2URL — Global Styles
   VS Code / Catppuccin-inspired dark theme
   ======================================================================== */

/* ── Fonts ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  /* Surface colors (Catppuccin Mocha) */
  --bg-base: #1e1e2e;
  --bg-surface: #181825;
  --bg-overlay: #313244;
  --bg-muted: #45475a;

  /* Text colors */
  --text-primary: #cdd6f4;
  --text-secondary: #a6adc8;
  --text-muted: #6c7086;

  /* Accent colors */
  --accent: #cba6f7;
  --accent-hover: #b4befe;
  --accent-glow: rgba(203, 166, 247, 0.25);
  --green: #a6e3a1;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --peach: #fab387;

  /* Layout */
  --header-height: 48px;

  --radius: 8px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-size: 14px;
  --line-height: 1.6;
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-overlay);
  user-select: none;
  z-index: 10;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.header__brand-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  filter: brightness(0) invert(1);
}

.header__info {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Language selector */
.lang-select {
  appearance: none;
  background: var(--bg-overlay);
  color: var(--text-secondary);
  border: 1px solid var(--bg-muted);
  border-radius: var(--radius);
  padding: 4px 28px 4px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236c7086'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.lang-select:hover,
.lang-select:focus {
  border-color: var(--accent);
  color: var(--text-primary);
  outline: none;
}

/* Character counter */
.char-counter {
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.3s;
}

.char-counter--warning {
  color: var(--yellow);
}

.char-counter--danger {
  color: var(--red);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ── Editor Container ──────────────────────────────────────────────────── */
.editor-container {
  position: relative;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Line numbers gutter */
.line-numbers {
  position: absolute;
  top: 0;
  left: 0;
  width: 52px;
  height: 100%;
  padding: 16px 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-overlay);
  overflow: hidden;
  user-select: none;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text-muted);
  text-align: right;
}

.line-numbers__inner {
  padding-right: 12px;
  white-space: pre;
}

/* Shared positioning for textarea + highlighting pre */
.editor-layer {
  position: absolute;
  top: 0;
  left: 52px;
  right: 0;
  bottom: 0;
  padding: 16px 16px 16px 16px;
  border-right: 16px solid transparent;
  background-clip: padding-box;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  tab-size: 4;
  white-space: pre;
  overflow: auto;
  outline: none;
}

/* Highlighted code (behind textarea) */
.editor-highlight {
  z-index: 1;
  color: var(--text-primary);
  pointer-events: none;
  background: transparent;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.editor-highlight::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.editor-highlight::-webkit-scrollbar-track,
.editor-highlight::-webkit-scrollbar-thumb {
  background: transparent !important;
  border: none !important;
}

.editor-highlight code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  white-space: pre;
  display: block;
}

/* Textarea (transparent, on top) */
.editor-textarea {
  z-index: 3;
  color: transparent;
  caret-color: var(--accent);
  background: transparent;
  resize: none;
  -webkit-text-fill-color: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-muted) transparent;
}

.editor-textarea::selection {
  background: rgba(203, 166, 247, 0.2);
}

.editor-textarea::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.editor-textarea::-webkit-scrollbar-track {
  background: transparent;
}

.editor-textarea::-webkit-scrollbar-thumb {
  background: var(--bg-muted);
  border: 4px solid var(--bg-base);
  border-radius: 8px;
}

.editor-textarea::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}



/* ── Copy URL Button (Floating) ────────────────────────────────────────── */
.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border: 1px solid rgba(203, 166, 247, 0.3);
  border-radius: 6px;
  background: var(--bg-overlay);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: rgba(203, 166, 247, 0.15);
  border-color: var(--accent);
}

.copy-btn:active {
  transform: scale(0.96);
}

.copy-btn--success {
  color: var(--green);
  border-color: rgba(166, 227, 161, 0.4);
}

/* ── Toast Notification ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  background: var(--bg-overlay);
  border: 1px solid var(--bg-muted);
  border-radius: var(--radius);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 13px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Placeholder state ─────────────────────────────────────────────────── */
.editor-textarea::placeholder {
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  opacity: 0.6;
}

/* ── Prism.js Theme Overrides (Catppuccin-inspired) ────────────────────── */
code[class*="language-"],
pre[class*="language-"] {
  color: var(--text-primary);
  background: none;
  text-shadow: none;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6c7086;
  font-style: italic;
}

.token.punctuation {
  color: #9399b2;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #fab387;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #a6e3a1;
}

.token.operator,
.token.entity,
.token.url {
  color: #89dceb;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #cba6f7;
}

.token.function,
.token.class-name {
  color: #89b4fa;
}

.token.regex,
.token.important,
.token.variable {
  color: #f9e2af;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header {
    padding: 0 10px;
  }

  .header__brand {
    font-size: 13px;
  }

  /* Hide brand text on mobile to save space */
  .header__brand span {
    display: none;
  }

  .header__info {
    gap: 8px;
  }

  /* Hide character counter on mobile to save space */
  .char-counter {
    display: none;
  }

  .copy-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .line-numbers {
    width: 36px;
  }

  .line-numbers__inner {
    padding-right: 8px;
  }

  .editor-layer {
    left: 36px;
    padding: 12px 12px 12px 12px;
    border-right: 12px solid transparent;
  }

}