/* Cloud deploy styles (extends styles.css) */

.deploy-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  align-items: start;
}

.deploy-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.deploy-panel + .deploy-panel { margin-top: var(--space-lg); }

.deploy-form[data-has-plan="true"] > .deploy-panel:not(.deploy-plan) { display: none; }
.deploy-form[data-has-plan="true"][data-editing="true"] > .deploy-panel:not(.deploy-plan) { display: block; }
.deploy-plan-source {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.deploy-form[data-has-plan="true"] > .deploy-plan-source { display: flex; }
.deploy-form[data-has-plan="true"][data-editing="true"] > .deploy-plan-source { display: none; }
.deploy-plan-source-copy { display: grid; min-width: 0; gap: 5px; }
.deploy-plan-source-copy strong { display: flex; min-width: 0; align-items: center; gap: 8px; overflow-wrap: anywhere; font-size: 14px; }
.deploy-plan-source-copy strong span { min-width: 0; overflow-wrap: anywhere; }
.deploy-plan-source-copy .eyebrow { margin: 0; }
.deploy-repository-label { display: flex; align-items: center; gap: 8px; }
.deploy-source-provider-icon { width: 20px; height: 20px; flex: 0 0 auto; object-fit: contain; }
.deploy-source-provider-icon[hidden] { display: none; }
.deploy-return-to-plan { margin-bottom: var(--space-lg); }

.form-actions { margin-top: var(--space-xl); }

.deploy-fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-xl);
}

.deploy-fieldset legend {
  padding: 0;
  margin-bottom: var(--space-sm);
}

.deploy-legend {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
}

.deploy-hint {
  display: block;
  margin-top: var(--space-xs);
  font-size: 13px;
  color: var(--color-text-muted);
}

.deploy-input {
  width: 100%;
}

.deploy-file { padding: 10px 12px; }

.deploy-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.deploy-source-row { grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr); }

.deploy-row--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- provider and source pickers ---------- */
.deploy-choose {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
}

.deploy-choose input,
.deploy-seg input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.deploy-choose label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.deploy-choose label strong { display: block; color: var(--color-text); font-size: 14px; }
.deploy-choose label small { display: block; margin-top: 4px; color: var(--color-text-muted); font-size: 12px; line-height: 1.45; }

.deploy-choose label:hover { border-color: var(--color-border-hover); }

.deploy-choose-locked {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: var(--space-md);
  border: 1px dashed var(--color-border-hover);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-muted);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}

.deploy-choose-locked:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.deploy-choose-locked .deploy-choose-icon { background: var(--color-bg-hover); }
.deploy-choose-copy { display: flex; flex-direction: column; gap: 4px; }
.deploy-choose-copy strong { color: var(--color-text); font-size: 15px; }
.deploy-choose-copy small { color: var(--color-primary); font-size: 13px; font-weight: 600; }
.deploy-unlock-flag { margin: 16px 0; }
.deploy-unlock-flag code { padding: 5px 8px; border-radius: var(--radius-sm); background: var(--color-bg-hover); font-family: var(--font-mono); }

.deploy-choose input:checked + label {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.deploy-choose input:focus-visible + label { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.deploy-choose-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.deploy-choose input:checked + label .deploy-choose-icon {
  background: var(--color-primary);
  color: #fff;
}

.deploy-choose-icon svg { width: 18px; height: 18px; }

.deploy-choose-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.deploy-choose input:checked + label .deploy-choose-icon img { filter: brightness(0) invert(1); }

.deploy-choose strong { display: block; font-size: 15px; }

.deploy-choose small {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.deploy-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--color-bg-hover);
  border-radius: var(--radius-md);
}

.deploy-seg label {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.deploy-seg label:hover { color: var(--color-text); }

.deploy-seg input:checked + label {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.deploy-seg input:focus-visible + label { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---------- conditional sections ---------- */
.deploy-form[data-provider="railway"] .aws-fields,
.deploy-form[data-provider="railway"] .render-fields,
.deploy-form[data-provider="railway"] .aws-only,
.deploy-form[data-provider="render"] .aws-fields,
.deploy-form[data-provider="render"] .railway-fields,
.deploy-form[data-provider="aws"] .railway-fields,
.deploy-form[data-provider="aws"] .render-fields,
.deploy-form[data-provider="render"] .aws-only,
.deploy-form[data-provider="railway"] .render-only,
.deploy-form[data-provider="aws"] .render-only,
.deploy-form[data-provider="render"] .source-zip,
.deploy-form[data-provider="render"] #source-zip,
.deploy-form[data-provider="aws"] #source-zip,
.deploy-form[data-provider="render"] .deploy-seg label[for="source-zip"],
.deploy-form[data-provider="aws"] .deploy-seg label[for="source-zip"],
.deploy-form[data-source="zip"] .source-repo,
.deploy-form[data-source="repo"] .source-zip { display: none; }

/* ---------- plan ---------- */
.deploy-plan-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.deploy-plan-title h3 { font-size: 20px; }
.deploy-plan-heading { display: flex; align-items: center; gap: 10px; }
.deploy-plan-heading img { width: 24px; height: 24px; object-fit: contain; flex: 0 0 auto; }

.deploy-pill {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--color-bg-hover);
  color: var(--color-text-muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  overflow-wrap: anywhere;
}

.deploy-pill--managed { background: var(--color-accent-light); color: var(--color-accent); }
.deploy-pill--image { background: var(--color-primary-light); color: var(--color-primary); }
.deploy-pill--build { background: rgba(180, 86, 10, 0.12); color: #8a4208; }

.deploy-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-lg);
}

.deploy-step {
  position: relative;
  padding-left: 26px;
}

.deploy-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: -18px;
  width: 2px;
  background: var(--color-border);
}

.deploy-step:last-child::before { display: none; }

.deploy-dot {
  position: absolute;
  left: -5px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-surface);
}

.deploy-step h4 {
  font-size: 15.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.deploy-step p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.deploy-step code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--color-bg-hover);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.deploy-service-select {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.deploy-vars {
  margin: var(--space-sm) 0 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 12px;
  font-size: 13px;
}

.deploy-vars dt {
  font-family: var(--font-mono);
  color: var(--color-text-dim);
}

.deploy-vars dd { margin: 0; color: var(--color-text-muted); overflow-wrap: anywhere; }

.deploy-ref {
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ---------- notices ---------- */
.deploy-notice {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border-hover);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: 14.5px;
  color: var(--color-text-muted);
}

.deploy-notice strong { color: var(--color-text); display: block; margin-bottom: 6px; }

.deploy-notice ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }

.deploy-notice--warn { border-left-color: #b78a0a; background: rgba(183, 138, 10, 0.06); }

.deploy-notice--error { border-left-color: var(--color-error); background: rgba(192, 57, 43, 0.05); }

.deploy-notice--ok { border-left-color: var(--color-success); background: var(--color-accent-light); }

.deploy-notice code { font-family: var(--font-mono); font-size: 12.5px; }

.deploy-confirm.deploy-credential-dialog { width: min(560px, calc(100% - 32px)); max-height: min(90vh, 760px); overflow: auto; }
.deploy-confirm.deploy-git-credential-dialog { width: min(560px, calc(100% - 32px)); max-height: min(90vh, 760px); overflow: auto; }
.deploy-credential-dialog .deploy-confirm-card { display: grid; gap: 12px; }
.deploy-credential-dialog h2,
.deploy-credential-dialog p { margin-top: 0; }
.deploy-credential-dialog-fields { display: none; gap: 8px; }
.deploy-credential-dialog[data-provider="railway"] [data-credential-provider="railway"],
.deploy-credential-dialog[data-provider="render"] [data-credential-provider="render"],
.deploy-credential-dialog[data-provider="aws"] [data-credential-provider="aws"] { display: grid; }
.deploy-credential-dialog-fields .form-note { margin: 0; line-height: 1.5; }
.deploy-btn[hidden] { display: none; }

/* ---------- deployment status ---------- */
.deploy-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--color-bg-hover);
  color: var(--color-text-muted);
}

.deploy-status--deployed { background: var(--color-accent-light); color: var(--color-accent); }
.deploy-status--destroyed { background: var(--color-bg-hover); color: var(--color-text-dim); }
.deploy-status--failed,
.deploy-status--cleanup_failed { background: rgba(192, 57, 43, 0.1); color: #8e2b20; }
.deploy-status--provisioning,
.deploy-status--destroying { background: var(--color-primary-light); color: var(--color-primary); }

.deploy-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  font-size: 14px;
  margin-top: var(--space-md);
}

.deploy-meta dt { color: var(--color-text-dim); font-size: 13px; }
.deploy-meta dd { margin: 0; overflow-wrap: anywhere; }
.deploy-meta code { font-family: var(--font-mono); font-size: 12.5px; }

.deploy-console {
  overflow: hidden;
  margin-top: var(--space-md);
  border: 1px solid #263449;
  border-radius: var(--radius-md);
  background: #0b1220;
  color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.deploy-console-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 8px 13px;
  border-bottom: 1px solid #263449;
  background: #111c2d;
  font-family: var(--font-mono);
  font-size: 12px;
}

.deploy-console-lights { display: flex; gap: 5px; }
.deploy-console-lights i { width: 8px; height: 8px; border-radius: 50%; background: #475569; }
.deploy-console-lights i:first-child { background: #f87171; }
.deploy-console-lights i:nth-child(2) { background: #fbbf24; }
.deploy-console-lights i:last-child { background: #34d399; }
.deploy-console-title { color: #dbeafe; }
.deploy-console-state { margin-left: auto; color: #94a3b8; text-transform: uppercase; }
.deploy-console-state--running,
.deploy-console-state--provisioning,
.deploy-console-state--destroying { color: #60a5fa; }
.deploy-console-state--complete,
.deploy-console-state--deployed { color: #4ade80; }
.deploy-console-state--failed { color: #f87171; }

.deploy-console-output {
  display: grid;
  gap: 3px;
  max-height: 380px;
  overflow: auto;
  padding: 13px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  scrollbar-color: #475569 #0b1220;
}

.deploy-console-line {
  display: grid;
  grid-template-columns: 16px 100px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.deploy-console-prefix { color: #64748b; }
.deploy-console-kind { color: #94a3b8; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; }
.deploy-console-message { min-width: 0; overflow-wrap: anywhere; color: #e2e8f0; }
.deploy-console-detail,
.deploy-console-error { grid-column: 3; overflow-wrap: anywhere; color: #94a3b8; }
.deploy-console-line--complete .deploy-console-kind,
.deploy-console-line--created .deploy-console-kind,
.deploy-console-line--verified .deploy-console-kind,
.deploy-console-line--deleted .deploy-console-kind,
.deploy-console-line--running .deploy-console-kind { color: #4ade80; }
.deploy-console-line--creating .deploy-console-kind,
.deploy-console-line--starting .deploy-console-kind,
.deploy-console-line--verifying .deploy-console-kind,
.deploy-console-line--deleting .deploy-console-kind,
.deploy-console-line--associating .deploy-console-kind { color: #60a5fa; }
.deploy-console-line--failed .deploy-console-kind,
.deploy-console-line--failed .deploy-console-error { color: #f87171; }
.deploy-console-line--failed .deploy-console-message { color: #fecaca; }
.deploy-console-line--waiting .deploy-console-kind { color: #fbbf24; }
.deploy-console-footer {
  padding: 9px 13px;
  border-top: 1px solid #263449;
  color: #4ade80;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.deploy-console-footer::before { content: "› "; color: #64748b; }

/* ---------- history ---------- */
.deploy-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-md); }

.deploy-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  padding: var(--space-md) var(--space-lg);
}

.deploy-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.deploy-item-head h3 { font-size: 16px; overflow-wrap: anywhere; }

.deploy-item-sub {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--color-text-muted);
}

.deploy-provider-logo {
  width: 14px;
  height: 14px;
  object-fit: contain;
  vertical-align: -2px;
  margin-right: 5px;
}

.deploy-item-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: var(--space-md);
}

.deploy-item-actions form { display: inline-flex; }
.deploy-item-actions form.deploy-delete-trigger { display: inline-flex; flex: 0 0 auto; }

.deploy-error {
  margin-top: var(--space-sm);
  font-size: 13.5px;
  color: #8e2b20;
}

.deploy-btn {
  padding: 8px 16px;
  font-size: 13.5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.deploy-btn:hover { border-color: var(--color-text); background: var(--color-bg-hover); }

.deploy-btn--danger { color: #8e2b20; border-color: rgba(192, 57, 43, 0.35); }

.deploy-btn--danger:hover { border-color: var(--color-error); background: rgba(192, 57, 43, 0.06); }

.deploy-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.deploy-confirm {
  width: min(460px, calc(100% - 32px));
  max-width: none;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  background: var(--color-bg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .24);
}

.deploy-confirm::backdrop { background: rgba(15, 23, 42, .58); }
.deploy-confirm-card { padding: 28px; }
.deploy-confirm-card h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.25; }
.deploy-confirm-card > p:not(.eyebrow) { color: var(--color-text-muted); line-height: 1.6; }
.deploy-confirm-card .eyebrow { margin-top: 0; }
.deploy-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.deploy-confirm-actions button[value="confirm"] { background: #a93226; color: #fff; border-color: #a93226; }
.deploy-confirm-actions button[value="confirm"]:hover { background: #86281f; }
.deploy-btn--primary { background: var(--color-text); color: #fff; border-color: var(--color-text); text-decoration: none; }
.deploy-btn--primary:hover { background: #000; color: #fff; }

@media (max-width: 480px) {
  .deploy-confirm-card { padding: 22px; }
  .deploy-confirm-actions { flex-direction: column-reverse; }
  .deploy-confirm-actions > * { width: 100%; }
}

.deploy-empty {
  padding: var(--space-xl);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14.5px;
}

.deploy-history-progress {
  margin-top: var(--space-md);
  overflow: hidden;
  border: 1px solid #263449;
  border-radius: var(--radius-md);
  background: #0b1220;
}

.deploy-history-progress summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: #111c2d;
  color: #dbeafe;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.deploy-history-progress[open] summary { border-bottom: 1px solid #263449; }
.deploy-history-progress .deploy-console { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.deploy-history-progress .deploy-console-output { max-height: 260px; }
.deploy-console-open { color: #4ade80; font-size: 10.5px; text-transform: uppercase; }

@media (max-width: 640px) {
  .deploy-plan-source { align-items: stretch; flex-direction: column; }
  .deploy-plan-source > .deploy-btn { width: 100%; justify-content: center; }
  .deploy-panel { padding: var(--space-lg); }
  .deploy-choose { grid-template-columns: 1fr; }
  .deploy-row,
  .deploy-row--three { grid-template-columns: 1fr; }
  .deploy-meta { grid-template-columns: 1fr; gap: 2px; }
  .deploy-meta dd { margin-bottom: 8px; }
  .deploy-item { padding: var(--space-md); }
  .deploy-item-actions > *, .deploy-item-actions form, .deploy-item-actions .deploy-btn { width: 100%; }
  .deploy-item-actions .deploy-btn { justify-content: center; text-align: center; }
  .deploy-console-output { max-height: 300px; padding: 10px; font-size: 11px; }
  .deploy-console-line { grid-template-columns: 12px 78px minmax(0, 1fr); gap: 6px; }
  .deploy-console-kind { font-size: 9px; }
  .deploy-plan-title { align-items: flex-start; flex-direction: column; }
  .deploy-resource { grid-template-columns: minmax(0, 1fr); }
  .deploy-resource-status { grid-row: 2; }
  .deploy-vars { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .deploy-vars dd { margin-bottom: 6px; overflow-wrap: anywhere; }
  .deploy-btn { min-height: 44px; }
}
.deploy-btn--primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.deploy-locked-empty {
  display: grid;
  gap: 6px;
}

.deploy-locked-empty strong {
  color: var(--ink, #172033);
}

.deploy-locked-empty span {
  line-height: 1.5;
}

.deploy-locked-empty a {
  width: fit-content;
  font-weight: 700;
}

