/* Carbon Core · Toast's repository intake
 * Scoped to the injected repository tool so existing Kitchen/role views keep
 * their established layout and controls.
 */

.toast-repository-tools {
  --toast-panel: rgba(8, 17, 11, 0.96);
  --toast-panel-soft: rgba(13, 25, 17, 0.92);
  --toast-border: color-mix(in srgb, var(--cc-gold, #c9a62e) 25%, transparent);
  --toast-border-strong: color-mix(in srgb, var(--cc-gold, #c9a62e) 58%, transparent);
  --toast-gold: var(--cc-gold, #c9a62e);
  --toast-gold-light: var(--cc-gold-light, #e2c85d);
  --toast-cream: var(--cc-cream, #edf0e7);
  --toast-muted: var(--cc-muted, #7e8b80);
  --toast-green: var(--cc-green, #58ae76);
  --toast-error: #e78974;
  --toast-focus: #f0d972;
  position: relative;
  z-index: 4;
  width: min(100%, 920px);
  margin: 10px 0 14px auto;
  color: var(--toast-cream);
  font: inherit;
}

/* The live repository view is normally toolbar + stage. When this direct child
 * is mounted, reserve one bounded middle row without letting the form squeeze
 * the lineage canvas out of view. */
.cc-toast-view:has(> .toast-repository-tools) {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.cc-toast-view > .toast-repository-tools {
  min-height: 0;
}

.cc-toast-view > .toast-repository-tools [data-toast-add-panel] {
  max-height: min(45vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--cc-gold, #c9a62e) 30%, transparent) rgba(0, 0, 0, 0.2);
  scrollbar-width: thin;
}

.toast-repository-tools,
.toast-repository-tools * {
  box-sizing: border-box;
}

.toast-repository-tools [hidden] {
  display: none !important;
}

.toast-repository-tools button,
.toast-repository-tools input,
.toast-repository-tools select,
.toast-repository-tools textarea {
  font: inherit;
}

.toast-repository-tools button {
  -webkit-tap-highlight-color: transparent;
}

.toast-repository-tools__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.toast-repository-tools__header > div {
  min-width: 0;
}

.toast-repository-tools [data-toast-add-toggle] {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  float: none;
  position: relative;
  z-index: 1;
  padding: 6px 11px;
  border: 1px solid var(--toast-border-strong);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(202, 167, 47, 0.14), rgba(202, 167, 47, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 18px rgba(0, 0, 0, 0.2);
  color: var(--toast-gold-light);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.105em;
  line-height: 1;
  text-transform: uppercase;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.toast-repository-tools [data-toast-add-toggle]::before {
  content: "+";
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}

.toast-repository-tools [data-toast-add-toggle][aria-expanded="true"]::before {
  content: "−";
}

.toast-repository-tools [data-toast-add-toggle]:hover {
  border-color: var(--toast-gold-light);
  background: rgba(202, 167, 47, 0.17);
  color: #f2dd83;
}

.toast-repository-tools [data-toast-add-toggle]:active {
  transform: translateY(1px);
}

.toast-repository-tools [data-toast-add-panel] {
  clear: both;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--toast-border);
  border-top-color: var(--toast-border-strong);
  border-radius: 10px;
  background:
    radial-gradient(circle at 90% -20%, rgba(198, 160, 39, 0.12), transparent 42%),
    linear-gradient(145deg, var(--toast-panel-soft), var(--toast-panel));
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.32), inset 0 1px rgba(255, 255, 255, 0.025);
  padding: clamp(16px, 2.5vw, 24px);
  animation: toast-panel-enter 180ms ease-out both;
}

@keyframes toast-panel-enter {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-repository-tools [data-toast-add-panel] > :first-child,
.toast-repository-tools [data-toast-add-panel] h2,
.toast-repository-tools [data-toast-add-panel] h3 {
  margin-top: 0;
}

.toast-repository-tools [data-toast-add-panel] h2,
.toast-repository-tools [data-toast-add-panel] h3 {
  margin-bottom: 5px;
  color: var(--toast-cream);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 760;
  letter-spacing: 0.025em;
}

.toast-repository-tools [data-toast-add-panel] > p:not(.toast-repository-storage-note):not([data-toast-form-status]) {
  max-width: 68ch;
  margin: 0 0 16px;
  color: var(--toast-muted);
  font-size: 12px;
  line-height: 1.55;
}

.toast-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 15px;
}

.toast-field {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 6px;
}

.toast-field--wide {
  grid-column: 1 / -1;
}

.toast-field > span,
.toast-field > label,
.toast-field label > span {
  color: color-mix(in srgb, var(--toast-cream) 72%, var(--toast-muted));
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.13em;
  line-height: 1.25;
  text-transform: uppercase;
}

.toast-field small {
  color: var(--toast-muted);
  font-size: 10px;
  line-height: 1.45;
}

.toast-field input,
.toast-field select,
.toast-field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(202, 168, 48, 0.18);
  border-radius: 6px;
  outline: 0;
  background: rgba(2, 9, 5, 0.78);
  color: var(--toast-cream);
  font-size: 12px;
  line-height: 1.4;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.toast-field input,
.toast-field select {
  padding: 8px 10px;
}

.toast-field textarea {
  min-height: 84px;
  resize: vertical;
  padding: 10px;
}

.toast-field select {
  color-scheme: dark;
}

.toast-field input::placeholder,
.toast-field textarea::placeholder {
  color: color-mix(in srgb, var(--toast-muted) 72%, transparent);
}

.toast-field input:hover,
.toast-field select:hover,
.toast-field textarea:hover {
  border-color: rgba(202, 168, 48, 0.36);
}

.toast-field input:focus,
.toast-field select:focus,
.toast-field textarea:focus {
  border-color: var(--toast-gold-light);
  background: rgba(4, 13, 7, 0.96);
  box-shadow: 0 0 0 3px rgba(226, 200, 93, 0.13);
}

.toast-field input[aria-invalid="true"],
.toast-field select[aria-invalid="true"],
.toast-field textarea[aria-invalid="true"] {
  border-color: var(--toast-error);
  box-shadow: 0 0 0 2px rgba(231, 137, 116, 0.12);
}

.toast-form-actions,
.toast-backup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toast-form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  margin-top: 2px;
  padding-top: 13px;
  border-top: 1px solid rgba(202, 168, 48, 0.11);
}

.toast-backup-actions {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid rgba(202, 168, 48, 0.12);
}

.toast-form-actions button,
.toast-backup-actions button {
  min-height: 35px;
  padding: 8px 12px;
  border: 1px solid rgba(202, 168, 48, 0.32);
  border-radius: 6px;
  background: rgba(202, 168, 48, 0.075);
  color: var(--toast-gold-light);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.toast-form-actions button[type="submit"] {
  border-color: color-mix(in srgb, var(--toast-green) 68%, var(--toast-gold));
  background: linear-gradient(180deg, color-mix(in srgb, var(--toast-green) 25%, transparent), color-mix(in srgb, var(--toast-green) 12%, transparent));
  color: #b8e2bf;
}

.toast-form-actions button:hover,
.toast-backup-actions button:hover {
  border-color: var(--toast-gold-light);
  background: rgba(202, 168, 48, 0.15);
  color: #f0dc84;
}

.toast-form-actions button[type="submit"]:hover {
  border-color: #86c895;
  background: color-mix(in srgb, var(--toast-green) 29%, transparent);
  color: #d2f0d7;
}

.toast-form-actions button:active,
.toast-backup-actions button:active {
  transform: translateY(1px);
}

.toast-repository-tools button:disabled,
.toast-repository-tools input:disabled,
.toast-repository-tools select:disabled,
.toast-repository-tools textarea:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.toast-repository-storage-note {
  position: relative;
  clear: both;
  margin: 15px 0 0;
  padding: 10px 11px 10px 31px;
  border: 1px solid rgba(113, 164, 124, 0.21);
  border-radius: 6px;
  background: rgba(52, 104, 65, 0.09);
  color: #91aa96;
  font-size: 10px;
  line-height: 1.5;
}

.toast-repository-storage-note::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 12px;
  width: 8px;
  height: 8px;
  border: 1px solid var(--toast-green);
  border-radius: 50%;
  box-shadow: 0 0 9px color-mix(in srgb, var(--toast-green) 58%, transparent);
}

.toast-repository-storage-note strong {
  color: #b8cdbb;
  font-weight: 750;
}

.toast-repository-tools [data-toast-form-status] {
  min-height: 18px;
  margin: 10px 0 0;
  padding: 2px 0;
  color: var(--toast-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.025em;
  line-height: 1.4;
}

.toast-repository-tools [data-toast-form-status][data-state="working"] {
  color: var(--toast-gold-light);
}

.toast-repository-tools [data-toast-form-status][data-state="working"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border: 1px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: toast-status-spin 700ms linear infinite;
}

.toast-repository-tools [data-toast-form-status][data-state="success"] {
  color: #82cb94;
}

.toast-repository-tools [data-toast-form-status][data-state="success"]::before {
  content: "✓";
  margin-right: 6px;
}

.toast-repository-tools [data-toast-form-status][data-state="error"] {
  color: var(--toast-error);
}

.toast-repository-tools [data-toast-form-status][data-state="error"]::before {
  content: "!";
  display: inline-grid;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 9px;
}

@keyframes toast-status-spin {
  to { transform: rotate(360deg); }
}

.toast-repository-tools :where(button, input, select, textarea):focus-visible {
  outline: 2px solid var(--toast-focus);
  outline-offset: 3px;
}

@media (max-width: 700px) {
  .toast-repository-tools {
    width: 100%;
    margin-right: 0;
  }

  .toast-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast-field--wide,
  .toast-form-actions {
    grid-column: 1;
  }

  .toast-form-actions {
    justify-content: stretch;
  }

  .toast-form-actions button {
    flex: 1 1 140px;
  }
}

@media (max-width: 440px) {
  .toast-repository-tools__header {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast-repository-tools [data-toast-add-toggle] {
    width: 100%;
  }

  .toast-repository-tools [data-toast-add-panel] {
    margin-top: 8px;
    padding: 14px;
  }

  .toast-backup-actions button {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast-repository-tools *,
  .toast-repository-tools *::before,
  .toast-repository-tools *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
