/* ══════════════════════════════════════════════
   TSD News Dashboard — Vanilla CSS
   ══════════════════════════════════════════════ */

* { box-sizing: border-box; }

:root {
  --accent:  #1e88ff;
  --accent2: #7c5dff;
  --green:   #22c55e;
  --amber:   #f59e0b;
  --gray:    #6b7280;
  --surface: rgba(255,255,255,0.04);
  --border:  rgba(255,255,255,0.08);
  --radius:  12px;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(120% 120% at 20% 10%, #123, transparent), #0b1220;
  color: #e7edf7;
  min-height: 100vh;
}

a { color: #6cb2ff; }

/* ── Shell ── */
.app-shell { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.25); }
.muted { color: #8892a4; font-size: 13px; margin: 4px 0 0; }

/* ── App header ── */
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.app-header h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.3px; }
.app-header .primary { display: flex; align-items: center; gap: 6px; }

/* ── Stat cards ── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid; border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-value { display: block; font-size: 28px; font-weight: 700; }
.stat-label { display: block; font-size: 12px; color: #8892a4; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Filter bar ── */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; padding: 12px 16px; }
.filter-search { flex: 1; min-width: 180px; }
.filter-bar select { width: auto; min-width: 130px; }

/* ── Buttons ── */
button {
  cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; font-size: 14px;
  font-family: inherit; transition: opacity .15s;
}
button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
button.ghost   { background: transparent; border: 1px solid var(--border); color: #e7edf7; }
button.compact { padding: 8px 12px; font-size: 13px; }
.btn-icon { background: transparent; padding: 6px; border-radius: 8px; color: #8892a4; }
.btn-icon:hover { color: #e7edf7; background: rgba(255,255,255,0.06); }
.btn-icon.danger:hover { color: #f87171; background: rgba(248,113,113,0.1); }
.btn-mini { padding: 4px 8px; font-size: 11px; border-radius: 6px; background: rgba(255,255,255,0.08); color: #8892a4; cursor: pointer; border: none; font-family: inherit; }

/* ── Inputs ── */
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.06);
  color: #e7edf7; font-size: 14px; font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.code-textarea { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; line-height: 1.6; }

/* ── Form grid ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #8892a4; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.field-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field-header label { margin-bottom: 0; }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; }

/* ── Language tabs ── */
.lang-tabs { display: flex; gap: 4px; margin-bottom: 16px; background: rgba(255,255,255,0.03); padding: 4px; border-radius: 10px; }
.lang-tab { padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; background: transparent; color: #8892a4; border: none; cursor: pointer; font-family: inherit; }
.lang-tab.active { background: rgba(255,255,255,0.08); color: #e7edf7; }
.tab-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-left: 6px; vertical-align: middle; }
.tab-dot.hidden { display: none; }
.lang-badge { font-size: 10px; background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; font-weight: 700; letter-spacing: 0.5px; }

/* ── Toggle tabs (edit/preview) ── */
.toggle-tabs { display: flex; gap: 2px; background: rgba(255,255,255,0.04); border-radius: 8px; padding: 2px; }
.toggle-tabs button { padding: 4px 10px; font-size: 12px; border-radius: 6px; color: #8892a4; background: transparent; border: none; cursor: pointer; font-family: inherit; }
.toggle-tabs button.active { background: rgba(255,255,255,0.1); color: #e7edf7; }

/* ── HTML preview ── */
.html-preview { border: 1px solid var(--border); border-radius: 8px; padding: 16px; min-height: 200px; background: rgba(255,255,255,0.02); font-size: 14px; line-height: 1.7; }
.html-preview h1, .html-preview h2, .html-preview h3 { margin-top: 0; }
.html-preview img { max-width: 100%; border-radius: 8px; }

/* ── Image preview ── */
.image-preview { margin-top: 8px; border-radius: 8px; overflow: hidden; max-width: 240px; border: 1px solid var(--border); }
.image-preview img { display: block; width: 100%; height: auto; }

/* ── News table ── */
.news-table-wrap { overflow-x: auto; }
.news-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.news-table thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #8892a4; font-weight: 600; padding: 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left;
}
.news-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background .15s; }
.news-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.news-table td { padding: 10px; vertical-align: middle; }
.col-img { width: 48px; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: block; }
.thumb-placeholder { background: rgba(255,255,255,0.06); }
.item-title { display: block; font-weight: 600; color: #e7edf7; }
.item-slug { display: block; font-size: 11px; color: #6b7280; margin-top: 2px; }
.col-actions { white-space: nowrap; }
.cell-langs { white-space: nowrap; }
.cell-date { white-space: nowrap; font-size: 13px; color: #8892a4; }

/* ── Language dots ── */
.lang-dot { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 4px; margin-right: 3px; background: rgba(255,255,255,0.05); color: #4b5563; font-weight: 700; }
.lang-dot.filled { background: rgba(34,197,94,0.15); color: var(--green); }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; border: 1px solid transparent; }
.badge-cat { background: rgba(124,93,255,0.12); color: #a78bfa; border-color: rgba(124,93,255,0.2); }

/* ── Form ── */
.form-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.form-header h3 { margin: 0; font-size: 18px; }
.form-error { color: #f87171; font-size: 13px; padding: 8px 12px; background: rgba(248,113,113,0.1); border-radius: 8px; margin-bottom: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px); display: flex; align-items: flex-start;
  justify-content: center; z-index: 999; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #0f1628; border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; width: min(680px, calc(100% - 32px));
  box-shadow: 0 24px 80px rgba(0,0,0,0.5); animation: modalIn .2s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ── Toast notifications ── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  pointer-events: auto; cursor: pointer; animation: toastIn .25s ease-out;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3); font-family: inherit;
}
.toast-success { background: #065f46; color: #6ee7b7; border: 1px solid #10b981; }
.toast-error   { background: #7f1d1d; color: #fca5a5; border: 1px solid #ef4444; }
.toast-info    { background: #1e3a5f; color: #93c5fd; border: 1px solid #3b82f6; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 16px; color: #6b7280; }
.empty-state svg { margin-bottom: 12px; }
.empty-state p { margin: 4px 0; }

/* ── Loading state ── */
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px; color: #8892a4; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.page-btns { display: flex; gap: 6px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
  .filter-bar select, .filter-bar input { width: 100%; }
  .modal { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .news-table { font-size: 13px; }
  .col-img { display: none; }
}
@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 22px; }
  .lang-tabs { overflow-x: auto; }
}

/* ── Quill Editor — Dark Theme Overrides ── */
.ql-toolbar.ql-snow {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.ql-container.ql-snow {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: rgba(255,255,255,0.03);
  color: #e7edf7;
  font-family: inherit;
  font-size: 14px;
  min-height: 200px;
}
.ql-editor {
  min-height: 200px;
  line-height: 1.6;
}
.ql-editor.ql-blank::before {
  color: rgba(255,255,255,0.35);
  font-style: italic;
}
/* Toolbar icon colors */
.ql-snow .ql-stroke { stroke: #c0c8d8; }
.ql-snow .ql-fill   { fill: #c0c8d8; }
.ql-snow .ql-picker-label { color: #c0c8d8; }
.ql-snow .ql-picker-options {
  background: #1a2538;
  border-color: var(--border);
}
.ql-snow .ql-picker-item { color: #c0c8d8; }
.ql-snow .ql-picker-item:hover,
.ql-snow .ql-picker-label:hover { color: #fff; }
.ql-snow .ql-picker-item:hover .ql-stroke,
.ql-snow .ql-picker-label:hover .ql-stroke { stroke: #fff; }
.ql-snow .ql-picker-item:hover .ql-fill,
.ql-snow .ql-picker-label:hover .ql-fill { fill: #fff; }
.ql-snow .ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow .ql-active .ql-fill   { fill: var(--accent); }
.ql-snow .ql-active { color: var(--accent); }
.ql-snow .ql-tooltip {
  background: #1a2538;
  border-color: var(--border);
  color: #e7edf7;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.ql-snow .ql-tooltip input[type="text"] {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: #e7edf7;
  border-radius: 4px;
}
.ql-snow .ql-tooltip a { color: var(--accent); }

/* Image upload button — uploading state */
.ql-toolbar .ql-image.uploading {
  opacity: 0.5;
  pointer-events: none;
  animation: ql-pulse 1s ease-in-out infinite;
}
@keyframes ql-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.2; }
}

/* Inline images in editor */
.ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 8px 0;
  cursor: pointer;
  transition: outline .15s;
}
.ql-editor img:hover { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Image borders (data-border attribute) */
.ql-editor img[data-border="thin"]   { border: 1px solid rgba(255,255,255,0.2); }
.ql-editor img[data-border="normal"] { border: 2px solid rgba(255,255,255,0.35); }

/* ── Custom Toolbar Buttons ── */
.ql-snow .ql-poem,
.ql-snow .ql-song {
  width: auto !important;
  padding: 0 6px !important;
  font-size: 13px;
  font-weight: 600;
}
.ql-snow .ql-poem::after  { content: '📜'; }
.ql-snow .ql-song::after  { content: '🎵'; }
.ql-snow .ql-poem.ql-active,
.ql-snow .ql-song.ql-active { background: rgba(30,136,255,0.15); border-radius: 4px; }

/* ── Poem Block in Editor ── */
.ql-editor .poem-block {
  text-align: center;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 2;
  padding: 2px 32px;
  margin: 0;
  background: rgba(124, 93, 255, 0.06);
  border-left: 3px solid #7c5dff;
}

/* ── Song / Lyrics Block in Editor ── */
.ql-editor .song-block {
  font-family: 'Courier New', Courier, monospace;
  line-height: 1.8;
  padding: 2px 20px;
  margin: 0;
  background: rgba(34, 197, 94, 0.06);
  border-left: 3px solid #22c55e;
}

/* ── YouTube Video Embed in Editor ── */
.ql-editor .video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  margin: 12px 0;
  background: rgba(255,255,255,0.03);
}
.ql-editor .video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ── Blockquote in Editor ── */
.ql-editor blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 16px;
  margin: 8px 0;
  background: rgba(30, 136, 255, 0.05);
  color: #c0c8d8;
  font-style: italic;
}

/* ── Image Options Toolbar ── */
.img-toolbar {
  position: fixed;
  z-index: 10000;
  background: #1a2538;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 13px;
}
.img-tb-section {
  display: flex;
  align-items: center;
  gap: 4px;
}
.img-tb-label {
  color: #8899aa;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-right: 2px;
}
.img-tb-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #c0c8d8;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all .15s;
}
.img-tb-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.img-tb-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.img-tb-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.img-tb-caption-section { flex: 1; min-width: 140px; }
.img-tb-caption-section input {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #e7edf7;
  padding: 3px 8px;
  font-size: 12px;
  width: 100%;
  max-width: 180px;
}
.img-tb-caption-section input::placeholder { color: rgba(255,255,255,0.3); }
