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

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3250;
  --text: #e2e4f0;
  --text2: #8b91b8;
  --primary: #4f6ef7;
  --primary-hover: #3d5de6;
  --danger: #e54a4a;
  --success: #2ecc71;
  --fb: #1877F2;
  --ig: #c837ab;
  --auto: #f39c12;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text2); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; overflow: auto;
}
.login-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px 36px; width: 360px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
  color: var(--primary);
}
.login-logo h1 { font-size: 18px; font-weight: 600; color: var(--text); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: rgba(229,74,74,.15); border: 1px solid rgba(229,74,74,.4); color: #f08080; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; height: 52px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { color: var(--primary); display: flex; align-items: center; }
.header-title { font-weight: 600; font-size: 15px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.badge-live {
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; letter-spacing: .05em;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg2);
  overflow-y: auto;
  padding: 12px 0;
}
.sidebar-section { padding: 10px 14px 14px; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: none; }
.sidebar-title { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.sidebar-note { font-size: 11px; color: var(--text2); margin-top: 6px; line-height: 1.5; }
.poll-row { display: flex; gap: 6px; }

.session-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  background: var(--bg3); margin-bottom: 4px;
  font-size: 12px; cursor: pointer;
}
.session-item:hover { background: var(--border); }
.session-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.platform-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.platform-facebook { background: var(--fb); }
.platform-instagram { background: var(--ig); }

.empty-text { font-size: 12px; color: var(--text2); }

.code-block {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px;
  font-family: monospace; font-size: 11px; color: var(--text2);
  word-break: break-all; margin-top: 4px;
}
.code-block.small { font-size: 10px; }

/* ── Main: Yorum Akışı ───────────────────────────────────────────────────── */
.main {
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}
.main-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0;
}
.count-badge { font-size: 12px; color: var(--text2); }
.main-header-actions { display: flex; gap: 8px; }

.comment-feed {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.comment-feed::-webkit-scrollbar { width: 5px; }
.comment-feed::-webkit-scrollbar-track { background: transparent; }
.comment-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.comment-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.comment-card:hover { border-color: var(--primary); background: var(--bg3); }
.comment-card.selected { border-color: var(--primary); background: var(--bg3); }
.comment-card.replied { opacity: .55; }
.comment-card.replied:hover { opacity: 1; }

.comment-header {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 5px;
}
.platform-icon { width: 14px; height: 14px; flex-shrink: 0; }
.comment-page { font-weight: 600; font-size: 12px; color: var(--text2); }
.comment-user { font-weight: 600; font-size: 13px; }
.comment-time { font-size: 11px; color: var(--text2); margin-left: auto; }
.comment-body { font-size: 13px; line-height: 1.5; color: var(--text); }

/* ── Right Panel ─────────────────────────────────────────────────────────── */
.right-panel {
  border-left: 1px solid var(--border);
  background: var(--bg2);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.reply-box {
  padding: 14px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.reply-box-header { display: flex; align-items: center; justify-content: space-between; }
.reply-box-title { font-weight: 600; font-size: 13px; }

.reply-target {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  min-height: 50px; font-size: 12px; line-height: 1.5;
}
.reply-placeholder { color: var(--text2); font-style: italic; }
.reply-msg { color: var(--text2); }

.rules-box {
  flex: 1; overflow-y: auto; padding: 12px 14px;
}
.rules-box::-webkit-scrollbar { width: 4px; }
.rules-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.rules-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-weight: 600; font-size: 13px;
}

.rule-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 8px;
}
.rule-info { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; }
.rule-keyword { font-weight: 600; font-size: 12px; }
.rule-reply { font-size: 12px; color: var(--text2); line-height: 1.4; margin-bottom: 6px; }
.rule-footer { display: flex; align-items: center; gap: 6px; }
.rule-hits { font-size: 11px; color: var(--text2); flex: 1; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge-tag {
  font-size: 10px; font-weight: 600; padding: 2px 6px;
  border-radius: 4px; background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border); text-transform: uppercase; letter-spacing: .03em;
}
.badge-facebook { color: var(--fb); border-color: var(--fb); }
.badge-instagram { color: var(--ig); border-color: var(--ig); }
.badge-all { color: var(--primary); border-color: var(--primary); }
.badge-auto { color: var(--auto); border-color: var(--auto); }
.badge-replied { color: var(--success); border-color: var(--success); }

/* ── Toggle ──────────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 34px; height: 18px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 10px; cursor: pointer; transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 12px; width: 12px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.form-row { display: flex; gap: 6px; margin-bottom: 8px; }
.input, .select, .textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { resize: vertical; min-height: 60px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b91b8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); cursor: pointer; margin-top: 8px; }
.checkbox-label input { width: 14px; height: 14px; accent-color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer; border: none;
  transition: background .15s, opacity .15s; font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-icon {
  background: transparent; border: none; cursor: pointer;
  color: var(--text2); padding: 3px 6px; border-radius: 4px;
  font-size: 13px; transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text); background: var(--bg3); }
.btn-icon.danger:hover { color: var(--danger); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; width: 480px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px); display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.import-box { display: flex; gap: 8px; margin-bottom: 6px; }
.import-box .input { flex: 1; }
.modal-divider { text-align: center; font-size: 11px; color: var(--text2); margin: 10px 0; position: relative; }
.modal-divider::before, .modal-divider::after { content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--border); }
.modal-divider::before { left: 0; } .modal-divider::after { right: 0; }

.page-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.page-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.page-name { flex: 1; font-size: 13px; }

.info-box {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; font-size: 12px;
  color: var(--text2); line-height: 1.7; margin-bottom: 14px;
}
.info-box code {
  background: var(--bg); padding: 1px 4px; border-radius: 3px;
  font-family: monospace; font-size: 11px; color: var(--primary);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.toast-success { background: #1a3a28; border: 1px solid var(--success); color: var(--success); }
.toast-error { background: #3a1a1a; border: 1px solid var(--danger); color: #f08080; }

@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Scrollbar Global ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }
