/* === Design system === */
:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

/* === Reset & base === */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0f0f0f;
  color: #e0e0e0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #141414;
  border-bottom: 1px solid #2a2a2a;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  color: #7eb8f7;
  line-height: 1;
}

.title {
  font-weight: 600;
  color: #fff;
  font-size: 1.05rem;
  letter-spacing: -0.005em;
}

.user-email {
  font-size: 0.9rem;
  color: #aaa;
  font-family: var(--font-sans);
}
.tier-badge {
  background: #2a2a2a;
  color: #aaa;
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-sans);
}

.tier-badge[data-tier="pro"]   { background: #2a3a4a; color: #a0c0e0; }
.tier-badge[data-tier="unlimited"] { background: #4a3a2a; color: #e0c0a0; }

.actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  margin-right: 1rem;
}

.auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-msg, .auth-section { display: flex; align-items: center; gap: 0.5rem; }

.user-email {
  color: #aaa;
  font-size: 0.85rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #1f1f1f;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.btn:hover:not(:disabled) {
  background: #2a2a2a;
  border-color: #444;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #7eb8f7;
  border-color: #7eb8f7;
  color: #0f0f0f;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: #acd4ff;
  border-color: #acd4ff;
}

.btn-primary-outline {
  background: transparent;
  border-color: #7eb8f7;
  color: #7eb8f7;
}
.btn-primary-outline:hover:not(:disabled) {
  background: rgba(126, 184, 247, 0.1);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #ccc;
}

/* === Engine select (topbar) === */
.engine-select {
  background: #1f1f1f;
  border: 1px solid #333;
  color: #ccc;
  padding: 0.45rem 0.8rem;
  border-radius: 4px;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%23999' d='M3 4l3 4 3-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  padding-right: 1.85rem;
}
.engine-select:hover:not(:disabled) { border-color: #555; color: #fff; }
.engine-select:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost:hover:not(:disabled) {
  color: #fff;
  background: #1f1f1f;
}

.btn-small {
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

.btn-link {
  background: transparent;
  border: none;
  color: #7eb8f7;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 0;
  cursor: pointer;
}
.btn-link:hover { color: #acd4ff; }
.logs-actions { display: flex; align-items: center; gap: 1rem; }

/* === Workspace (editor + pdf) === */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: #2a2a2a;
  overflow: hidden;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: #0f0f0f;
  min-width: 0;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: #181818;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.92rem;
  color: #ccc;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
}

.panel-meta {
  font-size: 0.82rem;
  color: #777;
  font-family: var(--font-sans);
}

/* === Editor === */
.editor-host {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* === PDF viewer === */
.pdf-host {
  flex: 1;
  overflow: auto;
  background: #1a1a1a;
  position: relative;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #555;
  gap: 0.5rem;
  text-align: center;
  padding: 2rem;
}
.placeholder p { margin: 0; font-size: 0.9rem; }

.pdf-page-wrapper {
  position: relative;
  margin: 1rem auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.pdf-page-wrapper .pdf-canvas {
  display: block;
  margin: 0;
  box-shadow: none;
  max-width: 100%;
}
.pdf-canvas {
  display: block;
  margin: 1rem auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  max-width: 100%;
}

/* PDF arama highlight overlay (canvas üstüne absolute rectangle'lar) */
.pdf-hit-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.pdf-hit-overlay .pdf-hit {
  position: absolute;
  background-color: rgba(255, 230, 0, 0.45);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 200, 0, 0.4);
  transition: background-color 0.15s, box-shadow 0.15s;
}
.pdf-hit-overlay .pdf-hit.pdf-hit-active {
  background-color: rgba(255, 140, 0, 0.7);
  box-shadow: 0 0 0 2px #ff8c00;
}

/* === PDF toolbar === */
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  margin-left: auto;
  margin-right: 0.6rem;
}
.pdf-btn {
  background: transparent;
  border: 1px solid #2a2a2a;
  color: #ccc;
  padding: 0;
  border-radius: 3px;
  cursor: pointer;
  min-width: 2.1rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
}
.pdf-btn:hover:not(:disabled) { background: #2a2a2a; color: #fff; }
.pdf-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pdf-zoom-badge {
  min-width: 3.4rem;
  text-align: center;
  color: #aaa;
}
.pdf-sep {
  width: 1px;
  height: 1.3rem;
  background: #2a2a2a;
  margin: 0 0.35rem;
}
.pdf-page-input {
  width: 3.4rem;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #ccc;
  padding: 0.25rem 0.4rem;
  text-align: center;
  font-family: inherit;
  font-size: inherit;
  border-radius: 3px;
  appearance: textfield;
  -moz-appearance: textfield;
  height: 2rem;
  box-sizing: border-box;
}
.pdf-page-input::-webkit-inner-spin-button,
.pdf-page-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pdf-page-input:disabled { opacity: 0.4; }
.pdf-page-total { color: #777; }

.pdf-search {
  width: 10rem;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #ccc;
  padding: 0.25rem 0.6rem;
  font-family: inherit;
  font-size: inherit;
  border-radius: 3px;
  height: 2rem;
  box-sizing: border-box;
}
.pdf-search:disabled { opacity: 0.4; }
.pdf-search::placeholder { color: #555; }
.pdf-search::-webkit-search-cancel-button { -webkit-appearance: none; }

/* === Logs === */
.logs {
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  border-top: 1px solid #2a2a2a;
  max-height: 200px;
  flex-shrink: 0;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.8rem;
  background: #181818;
  border-bottom: 1px solid #2a2a2a;
}

.logs-body {
  margin: 0;
  padding: 0.85rem 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #aaa;
  white-space: pre-wrap;
  overflow: auto;
  flex: 1;
  line-height: 1.55;
}

.logs-body .log-error { color: #f0a0a0; }
.logs-body .log-warn  { color: #e0c0a0; }
.logs-body .log-ok    { color: #8fda9d; }
.logs-body .log-info  { color: #a0c0e0; }

/* Tıklanabilir tanı satırı (log parse'tan) */
.logs-body .log-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.3);
  text-underline-offset: 2px;
}
.logs-body .log-clickable:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration-color: currentColor;
}

/* === Responsive === */
@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .topbar {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .title { display: none; }
  .actions { margin-right: 0; }
  .user-email { max-width: 100px; }
}
/* ===== Cok dosyali proje: dosya agaci (styles.css'in SONUNA EKLE) ===== */
.workspace { grid-template-columns: 210px 1fr 1fr; }

.panel-files { background: #0c0c0c; }
.file-actions { display: flex; gap: 0.25rem; }
.icon-btn {
  background: transparent; border: 1px solid #333; color: #ccc;
  width: 22px; height: 22px; border-radius: 4px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
.icon-btn:hover { background: #1f1f1f; color: #fff; border-color: #444; }

.file-tree { list-style: none; margin: 0; padding: 0.4rem; overflow: auto; flex: 1.6 1 0; min-height: 80px; font-size: 0.92rem; }

.outline-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 60px;
  border-top: 1px solid #1c1c1c;
}
.panel-subheader {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #888;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #111;
  flex-shrink: 0;
  font-weight: 600;
}
.outline-list {
  list-style: none;
  margin: 0;
  padding: 0.3rem 0;
  overflow: auto;
  flex: 1;
  font-size: 0.88rem;
  font-family: var(--font-sans);
}
.outline-list li {
  padding: 0.32rem 0.9rem;
  cursor: pointer;
  color: #bbb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outline-list li:hover { background: #1c1c1c; color: #fff; }
.outline-list li.outline-empty { color: #555; cursor: default; }
.outline-list li.outline-empty:hover { background: transparent; color: #555; }
.outline-list li.outline-l1 { padding-left: 1.6rem; color: #aaa; }
.outline-list li.outline-l2 { padding-left: 2.3rem; color: #999; font-size: 0.82rem; }

.modal-select-label {
  display: block;
  margin: 0.6rem 0 0.3rem;
  font-size: 0.82rem;
  color: #aaa;
}
.modal-select {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}
.modal-select:focus { outline: none; border-color: #7eb8f7; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.3rem 0.4rem; border-radius: 4px; cursor: pointer; gap: 0.3rem;
}
.file-item:hover { background: #161616; }
.file-item.active { background: #1d2733; }
.file-name {
  display: flex; align-items: center; gap: 0.5rem; min-width: 0; flex: 1;
  font-size: 0.92rem; color: #ddd; font-family: var(--font-mono);
}
.file-icon { font-size: 0.95rem; flex-shrink: 0; }
.file-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-badge {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em;
  background: #4a3a2a; color: #e0c0a0; padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
  font-weight: 600;
}
.file-row-actions { display: none; gap: 0.1rem; flex-shrink: 0; }
.file-item:hover .file-row-actions { display: flex; }
.row-btn {
  background: transparent; border: none; color: #888; font-size: 0.8rem;
  padding: 0.1rem 0.2rem; border-radius: 3px; line-height: 1;
}
.row-btn:hover { color: #fff; background: #2a2a2a; }

.binary-preview {
  flex: 1; overflow: auto; background: #1a1a1a;
  align-items: flex-start; justify-content: center; padding: 1rem;
}
.binary-preview img { max-width: 100%; height: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }

@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr 1fr; }
}
/* ===== Boyutlandirilabilir paneller + surukle-birak  (styles.css'in SONUNA EKLE) =====
   Bu blok, daha onceki grid yerlesimini flex'e cevirir; ayraclar JS ile suruklenir. */
body { display: flex; flex-direction: column; }

.workspace { display: flex; flex-direction: row; flex: 1 1 0; min-height: 0; }
.panel-files { width: var(--w-files, 210px); flex: 0 0 auto; min-width: 0; position: relative; }
.panel-editor { flex: var(--f-editor, 1) 1 0; min-width: 0; }
.panel-pdf { flex: var(--f-pdf, 1) 1 0; min-width: 0; }

.gutter-v, .gutter-h { background: #222; transition: background 0.12s; }
.gutter-v { flex: 0 0 5px; cursor: col-resize; }
.gutter-h { flex: 0 0 5px; cursor: row-resize; }
.gutter-v:hover, .gutter-h:hover { background: #3a5570; }

.logs { height: var(--h-logs, 180px); max-height: none; flex: 0 0 auto; }

body.resizing { user-select: none; cursor: grabbing; }
body.resizing .editor-host, body.resizing .pdf-host { pointer-events: none; }

.panel-files.drag-over { outline: 2px dashed #7eb8f7; outline-offset: -4px; background: #11202e; }
.drop-hint { padding: 0.4rem 0.6rem; font-size: 0.7rem; color: #555; border-top: 1px solid #1c1c1c; }

@media (max-width: 800px) {
  .workspace { flex-direction: column; }
  .panel-files { width: auto; height: 130px; }
  .gutter-v { display: none; }
}
/* ===== Projelerim (dashboard) ===== */
.dashboard {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 2.5rem clamp(1.5rem, 5vw, 4rem) 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  font-family: var(--font-sans);
}
.dash-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #1f1f1f;
}
.dash-title {
  font-size: 1.85rem; margin: 0; font-weight: 700;
  letter-spacing: -0.02em; color: #fff;
}
.dash-status { color: #888; font-size: 0.88rem; margin: 0; min-height: 1em; }
.dash-signed-out { color: #aaa; padding: 1.1rem; border: 1px dashed #333; border-radius: 8px; font-size: 0.9rem; }
.dash-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem;
}
.dash-card {
  display: flex; align-items: stretch;
  border: 1px solid #2a2a2a; border-radius: 8px; background: #161616;
  overflow: hidden; transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.dash-card:hover { border-color: #3a5570; background: #1a1f25; transform: translateY(-1px); }
.dash-card-main { flex: 1 1 auto; padding: 1rem 1.15rem; cursor: pointer; min-width: 0; }
.dash-card-name {
  font-weight: 600; font-size: 0.98rem;
  margin-bottom: 0.3rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff;
}
.dash-card-meta { font-size: 0.8rem; color: #888; }
.dash-card-del {
  background: transparent; border: none; color: #777; cursor: pointer;
  padding: 0 1rem; font-size: 1.05rem;
}
.dash-card-del:hover { color: #e06666; background: #2a1a1a; }
/* ===== Ozel modal (prompt/confirm yerine)  (styles.css'in SONUNA EKLE) ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: none; align-items: center; justify-content: center;
}
.modal-box {
  background: #1b1b1d; border: 1px solid #333; border-radius: 12px;
  padding: 1.3rem 1.4rem; width: min(420px, 90vw);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.modal-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.5rem; }
.modal-message { color: #ccc; margin-bottom: 0.9rem; line-height: 1.45; }
.modal-input {
  width: 100%; box-sizing: border-box; padding: 0.55rem 0.7rem;
  background: #111; border: 1px solid #3a3a3a; border-radius: 7px;
  color: #eee; font-size: 0.95rem; margin-bottom: 1rem;
}
.modal-input:focus { outline: none; border-color: #3a5570; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.btn-danger { background: #c0392b !important; border-color: #c0392b !important; color: #fff !important; }
