/* ============================================================
   encRoex — stylesheet
   Concept: a code editor whose file explorer lists encoders
   instead of source files, each tagged with a real
   "language color" dot (à la GitHub/VSCode).
   ============================================================ */

:root {
  --bg-app: #0a0c11;
  --bg-sidebar: #0d0f15;
  --bg-panel: #10131a;
  --bg-editor: #0c0e13;
  --bg-elevated: #161a23;
  --bg-hover: #1a1e28;
  --border: #1e2330;
  --border-soft: #171b25;

  --text-primary: #e8eaf0;
  --text-secondary: #aab0c0;
  --text-muted: #6b7284;

  --accent: #2dd4a7;
  --accent-dim: #1c9273;
  --accent-soft: rgba(45, 212, 167, 0.12);
  --accent-2: #ffb454;
  --accent-2-soft: rgba(255, 180, 84, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);

  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 8px;
  --radius-sm: 5px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 12% 8%, rgba(45, 212, 167, 0.05), transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(255, 180, 84, 0.04), transparent 40%);
}

::selection { background: var(--accent-soft); color: var(--text-primary); }

button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ================= LAYOUT ================= */
.app {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

/* ================= SIDEBAR ================= */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.brand__mark {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  text-shadow: 0 0 18px var(--accent-soft);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand__tag {
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.sidebar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 14px 6px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.sidebar__search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12.5px;
  width: 100%;
}
.sidebar__search input::placeholder { color: var(--text-muted); }

.sidebar__tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 12px;
}

.tree-group__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-sm);
  user-select: none;
}
.tree-group__head:hover { background: var(--bg-hover); }
.tree-group__head .chevron { transition: transform 0.15s ease; color: var(--text-muted); flex-shrink: 0; }
.tree-group__head .folder-icon { color: var(--text-muted); flex-shrink: 0; }
.tree-group.is-collapsed .chevron { transform: rotate(-90deg); }
.tree-group.is-collapsed .tree-group__list { display: none; }

.tree-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px 7px 26px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.tree-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.tree-item.is-active {
  background: var(--accent-soft);
  color: var(--text-primary);
  box-shadow: inset 2px 0 0 var(--accent);
}
.tree-item__ext { color: var(--text-muted); }
.tree-item.is-active .tree-item__ext { color: var(--accent); }

.lang-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 2.4s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ================= MAIN ================= */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
}
.tabbar__scroll { display: flex; gap: 6px; overflow-x: auto; }
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
}
.tabbar__actions { display: flex; gap: 7px; }
.winbtn { width: 10px; height: 10px; border-radius: 50%; opacity: 0.85; }
.winbtn--r { background: #ff5f57; }
.winbtn--y { background: #febc2e; }
.winbtn--g { background: #28c840; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
}
.crumb-sep { color: var(--text-muted); opacity: 0.5; }
.crumb-current { color: var(--accent); }

/* ================= PANEL ================= */
.panel {
  padding: 28px 32px 40px;
  max-width: 1180px;
  width: 100%;
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.panel__title {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.panel__desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13.5px;
  max-width: 56ch;
}

.mode-toggle {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn:hover:not(.is-active) { color: var(--text-secondary); }
.mode-btn.is-active { background: var(--accent); color: #06120e; }
.mode-btn:disabled { opacity: 0.35; cursor: not-allowed; }
#btnDecode.is-active, #fileBtnDecode.is-active { background: var(--accent-2); color: #241505; }

.caesar-opts {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.caesar-opts label { font-family: var(--mono); color: var(--text-primary); }
.caesar-opts input[type="number"] {
  width: 64px;
  background: var(--bg-editor);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: var(--mono);
  padding: 5px 8px;
}
.caesar-opts .hint { color: var(--text-muted); }

/* ================= EDITORS ================= */
.editors {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-editor);
}
.editor { display: flex; flex-direction: column; min-width: 0; }
.editor--full { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 18px 0; }

.editor__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.editor__count { font-variant-numeric: tabular-nums; }

.editor__body {
  display: flex;
  flex: 1;
  min-height: 260px;
}
.gutter {
  flex-shrink: 0;
  width: 42px;
  padding: 14px 0;
  text-align: right;
  padding-right: 10px;
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
  overflow: hidden;
  user-select: none;
}
textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 14px 16px;
  min-width: 0;
}
textarea::placeholder { color: var(--text-muted); }
textarea[readonly] { color: var(--accent); }

.editor__swap {
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  background: var(--bg-panel);
}
.editor__swap button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.editor__swap button:hover { color: var(--accent); border-color: var(--accent-dim); transform: rotate(180deg); }

/* ================= BUTTONS ================= */
.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.btn {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent-dim); }
.btn--primary { background: var(--accent); color: #06120e; border-color: var(--accent); }
.btn--primary:hover { background: #34e0b3; }
.btn--ghost { background: none; color: var(--text-muted); }
.btn--ghost:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.error {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--danger-soft);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: var(--mono);
}

/* ================= FILE TOOLS ================= */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 46px 20px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-editor);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.dropzone:hover, .dropzone.is-dragging {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.dropzone__title { font-family: var(--mono); font-size: 13.5px; color: var(--text-primary); }
.dropzone.is-dragging .dropzone__title, .dropzone:hover .dropzone__title { color: var(--accent); }
.dropzone__hint { font-size: 11.5px; max-width: 40ch; }

.filemeta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.field-row label { font-family: var(--mono); color: var(--text-primary); }
.field-row input {
  flex: 1;
  max-width: 260px;
  background: var(--bg-editor);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: var(--mono);
  padding: 8px 10px;
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--accent-dim);
  color: var(--text-primary);
  padding: 11px 20px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================= RESPONSIVE ================= */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    max-height: 320px;
  }
  .editors { grid-template-columns: 1fr; }
  .editor__swap { border: none; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
  .editor__swap button:hover { transform: rotate(90deg); }
  .panel { padding: 20px 16px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
