/* ═══════════════════════════════════════════════
   PastePHP — GitHub-style neutral dark theme
   ═══════════════════════════════════════════════ */

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

:root {
  --bg:          #0d1117;
  --bg-2:        #161b22;
  --bg-3:        #21262d;
  --border:      #30363d;
  --border-2:    #3d444d;
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-link:   #58a6ff;
  --text-link-h: #79c0ff;
  --accent:      #238636;
  --accent-h:    #2ea043;
  --danger:      #da3633;
  --danger-h:    #f85149;
  --yellow:      #9e6a03;
  --yellow-bg:   #2d2103;
  --green-bg:    #0d2b0d;
  --red-bg:      #2d0b0b;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 1px 3px rgba(0,0,0,.4);
  --font-mono:   'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --font-ui:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--text-link-h); text-decoration: underline; }

code, pre { font-family: var(--font-mono); }

/* ── Layout ───────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.main-content { flex: 1; padding: 1.5rem 1.25rem 3rem; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── Header ───────────────────────────────────── */
.site-header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.logo:hover { color: var(--text); text-decoration: none; opacity: .85; }
.logo svg { color: var(--text-link); }

.site-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.site-nav a {
  color: var(--text-muted);
  padding: .35rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.site-nav a:hover { color: var(--text); background: var(--bg-3); text-decoration: none; }
.site-nav .nav-user { color: var(--text); font-weight: 500; }

/* ── Footer ───────────────────────────────────── */
.site-footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--text-muted);
}
.footer-links { display: flex; gap: 1rem; }

/* ── Card ─────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-h);
}
.btn-primary:hover { background: var(--accent-h); color: #fff; }

.btn-ghost {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--border); }
.btn-ghost.active { background: var(--text-link); color: #fff; border-color: var(--text-link); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger-h);
}
.btn-danger:hover { background: var(--danger-h); color: #fff; }

.btn-lg { padding: .6rem 1.4rem; font-size: 1rem; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn-xs { padding: .2rem .5rem; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Alerts ───────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: .9rem;
}
.alert-success { background: var(--green-bg); border-color: #238636; color: #3fb950; }
.alert-error   { background: var(--red-bg);   border-color: #da3633; color: #f85149; }
.alert-info    { background: #111d2e;          border-color: #1f6feb; color: #58a6ff; }

/* ── Badges ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.badge-green  { background: var(--green-bg); color: #3fb950; border-color: #238636; }
.badge-yellow { background: var(--yellow-bg); color: #d29922; border-color: var(--yellow); }
.badge-red    { background: var(--red-bg); color: #f85149; border-color: var(--danger); }
.badge-lang   { background: var(--bg-3); color: var(--text-muted); border-color: var(--border); }
.badge-xs     { padding: .1rem .4rem; font-size: .7rem; }

/* ── Forms ────────────────────────────────────── */
.input, .select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .9rem;
  padding: .5rem .75rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--text-link); box-shadow: 0 0 0 3px rgba(88,166,255,.15); }
.input::placeholder { color: var(--text-muted); }
.input-sm { width: auto; min-width: 70px; }
.input-file { padding: .4rem .5rem; cursor: pointer; }

.label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: .35rem;
}

.form-group { margin-bottom: 1rem; }

.form-row { margin-bottom: .75rem; }

.title-input {
  font-size: 1.15rem;
  font-weight: 600;
  background: transparent;
  border-color: transparent;
  padding-left: 0;
}
.title-input:focus { border-color: var(--border); background: var(--bg); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8590' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
  width: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-options-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-muted);
}
.checkbox-label input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--text-link); }

.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: .5rem; }

/* ── Muted text ───────────────────────────────── */
.muted { color: var(--text-muted); font-size: .875rem; }

/* ── Home layout ──────────────────────────────── */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .home-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ── Editor ───────────────────────────────────── */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: .5rem .75rem;
}

.char-count { margin-left: auto; font-size: .8rem; color: var(--text-muted); }

.editor-wrap { position: relative; }

.editor {
  display: block;
  width: 100%;
  min-height: 340px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .88rem;
  line-height: 1.6;
  padding: 1rem;
  resize: vertical;
  outline: none;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
  transition: border-color .15s;
}
.editor:focus { border-color: var(--text-link); box-shadow: 0 0 0 3px rgba(88,166,255,.15); }

/* ── Image preview ────────────────────────────── */
.image-preview-wrap {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: 1rem;
  padding: .75rem;
  background: var(--bg-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.image-preview-wrap img {
  max-height: 120px;
  max-width: 200px;
  border-radius: var(--radius);
  object-fit: cover;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }

.stats-list { list-style: none; }
.stats-list li {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.stats-list li:last-child { border-bottom: none; }
.stat-val { font-weight: 600; color: var(--text); }

.recent-list { list-style: none; }
.recent-list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.recent-list li:last-child { border-bottom: none; }
.recent-link { display: block; font-size: .88rem; font-weight: 500; color: var(--text); margin-bottom: .2rem; }
.recent-link:hover { color: var(--text-link); text-decoration: none; }
.recent-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Paste view ───────────────────────────────── */
.paste-view { display: flex; flex-direction: column; gap: 1rem; }

.paste-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.paste-header-main { flex: 1; min-width: 0; }
.paste-title { font-size: 1.3rem; font-weight: 600; margin-bottom: .4rem; word-break: break-word; }
.paste-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }
.paste-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }

.code-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--bg-3);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  font-size: .82rem;
  color: var(--text-muted);
}
.code-lines { margin-right: auto; }

.paste-code-card { padding: 0; overflow: hidden; }

.code-wrap {
  display: flex;
  overflow-x: auto;
}

.line-numbers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 1rem .75rem 1rem .5rem;
  background: var(--bg-3);
  border-right: 1px solid var(--border);
  user-select: none;
  min-width: 46px;
  flex-shrink: 0;
}
.line-numbers span {
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--text-muted);
  display: block;
}

.paste-pre {
  margin: 0;
  padding: 1rem;
  flex: 1;
  overflow-x: auto;
  white-space: pre;
  background: var(--bg) !important;
}

.paste-pre code {
  font-size: .85rem;
  line-height: 1.6;
  background: transparent !important;
  padding: 0 !important;
}

/* Override highlight.js background */
.hljs { background: transparent !important; }

.paste-image-card { padding: .75rem; }
.paste-image { max-width: 100%; max-height: 500px; border-radius: var(--radius); display: block; object-fit: contain; }

/* ── Token notice ─────────────────────────────── */
.token-notice { background: #1c2128; border-color: #d29922; }
.delete-token {
  display: inline-block;
  margin-top: .5rem;
  padding: .4rem .75rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: .85rem;
  word-break: break-all;
  border: 1px solid var(--border);
}

/* ── Password gate ────────────────────────────── */
.pw-gate {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
}
.pw-gate-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.pw-gate h2 { margin-bottom: .5rem; }
.pw-gate .form-group { text-align: left; margin-top: 1.25rem; }
.pw-gate .btn { margin-top: .5rem; width: 100%; justify-content: center; }

/* ── Comments ─────────────────────────────────── */
.comments-section { margin-top: .5rem; }
.comments-list { margin-bottom: 1.25rem; }
.comment {
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .85rem;
  margin-bottom: .35rem;
}
.del-comment { color: var(--danger) !important; cursor: pointer; font-size: .8rem; }
.del-comment:hover { text-decoration: none; opacity: .8; }
.comment-body { font-size: .9rem; line-height: 1.6; color: var(--text); word-break: break-word; }

.comment-form { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.comment-input { resize: vertical; min-height: 80px; font-family: var(--font-ui); }

/* ── Auth pages ───────────────────────────────── */
.auth-wrap { display: flex; justify-content: center; padding: 3rem 1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 1.25rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--text-muted); }

/* ── Account page ─────────────────────────────── */
.account-layout { display: flex; flex-direction: column; gap: 1rem; }
.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.account-header h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .25rem; }
.account-stats { display: flex; gap: 1rem; }
.stat-pill {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .5rem 1.25rem;
  text-align: center;
}
.stat-num { display: block; font-size: 1.4rem; font-weight: 700; color: var(--text-link); }
.stat-lbl { font-size: .78rem; color: var(--text-muted); }

/* ── Tables ───────────────────────────────────── */
.paste-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.paste-table th {
  text-align: left;
  padding: .5rem .75rem;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.paste-table td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.paste-table tr:last-child td { border-bottom: none; }
.paste-table tr:hover td { background: var(--bg-3); }
.paste-link { font-weight: 500; color: var(--text); }
.paste-link:hover { color: var(--text-link); text-decoration: none; }

/* ── Pagination ───────────────────────────────── */
.pagination {
  display: flex;
  gap: .35rem;
  padding-top: 1rem;
  justify-content: center;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}

/* ── Admin ────────────────────────────────────── */
.section-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.stat-card { text-align: center; padding: 1rem; }
.stat-big { font-size: 2rem; font-weight: 700; color: var(--text-link); margin-bottom: .25rem; }

.admin-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 768px) { .admin-cols { grid-template-columns: 1fr; } }

.cfg-section { font-size: .85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin: 1rem 0 .5rem; }

.cfg-row { margin-bottom: .75rem; }
.cfg-inputs { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; flex-wrap: wrap; }

/* ── Error page ───────────────────────────────── */
.error-page { text-align: center; padding: 5rem 1rem; }
.error-page h1 { font-size: 5rem; font-weight: 800; color: var(--text-muted); line-height: 1; margin-bottom: .5rem; }
.error-page p { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Empty state ──────────────────────────────── */
.empty-state { text-align: center; padding: 3rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 600px) {
  .paste-header { flex-direction: column; }
  .paste-actions { justify-content: flex-start; }
  .header-inner { gap: .5rem; }
  .site-nav a { padding: .3rem .5rem; font-size: .82rem; }
  .form-grid { grid-template-columns: 1fr; }
  .account-header { flex-direction: column; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── File load toolbar label ─────────────────── */
.file-load-name {
  font-size: .8rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

/* ── API Docs ─────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { display: none; }
}

.docs-nav { position: sticky; top: 72px; padding: .75rem 0; }
.docs-nav-list { list-style: none; }
.docs-nav-list a {
  display: block;
  padding: .35rem 1rem;
  font-size: .875rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  text-decoration: none;
  transition: color .15s, background .15s;
}
.docs-nav-list a:hover { color: var(--text); background: var(--bg-3); text-decoration: none; }

.docs-title { font-size: 1.8rem; font-weight: 700; margin-bottom: .4rem; }
.docs-lead   { color: var(--text-muted); font-size: 1.05rem; margin-bottom: 1.5rem; }

.docs-section { margin-bottom: 2.5rem; }
.docs-section h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.docs-section h3 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 1rem 0 .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .78rem;
}
.docs-section p { margin-bottom: .75rem; line-height: 1.7; }
.docs-section code { background: var(--bg-3); padding: .15rem .4rem; border-radius: 4px; font-size: .85em; border: 1px solid var(--border); }
.docs-section pre code { background: transparent; border: none; padding: 0; font-size: inherit; }

.docs-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: .5rem 0 1rem;
  font-size: .84rem;
  line-height: 1.6;
}

.docs-table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.docs-table th {
  text-align: left;
  padding: .5rem .75rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
.docs-table td {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.docs-table code { background: var(--bg-3); padding: .1rem .35rem; border-radius: 4px; font-size: .82em; }

.http-method {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: var(--radius);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  font-family: var(--font-mono);
}
.http-method.get  { background: #0d2b0d; color: #3fb950; border: 1px solid #238636; }
.http-method.post { background: #111d2e; color: #58a6ff; border: 1px solid #1f6feb; }

.api-key-card { margin-bottom: 2rem; }
.api-key-display {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  margin-top: .5rem;
}
.api-key-value {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text);
  flex: 1;
  word-break: break-all;
  background: none;
  border: none;
  padding: 0;
}

.cli-download-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.1rem;
  margin-bottom: 1.25rem;
  background: var(--bg-3);
  border-color: var(--border-2);
}
