@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --navy: #0f2744;
  --navy-mid: #1e3a5f;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(15, 39, 68, 0.08);
  --nav-h: 64px;
  --bottom-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: var(--blue); text-decoration: none; }

/* ── Auth pages ── */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, var(--white) 0%, var(--gray-100) 60%, var(--blue-soft) 100%);
}

.auth-card {
  width: min(100%, 420px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
}

.auth-logo p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.auth-back {
  text-align: center;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.auth-back a {
  color: var(--muted);
}

.auth-back a:hover {
  color: var(--blue);
}

.badge-local {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--warn);
  color: var(--white);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  background: var(--gray-100);
  padding: 0.25rem;
  border-radius: 8px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
}

.tab.active {
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.8rem 1.25rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  width: 100%;
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover { background: var(--navy-mid); }

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--border);
}

.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.8rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.alert-info { background: var(--blue-soft); color: var(--navy-mid); border: 1px solid #bfdbfe; }

.hidden { display: none !important; }

/* ── App shell ── */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  display: none;
  width: 260px;
  flex-shrink: 0;
  background: var(--navy);
  color: var(--white);
  padding: 1.5rem 1rem;
  flex-direction: column;
}

.sidebar-brand {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.sidebar-sub {
  font-size: 0.72rem;
  color: var(--gray-400);
  margin-bottom: 2rem;
}

.sidebar-nav { list-style: none; flex: 1; }

.sidebar-nav li { margin-bottom: 0.25rem; }

.sidebar-nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}

.sidebar-nav button:hover,
.sidebar-nav button.active {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

.sidebar-footer {
  font-size: 0.75rem;
  color: var(--gray-400);
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

#sidebar-user {
  white-space: pre-line;
  line-height: 1.4;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: var(--bottom-h);
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}

.topbar-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.content {
  flex: 1;
  padding: 1.25rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-h);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.bottom-nav button {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  cursor: pointer;
}

.bottom-nav button.active { color: var(--blue); }

.bottom-nav .icon { font-size: 1.25rem; }

/* ── Metrics ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.metric-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-card .value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy);
  margin-top: 0.25rem;
}

.section-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.section-card h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.75rem;
}

.neg-item {
  border-left: 3px solid var(--warn);
  background: #fffbeb;
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.neg-item strong { color: var(--navy); }

.neg-item .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; }

.priority-yuksek { border-left-color: var(--danger); background: #fef2f2; }

/* ── Chat ── */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--bottom-h) - 120px);
  min-height: 400px;
}

.chat-disclaimer {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--gray-100);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.msg {
  max-width: 88%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.msg-user {
  align-self: flex-end;
  background: var(--blue);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.msg-bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-flagged {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.msg-thinking {
  color: var(--muted);
  font-style: italic;
}

.thinking-dots span {
  animation: thinkDot 1.2s ease-in-out infinite;
  opacity: 0.25;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinkDot {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--blue);
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--white);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--navy-mid);
  cursor: pointer;
}

.chip:hover { border-color: var(--blue); color: var(--blue); }

/* ── Admin ── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.admin-form {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  .main-area { padding-bottom: 0; }
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .auth-card { padding: 2.25rem 2rem; }
}

@media (min-width: 1024px) {
  .metrics-grid { grid-template-columns: repeat(6, 1fr); }
  .content { padding: 1.75rem 2rem; }
}

/* ── Brand / logo ── */
.brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.75rem;
}

.brand-logo, .topbar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-logo-img {
  width: 100%;
  max-width: 168px;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #fff;
  padding: 0.35rem 0.5rem;
  object-fit: contain;
}

.topbar-logo-img,
.topbar-title-logo {
  height: 38px;
  width: auto;
  max-width: 148px;
  object-fit: contain;
  display: block;
  mix-blend-mode: multiply;
}

.topbar-title-logo {
  height: 34px;
  max-width: 132px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar-logo { display: block; }

@media (min-width: 768px) {
  .topbar-logo { display: none; }
}

.auth-logo-img {
  width: auto;
  height: 56px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 0.5rem;
  mix-blend-mode: multiply;
}

.admin-wide { width: min(100%, 820px); }

.admin-logo {
  margin-bottom: 1.75rem;
}

.admin-logo-img {
  width: min(100%, 300px);
  height: auto;
  max-width: 320px;
  object-fit: contain;
  margin: 0 auto 0.65rem;
  display: block;
  mix-blend-mode: multiply;
}

.admin-logo p {
  margin-top: 0.35rem;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Charts ── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .charts-row { grid-template-columns: 1.4fr 1fr; }
}

.chart-card h3 { margin-bottom: 0.35rem; }

.chart-bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 64px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
}

.chart-bar-label { color: var(--muted); font-weight: 600; }

.chart-bar-track {
  height: 10px;
  background: var(--gray-100);
  border-radius: 999px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.chart-bar-val {
  font-weight: 700;
  color: var(--navy);
  text-align: right;
  font-size: 0.72rem;
}

.donut-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0.5rem auto 0;
}

.donut-svg { width: 100%; height: 100%; }

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.donut-center strong {
  font-size: 1.35rem;
  color: var(--navy);
}

.camp-chart-row {
  margin-bottom: 0.65rem;
}

.camp-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy);
  display: block;
  margin-bottom: 0.25rem;
}

.camp-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.camp-bar {
  height: 6px;
  border-radius: 999px;
  min-width: 4px;
}

.camp-bar.clicks { background: #2563eb; }
.camp-bar.cost { background: #d97706; }

.camp-item { border-left-color: #2563eb !important; background: #f8fafc !important; }

#campaigns-chart {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border);
}

/* ── Negative keywords UI ── */
.neg-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.neg-dismiss {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.35rem;
  border-radius: 6px;
}

.neg-dismiss:hover {
  background: #fee2e2;
  color: var(--danger);
}

.neg-add-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.neg-add-form input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

.neg-subtitle {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
  margin: 1rem 0 0.5rem;
}

.neg-custom:not(.neg-saved-complete) {
  background: #f0f9ff !important;
  border-left-color: var(--blue) !important;
}

.neg-item.muted { opacity: 0.75; }

.admin-cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.admin-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

/* ── Vinc brand (Veri İnternet Ağ Campain) ── */
.vinc-brand {
  font-weight: 700;
  color: var(--navy);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.vinc-brand-sm {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.92);
}

.vinc-brand-top {
  font-size: 0.62rem;
  max-width: 88px;
  flex-shrink: 0;
}

.vinc-gold {
  color: #d4a017;
  font-weight: 800;
}

.sidebar .vinc-gold {
  color: #f0c040;
}

h2.vinc-title,
#view-title.vinc-title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  max-width: 220px;
  display: flex;
  align-items: center;
}

@media (min-width: 768px) {
  h2.vinc-title,
  #view-title.vinc-title {
    font-size: 0.95rem;
    max-width: none;
  }
}

/* ── Negatif inline mark ── */
.neg-item.neg-marked-pending {
  border-left-color: var(--danger) !important;
  background: #fef2f2 !important;
}

/* Yazarken — tüm kart yeşile */
.neg-item.neg-has-replacement,
.neg-item.neg-has-replacement.priority-yuksek {
  background: #ecfdf5 !important;
  border-left-color: #22c55e !important;
}

.neg-has-replacement .neg-inline-form {
  background: #dcfce7;
  border-top-color: #86efac;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.65rem;
}

.neg-has-replacement .neg-badge {
  background: #bbf7d0;
  color: #15803d;
}

/* Kaydedildi — komple yeşil */
.neg-item.neg-saved-complete,
.neg-item.neg-saved-complete.priority-yuksek,
.neg-item.neg-custom.neg-saved-complete {
  background: #dcfce7 !important;
  border-left-color: #16a34a !important;
  border-left-width: 4px;
}

.neg-inline-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.neg-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--danger);
  background: #fee2e2;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.neg-inline-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.neg-term-struck {
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 2px;
  opacity: 0.65;
}

.neg-repl-input.neg-input-ok {
  border-color: var(--success);
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}

.neg-has-replacement .neg-inline-hint {
  color: var(--success);
}

.neg-has-replacement .neg-inline-hint::before {
  content: "✓ ";
}

.neg-inline-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.neg-saved-complete {
  background: #dcfce7 !important;
  border-left-color: var(--success) !important;
  transition: background 0.35s ease, border-color 0.35s ease;
}

/* duplicate block removed — see .neg-item.neg-saved-complete above */

.neg-saved-complete .neg-inline-form,
.neg-form-saved {
  background: #bbf7d0 !important;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.5rem;
  border: 1px solid #86efac;
}

.neg-term-new {
  color: #15803d;
  font-size: 1rem;
}

.neg-old-term {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.82rem;
}

.neg-input-locked {
  cursor: default;
  pointer-events: none;
  font-weight: 800 !important;
}

.neg-badge-ok {
  background: #bbf7d0 !important;
  color: #15803d !important;
}

.neg-saved-flash {
  animation: negSaved 0.4s ease;
}

@keyframes negSaved {
  from { background: #dcfce7; }
  to { background: #fef2f2; }
}

.neg-inline-row {
  display: flex;
  gap: 0.4rem;
}

.neg-repl-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #14532d;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

/* Enter / onay — kutucuk kaybolur, yeşil alanla bütünleşir; tıklanınca düzenlenebilir */
.neg-input-confirmed {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  font-weight: 800 !important;
  font-size: 0.95rem;
  color: #14532d !important;
  padding: 0.35rem 0 !important;
  cursor: text;
  pointer-events: auto;
}

.neg-input-editing {
  border: 2px solid #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2) !important;
  background: #fff !important;
  font-weight: 800 !important;
  padding: 0.55rem 0.75rem !important;
  pointer-events: auto;
}

.neg-edit-btn {
  display: inline-block;
  margin-top: 0.45rem;
  border: none;
  background: transparent;
  color: #15803d;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.neg-edit-btn:hover {
  color: #166534;
}

.neg-edit-btn.hidden {
  display: none;
}

.neg-form-merged {
  border-top: none !important;
  padding-top: 0.5rem !important;
}

.neg-form-merged .neg-inline-label {
  color: #15803d;
  font-weight: 600;
}

.neg-hint-confirmed {
  color: #15803d !important;
  font-weight: 600;
}

.neg-hint-confirmed::before {
  content: "✓ ";
}

/* ── Admin müşteri paneli görünümü ── */
.admin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  font-size: 0.82rem;
  position: sticky;
  top: 0;
  z-index: 300;
}

.admin-banner code {
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.65);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

body:has(.admin-banner:not(.hidden)) .app-shell {
  min-height: calc(100dvh - 44px);
}
