/* ============================================================
   DISCORD TEXT EDITOR — STYLE.CSS
   ============================================================ */

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

:root {
  /* Discord Colors */
  --dc-blurple:        #5865F2;
  --dc-blurple-hover:  #4752C4;
  --dc-green:          #57F287;
  --dc-yellow:         #FEE75C;
  --dc-red:            #ED4245;
  --dc-fuchsia:        #EB459E;
  --dc-white:          #FFFFFF;

  /* Background scale */
  --bg-1:   #0f1012;
  --bg-2:   #161719;
  --bg-3:   #1e1f22;
  --bg-4:   #2b2d31;
  --bg-5:   #313338;
  --bg-6:   #383a40;
  --bg-7:   #404249;

  /* Text scale */
  --text-primary:   #f2f3f5;
  --text-secondary: #b5bac1;
  --text-muted:     #80848e;
  --text-link:      #00aff4;

  /* Borders */
  --border-subtle: rgba(255,255,255,0.06);
  --border-normal: rgba(255,255,255,0.10);

  /* Misc */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --font-main:   'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Consolas', monospace;

  --header-h: 60px;
  --toolbar-h: 46px;
  --panel-header-h: 44px;
}

/* ============================================================
   BASE
   ============================================================ */

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: var(--bg-1);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */

.app-header {
  height: var(--header-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.discord-logo {
  width: 40px;
  height: 40px;
  background: var(--dc-blurple);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(88, 101, 242, 0.4);
}

.header-title h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-main);
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-normal);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.18);
}

.btn-danger:hover {
  background: rgba(237, 66, 69, 0.15);
  color: var(--dc-red);
  border-color: rgba(237, 66, 69, 0.4);
}

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

.app-main {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

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

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

.panel-editor {
  flex: 1 1 50%;
  background: var(--bg-2);
  border-right: 1px solid var(--border-subtle);
}

.panel-preview {
  flex: 1 1 50%;
  background: var(--bg-1);
  overflow-y: auto;
}

.panel-header {
  height: var(--panel-header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.panel-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-icon {
  background: rgba(88, 101, 242, 0.2);
  color: var(--dc-blurple);
}

.preview-icon {
  background: rgba(87, 242, 135, 0.2);
  color: var(--dc-green);
}

.char-counter {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.preview-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dc-green);
  background: rgba(87, 242, 135, 0.1);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid rgba(87, 242, 135, 0.2);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dc-green);
  animation: pulse-green 2s ease-in-out infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* ============================================================
   TOOLBAR
   ============================================================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: var(--toolbar-h);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border-normal);
  margin: 0 6px;
  flex-shrink: 0;
}

.tool-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tool-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.tool-btn:active {
  background: rgba(88, 101, 242, 0.25);
  color: var(--dc-blurple);
  transform: scale(0.94);
}

/* ============================================================
   EDITOR TEXTAREA
   ============================================================ */

.editor-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  padding: 20px;
  caret-color: var(--dc-blurple);
}

.editor-textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 13.5px;
  font-style: italic;
}

.editor-textarea:focus {
  outline: none;
}

/* Custom scrollbar */
.editor-textarea::-webkit-scrollbar,
.panel-preview::-webkit-scrollbar {
  width: 6px;
}

.editor-textarea::-webkit-scrollbar-track,
.panel-preview::-webkit-scrollbar-track {
  background: transparent;
}

.editor-textarea::-webkit-scrollbar-thumb,
.panel-preview::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
}

.editor-textarea::-webkit-scrollbar-thumb:hover,
.panel-preview::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* ============================================================
   DIVIDER (resizable)
   ============================================================ */

.panel-divider {
  width: 4px;
  background: var(--border-subtle);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.2s;
  position: relative;
}

.panel-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
}

.panel-divider:hover,
.panel-divider.dragging {
  background: var(--dc-blurple);
}

/* ============================================================
   DISCORD WINDOW MOCKUP
   ============================================================ */

.discord-window {
  background: var(--bg-5);
  border-radius: var(--radius-lg);
  margin: 16px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.discord-channel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-4);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.channel-icon {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 700;
}

.channel-divider {
  width: 1px;
  height: 16px;
  background: var(--border-normal);
}

.channel-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.discord-messages {
  padding: 16px;
  min-height: 120px;
}

.discord-message {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.message-avatar {
  flex-shrink: 0;
  margin-top: 2px;
}

.avatar-img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dc-blurple), #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.message-author {
  font-weight: 600;
  font-size: 14px;
  color: var(--dc-blurple);
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.message-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

.preview-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}

/* ============================================================
   DISCORD MARKDOWN STYLES (preview)
   ============================================================ */

.message-text strong {
  font-weight: 700;
  color: var(--text-primary);
}

.message-text em {
  font-style: italic;
}

.message-text u {
  text-decoration: underline;
}

.message-text s {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.message-text code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(0,0,0,0.3);
  padding: 1px 5px;
  border-radius: 3px;
  color: #e8e8e8;
  border: 1px solid rgba(255,255,255,0.06);
}

.message-text pre {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

.message-text pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.dc-spoiler {
  background: rgba(0,0,0,0.7);
  border-radius: 3px;
  padding: 0 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  color: transparent;
}

.dc-spoiler:hover,
.dc-spoiler.revealed {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.message-text blockquote {
  border-left: 4px solid var(--dc-blurple);
  padding: 4px 0 4px 12px;
  margin: 6px 0;
  color: var(--text-secondary);
  border-radius: 0 2px 2px 0;
}

.message-text h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  margin: 8px 0 4px;
  border-bottom: 1px solid var(--border-normal);
  padding-bottom: 6px;
}

.message-text h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin: 6px 0 4px;
}

.message-text h3 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  margin: 4px 0 4px;
}

.message-text ul {
  list-style: disc;
  padding-left: 20px;
  margin: 4px 0;
}

.message-text li {
  margin: 2px 0;
}

.message-text a {
  color: var(--text-link);
  text-decoration: none;
}

.message-text a:hover {
  text-decoration: underline;
}

.dc-mention {
  color: white;
  background: rgba(88, 101, 242, 0.3);
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.dc-mention:hover {
  background: rgba(88, 101, 242, 0.5);
}

.dc-channel {
  color: white;
  background: rgba(88, 101, 242, 0.3);
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.dc-channel:hover {
  background: rgba(88, 101, 242, 0.5);
}

.dc-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0;
}

/* ============================================================
   REFERENCE CARD
   ============================================================ */

.reference-card {
  margin: 0 16px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.reference-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.ref-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.ref-item code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 6px;
  color: var(--dc-green);
  white-space: nowrap;
  flex-shrink: 0;
}

.ref-item span {
  color: var(--text-muted);
  font-size: 11px;
}

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

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-6);
  color: var(--text-primary);
  border: 1px solid rgba(87, 242, 135, 0.3);
  border-radius: 40px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast svg {
  color: var(--dc-green);
  flex-shrink: 0;
}

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

@media (max-width: 768px) {
  .app-main {
    flex-direction: column;
    overflow-y: auto;
  }

  .panel-editor,
  .panel-preview {
    flex: unset;
    width: 100%;
    min-height: 50vh;
  }

  .panel-divider {
    width: 100%;
    height: 4px;
    cursor: row-resize;
  }

  .panel-divider::after {
    width: 40px;
    height: 2px;
  }

  .btn span,
  .header-subtitle { display: none; }

  .reference-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   SELECTION
   ============================================================ */

::selection {
  background: rgba(88, 101, 242, 0.4);
  color: var(--text-primary);
}
