/* ============================================================
   Susa Deploy Panel
   Yerleşim susa panelindeki (Velzon) dikey menü desenini izler:
   250px sabit sol menü, 70px'e daralabilen ikon modu, sağda içerik.
   Düz/minimal çizgi: gradient yok, cam efekti yok.
   ============================================================ */

:root {
  color-scheme: light;

  --bg:            #f3f4f7;
  --surface:       #ffffff;
  --surface-sunk:  #f8f9fb;
  --surface-hover: #eff1f5;
  --border:        #e3e6eb;
  --border-strong: #d1d6de;

  --text:          #15181e;
  --text-soft:     #59616e;
  --text-faint:    #8a919f;

  --accent:        #2f6bff;
  --accent-soft:   #ecf1ff;
  --accent-text:   #1d4ed8;

  --ok:            #12894a;
  --ok-soft:       #e6f5ec;
  --danger:        #d33a3a;
  --danger-soft:   #fdecec;
  --warn:          #b26a00;
  --warn-soft:     #fdf3e2;

  --menu-bg:       #ffffff;
  --menu-border:   #e3e6eb;
  --menu-item:     #59616e;
  --menu-hover-bg: #eff1f5;

  --term-bg:       #11141a;
  --term-fg:       #ccd2dc;
  --term-dim:      #6b7480;
  --term-cmd:      #79b0ff;
  --term-ok:       #6cd39a;
  --term-err:      #ff8b8b;
  --term-warn:     #f0c274;

  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;

  --menu-w:       250px;
  --menu-w-sm:    72px;
  --topbar-h:     56px;
  --rail-w:       260px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:            #0d1015;
    --surface:       #151920;
    --surface-sunk:  #1a1f27;
    --surface-hover: #1f242e;
    --border:        #242a34;
    --border-strong: #323945;
    --text:          #e7e9ee;
    --text-soft:     #a0a8b7;
    --text-faint:    #6b7482;
    --accent:        #5b8cff;
    --accent-soft:   #182240;
    --accent-text:   #90b0ff;
    --ok:            #45c07d;
    --ok-soft:       #142d1d;
    --danger:        #ef6b6b;
    --danger-soft:   #31191b;
    --warn:          #d99a3c;
    --warn-soft:     #2c2312;
    --menu-bg:       #151920;
    --menu-border:   #242a34;
    --menu-item:     #a0a8b7;
    --menu-hover-bg: #1f242e;
    --term-bg:       #090c11;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0d1015;
  --surface:       #151920;
  --surface-sunk:  #1a1f27;
  --surface-hover: #1f242e;
  --border:        #242a34;
  --border-strong: #323945;
  --text:          #e7e9ee;
  --text-soft:     #a0a8b7;
  --text-faint:    #6b7482;
  --accent:        #5b8cff;
  --accent-soft:   #182240;
  --accent-text:   #90b0ff;
  --ok:            #45c07d;
  --ok-soft:       #142d1d;
  --danger:        #ef6b6b;
  --danger-soft:   #31191b;
  --warn:          #d99a3c;
  --warn-soft:     #2c2312;
  --menu-bg:       #151920;
  --menu-border:   #242a34;
  --menu-item:     #a0a8b7;
  --menu-hover-bg: #1f242e;
  --term-bg:       #090c11;
}

/* ---------- temel ---------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
button, input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .92em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ============================================================
   Giriş ekranı
   ============================================================ */

body.is-login { display: grid; place-items: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 360px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 24px 24px;
  text-align: center;
}

.login-mark {
  width: 42px; height: 42px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-text);
}
.login-mark svg { width: 22px; height: 22px; }

.login-card h1 { font-size: 19px; letter-spacing: -.01em; }
.login-sub { margin: 8px 0 24px; color: var(--text-soft); font-size: 13px; }

.field { display: block; text-align: left; margin-bottom: 12px; }
.field-label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 500; color: var(--text-soft); }
.field input {
  width: 100%; padding: 10px 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color .12s, background .12s;
}
.field input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.field input::placeholder { color: var(--text-faint); }

.btn-primary {
  width: 100%; padding: 10px 14px;
  border: 0; border-radius: var(--r-md);
  background: var(--accent); color: #fff;
  font-weight: 500; cursor: pointer;
  transition: filter .12s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(.94); }

.alert {
  margin-bottom: 12px; padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: var(--r-md);
  background: var(--danger-soft); color: var(--danger);
  font-size: 13px; text-align: left;
}

.login-foot { margin: 16px 0 0; color: var(--text-faint); font-size: 12px; }

/* ============================================================
   Sol menü
   ============================================================ */

.app-menu {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 30;
  width: var(--menu-w);
  display: flex; flex-direction: column;
  background: var(--menu-bg);
  border-right: 1px solid var(--menu-border);
  transition: width .18s ease;
}
:root[data-sidebar="sm"] .app-menu { width: var(--menu-w-sm); }

.menu-brand {
  flex: none;
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--menu-border);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; text-decoration: none; color: inherit;
}

.brand-mark {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-text);
}
.brand-mark svg { width: 16px; height: 16px; }

.brand-text {
  font-size: 14px; color: var(--text-soft); white-space: nowrap;
}
.brand-text b { color: var(--text); font-weight: 600; }

.menu-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 0; }

.menu-title {
  display: flex; align-items: center;
  margin: 0; padding: 12px 20px 6px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint);
  white-space: nowrap; overflow: hidden;
}
.menu-title i {
  display: none;
  width: 16px; height: 2px; border-radius: 2px;
  background: var(--border-strong);
}
.menu-title:first-child { padding-top: 0; }

.menu-list { list-style: none; margin: 0; padding: 0 10px; }

.menu-item {
  position: relative;
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px;
  border: 0; border-radius: var(--r-md);
  background: transparent;
  color: var(--menu-item);
  text-align: left; text-decoration: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.menu-item:hover:not(:disabled) { background: var(--menu-hover-bg); color: var(--text); }
.menu-item:disabled { opacity: .4; cursor: not-allowed; }
.menu-item.is-running { background: var(--accent-soft); color: var(--accent-text); }

.menu-icon { flex: none; width: 18px; height: 18px; display: grid; place-items: center; }
.menu-icon svg { width: 18px; height: 18px; }

.menu-label {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.menu-flag {
  flex: none;
  width: 15px; height: 15px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--warn-soft); color: var(--warn);
  font-size: 9.5px; font-weight: 700;
}

.menu-foot { flex: none; padding: 10px; border-top: 1px solid var(--menu-border); }

/* ---- daraltılmış menü ---- */

:root[data-sidebar="sm"] .brand-text,
:root[data-sidebar="sm"] .menu-label,
:root[data-sidebar="sm"] .menu-flag,
:root[data-sidebar="sm"] .menu-title span { display: none; }

:root[data-sidebar="sm"] .menu-title { justify-content: center; padding: 14px 0 8px; }
:root[data-sidebar="sm"] .menu-title i { display: block; }

:root[data-sidebar="sm"] .menu-brand { justify-content: center; padding: 0; }

:root[data-sidebar="sm"] .menu-item { justify-content: center; padding: 10px 0; }
:root[data-sidebar="sm"] .menu-list { padding: 0 12px; }

/* daraltılmışken ipucu balonu */
:root[data-sidebar="sm"] .menu-item::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%);
  padding: 5px 9px;
  border-radius: var(--r-sm);
  background: var(--text); color: var(--surface);
  font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .12s;
  z-index: 5;
}
:root[data-sidebar="sm"] .menu-item:hover::after { opacity: 1; }

/* ============================================================
   İçerik
   ============================================================ */

.app-main {
  min-height: 100%;
  height: 100%;
  margin-left: var(--menu-w);
  display: flex; flex-direction: column;
  transition: margin-left .18s ease;
}
:root[data-sidebar="sm"] .app-main { margin-left: var(--menu-w-sm); }

.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.head-spacer { flex: 1; }

.run-head { display: flex; align-items: center; gap: 12px; min-width: 0; }

.run-title {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.run-meta {
  font-size: 12px; color: var(--text-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 500;
  color: var(--text-soft); white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status[data-state="running"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent-text);
}
.status[data-state="running"] .status-dot { animation: pulse 1.1s ease-in-out infinite; }

.status[data-state="success"] {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  color: var(--ok);
}
.status[data-state="failed"],
.status[data-state="timeout"],
.status[data-state="aborted"] {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-soft);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.toggle input { accent-color: var(--accent); margin: 0; }

.btn-ghost {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px; cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

.icon-btn {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-soft);
  cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

.only-mobile { display: none; }
.only-desktop { display: grid; }

/* daraltılmışken düğme ikonu "menü kapalı" hâlini gösterir */
:root[data-sidebar="sm"] #menuPin { color: var(--accent); }

/* ---------- çalışma alanı ---------- */

.work {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
}
:root[data-rail="off"] .work { grid-template-columns: minmax(0, 1fr); }
:root[data-rail="off"] .rail { display: none; }

.console-wrap { min-width: 0; min-height: 0; display: flex; }

.console {
  flex: 1; min-height: 0;
  overflow: auto;
  padding: 16px 0;
  background: var(--term-bg);
  color: var(--term-fg);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.62;
  tab-size: 4;
}

.console-empty {
  margin: 0; padding: 0 20px;
  color: var(--term-dim);
  font-family: var(--font); font-size: 13px;
}

.line { padding: 0 20px; white-space: pre-wrap; word-break: break-word; }
.line.cmd    { color: var(--term-cmd); }
.line.meta   { color: var(--term-dim); }
.line.rule   { color: var(--term-dim); opacity: .45; }
.line.err    { color: var(--term-err); }
.line.warn   { color: var(--term-warn); }
.line.ok     { color: var(--term-ok); }
.line.system { color: var(--term-dim); font-style: italic; }

/* ---------- geçmiş rayı ---------- */

.rail {
  min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.rail-head { flex: none; padding: 14px 16px 8px; }
.rail-head h2 {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint);
}

.history { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0 8px 12px; }

.history .empty { padding: 6px 10px; color: var(--text-faint); font-size: 12px; }

.history li.run {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .12s;
}
.history li.run:hover { background: var(--surface-hover); }
.history li.run.is-active { background: var(--accent-soft); }

.h-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.h-dot.success { background: var(--ok); }
.h-dot.failed, .h-dot.timeout, .h-dot.aborted { background: var(--danger); }
.h-dot.running { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }

.h-body { flex: 1; min-width: 0; }
.h-label {
  display: block; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.h-sub {
  display: block; margin-top: 1px;
  font-size: 11px; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- bildirim ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 9px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .16s, transform .16s;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: var(--danger-soft); color: var(--danger);
}

.menu-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 12, 16, .45);
  z-index: 25;
}

/* ============================================================
   Duyarlılık
   ============================================================ */

@media (max-width: 1100px) {
  :root { --rail-w: 220px; }
}

@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(240px, 1fr) auto; }
  .rail { border-left: 0; border-top: 1px solid var(--border); max-height: 34vh; }
  :root[data-rail="off"] .work { grid-template-rows: 1fr; }
}

@media (max-width: 760px) {
  .only-mobile { display: grid; }
  .only-desktop { display: none; }

  /* menü mobilde üstüne kayar */
  .app-menu { transform: translateX(-100%); width: var(--menu-w); transition: transform .18s ease; }
  :root[data-sidebar="sm"] .app-menu { width: var(--menu-w); }
  body.menu-open .app-menu { transform: translateX(0); }

  .app-main, :root[data-sidebar="sm"] .app-main { margin-left: 0; }

  /* mobilde her zaman geniş menü göster */
  :root[data-sidebar="sm"] .brand-text,
  :root[data-sidebar="sm"] .menu-label,
  :root[data-sidebar="sm"] .menu-flag,
  :root[data-sidebar="sm"] .menu-title span { display: initial; }
  :root[data-sidebar="sm"] .menu-title { justify-content: flex-start; padding: 12px 20px 6px; }
  :root[data-sidebar="sm"] .menu-title i { display: none; }
  :root[data-sidebar="sm"] .menu-item { justify-content: flex-start; padding: 9px 10px; }
  :root[data-sidebar="sm"] .menu-item::after { display: none; }
  :root[data-sidebar="sm"] .menu-brand { justify-content: flex-start; padding: 0 16px; }

  .topbar { padding-left: 8px; gap: 8px; }
  .run-title, .run-meta { display: none; }
  .toggle span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
