/* ==========================================================
   VSF Deploy — "Indigo Aurora" theme
   Inspired by the reference artwork: a deep indigo → warm
   mauve gradient canvas, flowing layered waves with hairline
   white edges on the left, a halftone dot field top-right,
   and frosted-glass panels floating above it.
   Self-contained: system fonts, inline SVG backgrounds.
   ========================================================== */
:root {
  --text: #efecf4;
  --muted: #b1abc4;
  --glass: rgba(21, 22, 47, .62);
  --glass-strong: rgba(18, 19, 42, .78);
  --glass-line: rgba(255, 255, 255, .13);
  --glass-line-strong: rgba(255, 255, 255, .22);
  --field: rgba(8, 9, 26, .45);
  --primary: #7c82f4;             /* periwinkle */
  --primary-2: #989df8;
  --primary-deep: #5d63e2;
  --danger: #f2929b;
  --warn: #edc476;
  --ok: #85d8a8;
  --shadow-card: 0 1px 0 rgba(255,255,255,.06) inset, 0 14px 38px rgba(8, 9, 26, .45);
  --shadow-pop: 0 1px 0 rgba(255,255,255,.08) inset, 0 24px 70px rgba(8, 9, 26, .6);
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  /* brand rails */
  --brand-tm: #f5975c;
  --brand-bm: #6cc4ec;
  --brand-waf: #b09df2;
  --brand-tmae: #e5c25e;
  --brand-trade: #a5b2c6;
  --brand-splendour: #ef92ad;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* ---------- the canvas: gradient + waves + halftone ---------- */
body {
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100vh;
  background:
    linear-gradient(118deg, #1f2044 0%, #2c2a55 34%, #4c3f5c 62%, #7b6567 84%, #947d73 100%);
  background-attachment: fixed;
  position: relative;
}
/* flowing waves — left side, hairline white edges */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 900' preserveAspectRatio='xMinYMid slice'><path d='M-50,-20 C480,140 160,400 350,560 C500,690 320,830 420,930 L-50,930 Z' fill='%23262657' fill-opacity='0.55' stroke='%23ffffff' stroke-opacity='0.28' stroke-width='1.4'/><path d='M-50,-20 C340,170 120,420 270,580 C390,710 240,850 310,930 L-50,930 Z' fill='%231d1d47' fill-opacity='0.7' stroke='%23ffffff' stroke-opacity='0.36' stroke-width='1.4'/><path d='M-50,-20 C200,200 60,440 170,600 C260,730 150,860 200,930 L-50,930 Z' fill='%23151538' fill-opacity='0.85' stroke='%23ffffff' stroke-opacity='0.45' stroke-width='1.4'/></svg>");
  background-size: cover;
  background-position: left center;
}
/* halftone dot field — fading in from the top-right corner */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,.55) 1.4px, transparent 1.6px);
  background-size: 19px 19px;
  -webkit-mask-image: radial-gradient(560px 380px at 96% 4%, rgba(0,0,0,.8), transparent 70%);
          mask-image: radial-gradient(560px 380px at 96% 4%, rgba(0,0,0,.8), transparent 70%);
}
#app-view, #login-view, .modal-backdrop, .toast { position: relative; z-index: 1; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
code { font-family: var(--mono); background: rgba(8,9,26,.5); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--glass-line); }

/* ---------- buttons ---------- */
.btn {
  font: inherit; cursor: pointer; border-radius: 9px;
  border: 1px solid var(--glass-line-strong);
  background: rgba(255,255,255,.07); color: var(--text);
  padding: 8px 14px; font-weight: 500;
  backdrop-filter: blur(6px);
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.32); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary-deep));
  border-color: rgba(255,255,255,.28); color: #fff; font-weight: 650;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px rgba(93,99,226,.4);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.danger { background: rgba(242,146,155,.1); border-color: rgba(242,146,155,.5); color: var(--danger); }
.btn.danger:hover { background: rgba(242,146,155,.2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); backdrop-filter: none; }
.btn.ghost:hover { background: rgba(255,255,255,.09); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 380px; background: var(--glass-strong); border: 1px solid var(--glass-line-strong);
  border-radius: 18px; box-shadow: var(--shadow-pop);
  backdrop-filter: blur(20px);
  padding: 34px; display: flex; flex-direction: column; gap: 14px;
}
.login-mark { font-family: var(--mono); letter-spacing: .24em; color: var(--primary-2); font-size: 12.5px; font-weight: 700; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--glass-line); border-radius: 9px; padding: 8px 10px;
}
input::placeholder { color: #8781a0; }
select option { background: #1d1e42; color: var(--text); }
textarea { font-family: var(--mono); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; white-space: pre-wrap; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 26px;
  padding: 10px 22px;
  background: rgba(14, 15, 36, .55);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-line);
  position: sticky; top: 0; z-index: 20;
}
.brandmark { font-family: var(--mono); letter-spacing: .12em; color: var(--primary-2); display: flex; align-items: center; gap: 8px; }
.brandmark strong { color: #fff; font-weight: 700; }
.env-tag { font-size: 11px; background: rgba(124,130,244,.18); color: var(--primary-2); border: 1px solid rgba(124,130,244,.45); border-radius: 5px; padding: 1px 7px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.navlink { background: none; border: none; color: var(--muted); font: inherit; font-weight: 500; padding: 7px 13px; border-radius: 8px; cursor: pointer; }
.navlink:hover { color: #fff; background: rgba(255,255,255,.08); }
.navlink.active { color: #fff; background: linear-gradient(180deg, var(--primary-2), var(--primary-deep)); font-weight: 650; box-shadow: 0 4px 14px rgba(93,99,226,.4); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------- pages ---------- */
.page { padding: 26px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; text-shadow: 0 2px 10px rgba(8,9,26,.4); }
.page-head-actions { display: flex; gap: 10px; }

/* ---------- site cards (frosted glass) ---------- */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 20px; }
@media (max-width: 520px) { .sites-grid { grid-template-columns: 1fr; } .page { padding: 14px; } }

.site-card {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  padding: 18px 18px 16px 22px; position: relative; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.site-card:hover { border-color: var(--glass-line-strong); box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 20px 50px rgba(8,9,26,.55); }
.site-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--rail, var(--primary)), color-mix(in srgb, var(--rail, var(--primary)) 45%, transparent));
}
.site-card.busy { border-color: rgba(237,196,118,.5); }

.site-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.site-name { font-size: 16px; font-weight: 700; margin: 0 0 2px; letter-spacing: -.01em; }
.site-url a { color: var(--muted); text-decoration: none; font-size: 12.5px; font-family: var(--mono); }
.site-url a:hover { color: var(--primary-2); }
.brand-chip {
  font-size: 10.5px; font-family: var(--mono); letter-spacing: .07em; font-weight: 700;
  color: var(--rail);
  background: rgba(8,9,26,.35);
  border: 1px solid color-mix(in srgb, var(--rail) 55%, transparent);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}

.site-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; margin: 13px 0; font-size: 12.8px; }
.site-meta .k { color: var(--muted); }
.site-meta .v { font-family: var(--mono); }
.site-meta .v.wrap { word-break: break-all; }

.proc-row { display: flex; gap: 8px; margin-bottom: 13px; flex-wrap: wrap; }
.proc {
  font-family: var(--mono); font-size: 12px; border: 1px solid var(--glass-line);
  border-radius: 7px; padding: 3px 9px; display: flex; align-items: center; gap: 7px;
  background: rgba(8,9,26,.35);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #7d7996; flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(133,216,168,.2), 0 0 8px rgba(133,216,168,.7); }
.dot.stopped, .dot.errored { background: var(--danger); box-shadow: 0 0 0 3px rgba(242,146,155,.18); }
.dot.unknown { background: #7d7996; }

.branch-row { display: flex; gap: 8px; align-items: center; margin-bottom: 13px; }

/* ---------- searchable branch combobox ---------- */
.combo { position: relative; flex: 1; min-width: 0; }
.combo input { width: 100%; font-family: var(--mono); font-size: 13px; }
.combo-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  max-height: 264px; overflow: auto;
  background: rgba(18, 19, 42, .96);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-line-strong); border-radius: 11px;
  box-shadow: var(--shadow-pop);
  padding: 5px;
}
.combo-item {
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  font-family: var(--mono); font-size: 12.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.combo-item:hover { background: rgba(124,130,244,.22); }
.combo-item.current { color: var(--primary-2); }
.combo-tag {
  font-size: 10px; letter-spacing: .05em; color: var(--ok);
  border: 1px solid rgba(133,216,168,.45); border-radius: 999px; padding: 1px 7px;
}
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 12.5px; }

.site-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.site-actions .btn.deploy { flex: 1; min-width: 130px; }

.magento-row { display: flex; gap: 8px; margin: 0 0 10px; }
.magento-row input { flex: 1; font-family: var(--mono); font-size: 12.5px; min-width: 0; }

.busy-banner {
  margin-bottom: 12px; font-size: 12.5px; color: var(--warn);
  background: rgba(237,196,118,.1); border: 1px solid rgba(237,196,118,.4);
  border-radius: 8px; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.busy-banner button { flex: none; }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 9, 26, .6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal {
  background: var(--glass-strong); border: 1px solid var(--glass-line-strong); border-radius: 18px;
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(22px);
  padding: 24px; width: 540px; max-width: 100%; max-height: 92vh; overflow: auto;
}
.modal-wide { width: 980px; }
.modal-sm { width: 430px; }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.dlg-icon {
  width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; margin-bottom: 12px;
  background: rgba(124,130,244,.18); color: var(--primary-2); border: 1px solid rgba(124,130,244,.4);
}
.dlg-icon.danger { background: rgba(242,146,155,.14); color: var(--danger); border-color: rgba(242,146,155,.45); }
.dlg-msg { color: var(--muted); margin: 4px 0 0; }
.dlg-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 10px; }

.pipeline-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.pipeline-choice {
  border: 1px solid var(--glass-line); border-radius: 12px; padding: 12px 14px; cursor: pointer;
  background: rgba(8,9,26,.3);
  transition: border-color .12s, background .12s;
}
.pipeline-choice:hover { border-color: var(--glass-line-strong); background: rgba(255,255,255,.05); }
.pipeline-choice.selected { border-color: var(--primary); background: rgba(124,130,244,.14); box-shadow: 0 0 0 1px var(--primary) inset; }
.pipeline-choice .pc-title { font-weight: 700; margin-bottom: 4px; }
.pipeline-choice .pc-cmds { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; }

/* ---------- log terminal ---------- */
.log-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.log-head h3 { display: inline; margin-right: 10px; }
.log-head-actions { display: flex; gap: 8px; }
.log-output {
  background: rgba(5, 6, 18, .92); border: 1px solid var(--glass-line); border-radius: 12px;
  padding: 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  height: 62vh; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
  color: #d5dcef;
}
.status-pill {
  font-size: 12px; font-family: var(--mono); font-weight: 700;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--glass-line); color: var(--muted);
  background: rgba(8,9,26,.35);
}
.status-pill.running { color: var(--warn); border-color: rgba(237,196,118,.5); }
.status-pill.succeeded { color: var(--ok); border-color: rgba(133,216,168,.5); }
.status-pill.failed, .status-pill.cancelled { color: var(--danger); border-color: rgba(242,146,155,.5); }

/* ---------- tables ---------- */
.table-wrap {
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 14px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  overflow: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  padding: 12px 14px; border-bottom: 1px solid var(--glass-line); background: rgba(8,9,26,.28);
}
.table td { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,.04); }
.table .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.site-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.site-form label.block { margin-bottom: 12px; }

.perm-box {
  border: 1px solid var(--glass-line); border-radius: 12px; padding: 12px 14px; margin: 0 0 14px;
  background: rgba(8,9,26,.25);
}
.perm-box legend { color: var(--muted); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; padding: 0 6px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 14px; margin-top: 6px; }
.perm-grid.indent { margin-left: 22px; }
.perm-item { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-size: 13px !important; color: var(--text) !important; font-weight: 400 !important; cursor: pointer; }
.perm-item input { margin-top: 3px; accent-color: var(--primary); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 90;
  background: var(--glass-strong); color: var(--text);
  border: 1px solid var(--glass-line-strong); border-left: 4px solid var(--primary);
  backdrop-filter: blur(18px);
  border-radius: 12px; padding: 12px 18px; max-width: 420px;
  box-shadow: var(--shadow-pop);
}
.toast.err { border-left-color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .modal { animation: pop .15s ease-out; }
  @keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
  .toast { animation: slidein .18s ease-out; }
  @keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
