/* GABİM Kontrol — yerel UI */
:root {
  --bg: #fafbfc;
  --panel: #ffffff;
  --border: #e6e8eb;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #15803d;
  --primary-hover: #166534;
  --primary-bg: #f0fdf4;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --code-bg: #f3f4f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh; overflow: hidden;
}

body { display: flex; }

/* ─── sidebar ─── */
.sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 4px 18px; }
.logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--primary); color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
}
.brand-title { font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--muted); font-size: 12px; }

nav { display: flex; flex-direction: column; gap: 2px; }
.nav {
  text-align: left; padding: 8px 12px;
  background: transparent; border: none;
  border-radius: 6px; cursor: pointer;
  color: var(--text); font-size: 13px;
}
.nav:hover { background: var(--bg); }
.nav.active { background: var(--primary-bg); color: var(--primary); font-weight: 500; }

.sidefoot {
  margin-top: auto; font-size: 11px; color: var(--muted);
  padding: 8px 4px; border-top: 1px solid var(--border);
}

/* ─── main ─── */
main {
  flex: 1; overflow: auto;
  padding: 28px 36px;
}
.view { display: none; }
.view.active { display: block; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }

/* ─── dropzone ─── */
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  background: var(--panel);
  padding: 56px 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.dz-icon { font-size: 36px; color: var(--muted); margin-bottom: 12px; }
.dz-title { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.dz-sub { color: var(--muted); font-size: 13px; }
.link {
  background: none; border: none; padding: 0;
  color: var(--primary); cursor: pointer;
  font-size: inherit; text-decoration: underline;
}

/* ─── progress ─── */
.progress { margin-top: 24px; }
.progress.hidden, .result.hidden { display: none; }
.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.fill {
  height: 100%; background: var(--primary);
  width: 0%; transition: width 0.2s;
}
.ptext { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* ─── result ─── */
.result {
  margin-top: 24px;
  display: flex; flex-direction: column; gap: 16px;
}

.summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
}
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat .value { font-size: 22px; font-weight: 600; }
.stat.ok .value { color: var(--primary); }
.stat.fix .value { color: #2563eb; }
.stat.err .value { color: var(--error); }
.stat.warn .value { color: var(--warn); }

.actions { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 6px;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  background: var(--primary); color: white;
}
.btn:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--panel); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--muted);
}

/* ─── tablolar ─── */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card.errors h3 { color: var(--error); }
.card.warns h3 { color: var(--warn); }
.card.fixes h3 { color: #2563eb; }

.kv { display: flex; flex-direction: column; gap: 4px; }
.kv .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-radius: 4px;
  font-size: 13px;
}
.kv .row:hover { background: var(--bg); }
.kv .k { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 600; }

.empty { color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }

.warning-banner {
  background: var(--warn-bg); border: 1px solid #fde68a;
  border-radius: 6px; padding: 10px 14px;
  font-size: 13px; color: #78350f;
}
.info-banner {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 10px 14px;
  font-size: 13px; color: #1e3a8a; line-height: 1.55;
}
.info-banner code {
  background: #dbeafe; padding: 1px 6px; border-radius: 3px;
  font-size: 12px;
}

/* Tıklanabilir kategoriler */
.kv .row.clickable { cursor: pointer; }
.kv .row.clickable:hover { background: var(--primary-bg); }

/* Detay frame */
.details-frame {
  margin-top: 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
}
.details-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.details-header h3 {
  margin: 0 0 10px; font-size: 13px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.filter-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.chip-group { display: flex; gap: 0; }
.chip {
  background: var(--panel); border: 1px solid var(--border);
  padding: 5px 12px; cursor: pointer; font-size: 12px;
  color: var(--text);
}
.chip-group .chip:first-child { border-radius: 6px 0 0 6px; }
.chip-group .chip:last-child { border-radius: 0 6px 6px 0; }
.chip-group .chip + .chip { border-left: none; }
.chip:hover { background: var(--bg); }
.chip.active {
  background: var(--primary); color: white; border-color: var(--primary);
}
.chip.clear { border-radius: 6px; color: var(--muted); }
.chip.clear:hover { background: var(--error-bg); color: var(--error); border-color: #fecaca; }
#detailSearch {
  flex: 1; min-width: 200px; max-width: 360px;
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px;
}
#detailSearch:focus { outline: none; border-color: var(--primary); }
.filter-status {
  margin-top: 8px; font-size: 12px; color: var(--muted);
}
.filter-status code {
  background: var(--code-bg); padding: 1px 6px; border-radius: 3px;
  font-size: 11px;
}

/* Detay tablosu */
.details-body { max-height: 480px; overflow: auto; }
.detail-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.detail-table thead th {
  position: sticky; top: 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 8px 12px; text-align: left;
  font-weight: 600; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.detail-table td {
  padding: 8px 12px; border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}
.detail-table tr:hover td { background: var(--bg); }
.detail-table .muted { color: var(--muted); font-size: 11px; }
.detail-table code {
  background: var(--code-bg); padding: 1px 6px; border-radius: 3px;
  font-family: ui-monospace, "SF Mono", monospace; font-size: 11px;
}
.detail-table code.old { background: #fef2f2; color: #991b1b; }
.detail-table code.new { background: #ecfdf5; color: #166534; }

.row-error td:first-child { border-left: 3px solid var(--error); padding-left: 9px; }
.row-warning td:first-child { border-left: 3px solid var(--warn); padding-left: 9px; }
.row-fix td:first-child { border-left: 3px solid #2563eb; padding-left: 9px; }

.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 10px; font-size: 10px; font-weight: 600;
  font-family: ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.02em;
}
.badge.err { background: var(--error-bg); color: var(--error); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.fix { background: #dbeafe; color: #1e40af; }

/* ─── ÖNİZLEME MODAL'I ─── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: 10px;
  width: 100%; max-width: 1700px;
  height: 100%; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.modal-header h2 {
  margin: 0; font-size: 16px; font-weight: 600;
}
.modal-controls {
  display: flex; gap: 8px; align-items: center;
}
.modal-controls .chip { font-size: 12px; padding: 6px 12px; }
.modal-controls .chip:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.modal-info {
  padding: 8px 20px;
  font-size: 12px; color: var(--muted);
  background: #fefce8; border-bottom: 1px solid #fef08a;
  line-height: 1.5;
}
.modal-body {
  flex: 1; overflow: auto;
  background: white;
}

/* Spreadsheet-tarzı tablo */
.preview-table {
  border-collapse: separate; border-spacing: 0;
  font-size: 11px;
  font-family: -apple-system, sans-serif;
  white-space: nowrap;
}
.preview-table thead th {
  position: sticky; top: 0;
  background: #f3f4f6;
  border-right: 1px solid #d1d5db;
  border-bottom: 2px solid #9ca3af;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600; font-size: 10.5px;
  color: var(--text);
  z-index: 10;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.preview-table thead th.first-col {
  position: sticky; left: 0; z-index: 20;
  background: #e5e7eb;
}
.preview-table thead th.errors-col {
  background: #fef2f2; color: #991b1b;
  min-width: 220px;
}
.preview-table thead th.row-num {
  position: sticky; left: 0; z-index: 30;
  background: #d1d5db;
  width: 50px; min-width: 50px;
  text-align: center;
}
.preview-table tbody td {
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #f3f4f6;
  padding: 4px 8px;
  max-width: 180px;
  overflow: hidden; text-overflow: ellipsis;
}
.preview-table tbody td.first-col {
  position: sticky; left: 50px;
  background: #fafbfc;
  font-weight: 500;
}
.preview-table tbody td.row-num {
  position: sticky; left: 0;
  background: #f3f4f6;
  text-align: center; color: var(--muted); font-size: 10px;
  width: 50px; min-width: 50px;
}
.preview-table tbody td.cell-yellow {
  background: #fef08a !important;
  font-weight: 500;
}
.preview-table tbody td.cell-errors {
  background: #fef2f2;
  color: #991b1b;
  font-size: 10.5px;
  white-space: normal;
  min-width: 220px;
}
.preview-table tbody tr:hover td {
  background: #f0f9ff;
}
.preview-table tbody tr:hover td.cell-yellow {
  background: #fde047 !important;
}
.preview-table tbody tr:hover td.first-col {
  background: #e0f2fe;
}

/* ─── KURALLAR ─── */
.rules-summary { margin-bottom: 14px; }

.rules-filter {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 0; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.rules-filter #ruleSearch {
  flex: 1; min-width: 200px; max-width: 360px;
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px;
}
.rules-filter #ruleSearch:focus { outline: none; border-color: var(--primary); }
.check-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.chip-count {
  margin-left: 4px; opacity: 0.7;
  font-size: 10px;
}

.rules-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 10px;
}
.rule-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.rule-card.rule-disabled {
  opacity: 0.55; background: #f9fafb;
}

.rule-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.rule-icon { font-size: 18px; }
.rule-id {
  background: var(--code-bg); padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-family: ui-monospace, "SF Mono", monospace;
  color: var(--muted);
}

.rule-body { font-size: 13px; line-height: 1.5; }
.rule-field { font-size: 14px; color: var(--text); }
.rule-desc { color: var(--muted); margin-top: 2px; }
.rule-ptype {
  margin-top: 4px; font-size: 12px;
  background: #eff6ff; color: #1e40af;
  padding: 3px 8px; border-radius: 4px;
  display: inline-block;
}
.rule-ptype b { font-weight: 600; }

.rule-params {
  margin-top: 6px; font-family: ui-monospace, monospace; font-size: 11px;
  color: #6b7280;
}
.rule-params b { color: var(--text); font-weight: 600; }
.rule-source {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  border-top: 1px dashed var(--border); padding-top: 6px;
}
.rule-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  border-top: 1px solid var(--border); padding-top: 8px;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
  margin-left: auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: #d1d5db;
  transition: 0.2s; border-radius: 10px;
}
.slider::before {
  position: absolute; content: "";
  height: 14px; width: 14px;
  left: 3px; top: 3px;
  background-color: white;
  transition: 0.2s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider::before { transform: translateX(16px); }

/* Form (Kural Düzenleme Modal'ı) */
.form-row { margin-bottom: 12px; }
.form-row label {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 4px; font-weight: 500;
}
.form-row input[type=text],
.form-row input[type=number],
.form-row select,
.form-row textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-help {
  background: #f9fafb; border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px;
  font-size: 11px; color: var(--muted); line-height: 1.6;
  margin-top: 8px;
}
.form-help code {
  background: #e5e7eb; padding: 1px 5px; border-radius: 3px;
  font-size: 10.5px;
}
.form-sub {
  font-size: 11px; color: var(--muted); font-weight: normal;
  margin-left: 6px;
}
.form-row .form-sub {
  display: block; margin-top: 4px; margin-left: 0;
}

/* Param grid (min/max yan yana) */
.param-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 8px;
}
.param-grid label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px;
}
.param-grid input, .param-grid select {
  width: 100%; padding: 7px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
}
.param-grid input:focus, .param-grid select:focus {
  outline: none; border-color: var(--primary);
}

.params-section .form-help { margin-top: 10px; }

/* ─── history ─── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: 12px; align-items: center;
  cursor: pointer; transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--primary); }
.history-item .fname { font-weight: 500; font-size: 13px; }
.history-item .meta { color: var(--muted); font-size: 12px; }
.history-item .pill {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 500;
}
.pill.ok { background: var(--primary-bg); color: var(--primary); }
.pill.err { background: var(--error-bg); color: var(--error); }

.about-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 22px 28px;
  max-width: 720px; line-height: 1.6;
}
.about-card ul { margin: 6px 0 14px; padding-left: 22px; }
.about-card b { color: var(--text); }

/* ─── detay listesi (gerekirse expand) ─── */
.details-toggle {
  background: none; border: none; color: var(--primary);
  cursor: pointer; padding: 8px 0;
  font-size: 13px; text-decoration: underline;
}
.details-pane {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; max-height: 320px; overflow: auto;
  font-family: ui-monospace, "SF Mono", monospace; font-size: 12px;
}
.details-pane table { width: 100%; border-collapse: collapse; }
.details-pane th, .details-pane td {
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  text-align: left;
}
.details-pane th {
  position: sticky; top: 0;
  background: var(--bg); font-weight: 600;
}
.details-pane tr.row-error td:first-child { color: var(--error); }
.details-pane tr.row-warn td:first-child { color: var(--warn); }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 1fr 1fr; gap: 6px; }
}
