/* Forms, Inputs, and Buttons */

/* ── Labels ── */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #9B9DA8);
  margin-bottom: 6px;
}

/* ── Text Inputs ── */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-card, #FFFFFF);
  color: var(--text-primary, #1C1E2A);
  border: 1.5px solid var(--border, #D8D5CE);
  border-radius: var(--radius-md, 10px);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition, 0.2s);
}

/* ── Select with chevron ── */
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%239B9DA8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

/* ── Hover ── */
input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
select:hover,
textarea:hover {
  border-color: var(--text-muted, #9B9DA8);
}

/* ── Focus (mode-aware) ── */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--active-accent, var(--accent));
  box-shadow: var(--shadow-glow, 0 0 0 3px) color-mix(in srgb, var(--active-accent, var(--accent)) 15%, transparent);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted, #9B9DA8);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

/* ── Config Bar (horizontal form row) ── */
.config-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.config-field {
  flex: 1;
  min-width: 160px;
}
.config-field.small {
  flex: 0 0 160px;
}

/* ── Row layout ── */
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.row > div,
.row > label {
  flex: 1;
  min-width: 160px;
}

/* ── Project attachment lists ── */
.project-existing-attachments .attach-list li,
#project-attach-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}
.project-existing-attachments .existing-attachment-label,
.pending-attachment-label {
  justify-self: start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-existing-attachments .existing-attachment-remove,
.pending-attachment-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #ff4d4f;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease;
  padding: 0;
  line-height: 1;
  box-sizing: border-box;
}
.project-existing-attachments .existing-attachment-remove:hover:not(:disabled),
.pending-attachment-remove:hover:not(:disabled) {
  background: #ff6b6d;
}
.project-existing-attachments .existing-attachment-remove:disabled,
.pending-attachment-remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.project-existing-attachments .existing-attachment-remove .remove-icon::before,
.pending-attachment-remove .remove-icon::before {
  content: '\2715';
  font-size: 12px;
}
.project-existing-attachments .existing-attachment-remove.confirming {
  background: #ff8587;
}
.project-existing-attachments .existing-attachment-remove.confirming .remove-icon::before {
  content: '!';
}
.project-existing-attachments .existing-attachment-remove.loading .remove-icon::before {
  content: '\2026';
}
.project-existing-attachments .existing-attachment-remove .remove-icon,
.pending-attachment-remove .remove-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.project-existing-attachments.hidden {
  display: none !important;
}
.inline-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Buttons ── */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition, 0.2s);
}
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.small-btn {
  padding: 6px 10px;
  font-size: 12px;
}
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

/* ── Busy spinner ── */
button .spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: agp-spin 0.9s linear infinite;
}

#btn-send.busy,
#btn-discovery-send.busy,
#btn-event-send.busy,
#btn-wb-send.busy,
#btn-generate.busy,
button.busy {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 40px !important;
}

#btn-send.busy .spinner,
#btn-send.busy .label,
#btn-discovery-send.busy .spinner,
#btn-discovery-send.busy .label,
#btn-event-send.busy .spinner,
#btn-event-send.busy .label,
#btn-wb-send.busy .spinner,
#btn-wb-send.busy .label,
#btn-generate.busy .spinner,
#btn-generate.busy .label,
button.busy .spinner,
button.busy .label {
  display: inline-flex !important;
  align-self: center !important;
}

#btn-send.busy .spinner,
#btn-discovery-send.busy .spinner,
#btn-event-send.busy .spinner,
#btn-wb-send.busy .spinner,
#btn-generate.busy .spinner,
button.busy .spinner {
  margin-right: 8px !important;
  flex-shrink: 0 !important;
}

#btn-send.busy .label,
#btn-discovery-send.busy .label,
#btn-event-send.busy .label,
#btn-wb-send.busy .label,
#btn-generate.busy .label,
button.busy .label {
  opacity: 0.9 !important;
}

@keyframes agp-spin {
  to { transform: rotate(360deg); }
}

/* ── Mode Tabs (segmented pill toggle) ── */
.segmented {
  display: flex;
  gap: 6px;
  width: 100%;
  background: var(--bg-card, #FFFFFF);
  border: 1px solid var(--border-light, #EBE9E3);
  border-radius: var(--radius-lg, 16px);
  padding: 5px;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  box-shadow: var(--shadow-sm);
  margin-bottom: 36px;
}

.seg {
  flex: 1;
  background: transparent;
  color: var(--text-muted, #9B9DA8);
  border: 1.5px solid transparent;
  padding: 13px 20px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 32px;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  font-weight: 500;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.25s ease;
}

.seg svg,
.seg i svg {
  width: 18px;
  height: 18px;
  opacity: 0.5;
  transition: all var(--transition, 0.2s);
  flex-shrink: 0;
}

.seg:hover {
  color: var(--text-secondary, #6B6D7B);
  background: var(--bg-input, #F0EDE8);
}
.seg:hover svg,
.seg:hover i svg {
  opacity: 0.7;
}

/* Default active state */
.seg.active {
  font-weight: 600;
  box-shadow: var(--shadow-md);
  outline: none;
}
.seg.active svg,
.seg.active i svg {
  opacity: 1;
}

/* Per-mode active tab colors */
.seg[data-mode="discovery"].active {
  background: var(--discovery-bg, #FDF8ED);
  color: #8B6E1A;
  border-color: var(--discovery-border, #F0E4C4);
}
.seg[data-mode="discovery"].active svg { color: var(--discovery-accent); }

.seg[data-mode="coach"].active {
  background: var(--coach-bg, #EDF8F6);
  color: #1A6B60;
  border-color: var(--coach-border, #C4E8E3);
}
.seg[data-mode="coach"].active svg { color: var(--coach-accent); }

.seg[data-mode="event"].active {
  background: var(--event-bg, #EEEEF8);
  color: #3A4490;
  border-color: var(--event-border, #CBCDE8);
}
.seg[data-mode="event"].active svg { color: var(--event-accent); }

.seg[data-mode="workbench"].active {
  background: var(--workbench-bg, #FDF0EF);
  color: #8B3A34;
  border-color: var(--workbench-border, #F0CCCB);
}
.seg[data-mode="workbench"].active svg { color: var(--workbench-accent); }

/* Mode tab spinner */
.seg .spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: agp-spin 0.9s linear infinite;
  flex-shrink: 0;
}
.seg.busy .spinner {
  display: inline-block;
}
.seg.busy {
  min-width: fit-content;
}

/* Ensure inputs are not blocked */
textarea,
input {
  pointer-events: auto !important;
  z-index: auto;
}

#user-input,
#event-input,
#workbench-input {
  pointer-events: auto !important;
  position: relative;
}

/* Hide native file input */
#ctx-file-input,
#composer-file-input,
#event-file-input,
input[type="file"].visually-hidden {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
}

/* ── Team Color Picker ── */
.team-color-picker {
  display: flex;
  gap: 10px;
  padding: 6px 4px;
}
.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  padding: 0;
  outline: none;
}
.color-dot:hover {
  transform: scale(1.15);
}
.color-dot:focus-visible {
  box-shadow: 0 0 0 2px var(--bg, #F6F4F0), 0 0 0 4px var(--accent, #D4A843);
}
.color-dot.selected {
  border-color: var(--text-primary, #1C1E2A);
  transform: scale(1.15);
}

/* ── Modal form spacing (shared across all modals) ── */
.modal-body > label,
.modal-body > div {
  margin-bottom: 18px;
}
.modal-body > :last-child {
  margin-bottom: 0;
}
.modal-body label > input,
.modal-body label > textarea,
.modal-body label > select {
  margin-top: 8px;
}
#team-modal label > select {
  color: var(--text-primary, #1C1E2A);
}
#team-modal label > select option {
  color: var(--text-primary, #1C1E2A);
}
#team-modal label > select option[value=""] {
  color: var(--text-muted, #9B9DA8);
}
#team-modal .ctx-drop-inline,
.team-edit .ctx-drop-inline {
  color: var(--text-muted, #9B9DA8);
  font-size: 14px;
  font-family: inherit;
}

/* ── Team inline edit on Settings page ── */
.team-edit .form-grid label {
  margin-bottom: 0;
}
.team-edit .form-grid select {
  color: var(--text-primary, #1C1E2A);
}
.team-edit .form-grid select option[value=""] {
  color: var(--text-muted, #9B9DA8);
}
.team-edit textarea {
  min-height: 80px;
}

/* ── Danger Zone ── */
.danger-zone {
  margin-top: 4px;
  border: none;
  padding: 0;
}
.danger-zone summary {
  cursor: pointer;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #9B9DA8);
}
.danger-zone[open] summary {
  margin-bottom: 4px;
}
.danger-zone-text {
  padding: 0 0 4px;
  font-size: 13px;
  color: var(--text-secondary, #6B6D7B);
  margin: 0;
}
.danger-zone-delete {
  background: none;
  border: none;
  color: #D4645C;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.danger-zone-delete:hover {
  color: #b83830;
}
