/* ==================
   BASE INPUTS
   ================== */

input[type="text"], select {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  background: #fafafa;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus, select:focus { border-color: #9b7ff5; background: #fff; }
input[type="text"]                     { width: 220px; }

textarea, .form-textarea {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  background: #fafafa;
  color: #1a1a1a;
  outline: none;
  width: 320px;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s;
}

textarea:focus, .form-textarea:focus { border-color: #9b7ff5; background: #fff; }

/* iOS Safari auto-zooms when focusing a field smaller than 16px and never
   zooms back out — render form controls at 16px on touch devices to stop it.
   Pinch-to-zoom (e.g. on photos) stays available. */
@media (pointer: coarse) {
  input, textarea, select, .form-textarea,
  .form-control, .form-control-sm, .form-select { font-size: 16px; }
}

button, input[type="submit"] {
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 1rem;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background 0.15s;
}

button:hover, input[type="submit"]:hover { background: #2d2d4e; }

.btn-clear {
  background: none;
  color: #888;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  text-decoration: none;
  transition: background 0.15s;
}

.btn-clear:hover { background: #f0f0f0; color: #444; }

label { font-size: var(--font-size-sm); color: #555; display: flex; align-items: center; gap: 0.35rem; }

/* ==================
   SEARCH WRAP + CLEAR
   ================== */

.search-wrap                                        { position: relative; display: inline-flex; align-items: center; }
.search-wrap input[type="text"]                     { padding-right: 1.5rem; }

.search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: color 0.1s, opacity 0.1s;
}

.search-clear:hover                                              { color: #555; background: none; }
.search-wrap input:not(:placeholder-shown) ~ .search-clear      { opacity: 1; pointer-events: auto; }

/* ==================
   PROGRAM MULTI-SELECT DROPDOWN
   ================== */

.program-dropdown { position: relative; }

.program-dropdown-summary {
  list-style: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.4rem 1.75rem 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  background: #fafafa;
  color: #1a1a1a;
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  position: relative;
}

.program-dropdown-summary::-webkit-details-marker { display: none; }
.program-dropdown-summary::after {
  content: "▾";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #888;
}

.program-dropdown[open] .program-dropdown-summary::after { content: "▴"; }

.program-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 0.4rem 0;
  min-width: 160px;
  max-height: 260px;
  overflow-y: auto;
}

.program-dropdown-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: #1a1a1a;
  white-space: nowrap;
}

.program-dropdown-option:hover { background: #f5f0ff; }

/* ==================
   INLINE EDITING
   ================== */

.markers-table .inline-input {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  font-size: var(--font-size-sm);
  width: 100%;
  background: #fafafa;
  color: #1a1a1a;
  transition: border-color 0.15s, background 0.15s;
}

.markers-table .inline-input:focus    { outline: none; border-color: #9b7ff5; background: #fff; }
.markers-table .inline-input--short   { width: 80px; }
.markers-table .inline-input--tiny    { width: 52px; }
.markers-table .inline-input--wide    { width: 190px; }

.markers-table .row-inactive td { opacity: 0.45; }
.markers-table .row-new td      { background: #f9f7ff; }

.btn-save-inline {
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 0.3rem 0.7rem;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-save-inline:hover          { background: #2d2d4e; }
.btn-save-inline.btn-add        { background: #3a7c3a; }
.btn-save-inline.btn-add:hover  { background: #2d5e2d; }

.hidden-form { display: none; }

.btn-inline-pencil {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: var(--font-size-sm);
  padding: 0 0.25rem;
  opacity: 0;
  transition: opacity 0.1s;
  vertical-align: middle;
}

.btn-inline-pencil:hover      { color: #555; background: none; }
dd:hover .btn-inline-pencil   { opacity: 1; }

.inline-edit-input {
  font-size: var(--font-size-sm);
  font-family: inherit;
  border: 1px solid #c7d4f5;
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

.inline-edit-input:focus { outline: none; border-color: #1a1a2e; }

/* ==================
   DESTRUCTIVE BUTTON
   ================== */

.btn-danger {
  background: var(--cat-danger);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background 0.15s;
}

/* color.adjust(#E63946, $lightness: -10%) */
.btn-danger:hover { background: #D21A28; }

/* ==================
   BASKET TOOLBAR
   ================== */

.basket-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.basket-toolbar-left { display: flex; gap: 0.5rem; align-items: center; }

.basket-load-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-left: 1px solid #e5e5e5;
  padding-left: 1rem;
}

.basket-file-input  { font-size: 12px; color: #555; }
.basket-radio       { font-size: var(--font-size-sm); color: #555; display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }

.basket-col              { display: none; }
.select-mode .basket-col { display: table-cell; }
.assign-mode .basket-col { display: table-cell; }

.select-action-bar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }

.btn-load-csv {
  background: #5a7abf;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-load-csv:hover { background: #3d5a99; }

.btn-select-mode {
  background: none;
  color: #666;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-select-mode:hover            { background: #f0f0f0; color: #333; }
.btn-select-mode.btn-select-active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

.btn-add-basket {
  background: #3a7c3a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.85rem;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-add-basket:hover { background: #2d5e2d; }

/* ==================
   ASSIGN SEEDKEYS
   ================== */

.btn-create-keys {
  background: #7c5cbf;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 1.1rem;
  font-size: var(--font-size-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}

.btn-create-keys:hover:not(:disabled) { background: #6347a8; }
.btn-create-keys:disabled             { opacity: 0.4; cursor: default; }

.assign-badge {
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 0 0.45rem;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.collection-input {
  width: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  font-size: 12px;
  background: #fafafa;
  color: #1a1a1a;
  text-align: center;
}

.collection-input:focus { border-color: #9b7ff5; background: #fff; outline: none; }

.confirm-table td { vertical-align: top; }

/* ==================
   PHOTO UPLOAD + CAPTION
   ================== */

.btn-add-photo {
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: #3a7c3a;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
}

.btn-add-photo:hover { background: #2d5e2d; }

.btn-photo-delete {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  padding: 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-photo-delete:hover { background: var(--cat-danger); }

.photo-caption-input       { width: 100%; font-size: 11px; padding: 2px 4px; border: 1px solid #ddd; border-radius: 3px; color: #444; box-sizing: border-box; }
.photo-caption-input:focus { outline: none; border-color: #9b7de8; }
.photo-caption-text        { font-size: 11px; color: #666; margin: 0; }

.photo-upload-spinner { margin-left: 0.75rem; font-size: var(--font-size-sm); color: #888; }
.upload-error         { margin-top: 0.5rem; font-size: var(--font-size-sm); color: #c0392b; }

/* ==================
   TRIAL ENTRIES IMPORT
   ================== */

.trial-entries-import          { margin-bottom: 0.75rem; font-size: var(--font-size-sm); }
.trial-entries-import > summary {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  background: #3b4dbf;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  font-size: var(--font-size-sm);
  list-style: none;
}
.trial-entries-import > summary::-webkit-details-marker { display: none; }
.trial-entries-import > summary:hover                   { background: #2d3da0; }
.trial-entries-form   { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; padding: 0.75rem; background: #f8f9ff; border: 1px solid #dde3f5; border-radius: 6px; width: fit-content; }
.entries-row          { display: flex; align-items: center; gap: 1rem; }
.entries-label        { font-weight: 600; color: #555; width: 4.5rem; }

.trial-marker-plan-link       { font-size: var(--font-size-sm); font-weight: 500; color: #3b5bdb; text-decoration: none; align-self: center; }
.trial-marker-plan-link:hover { text-decoration: underline; }

/* ==================
   ADMIN USER FORMS
   ================== */

/* Overrides the general .page-header for admin pages (adds space-between) */
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-title   { font-size: 1.1rem; font-weight: 600; color: #1a1a2e; margin: 0; }

.btn-action       { background: #1a1a2e; color: #fff; border: none; border-radius: 6px; padding: 0.4rem 0.9rem; font-size: var(--font-size-sm); font-weight: 500; text-decoration: none; cursor: pointer; transition: background 0.15s; }
.btn-action:hover { background: #2d2d4e; color: #fff; }

.col-actions { display: flex; gap: 0.75rem; align-items: center; white-space: nowrap; }

.btn-link              { background: none; border: none; padding: 0; font-size: var(--font-size-sm); cursor: pointer; color: #6b7280; text-decoration: underline; }
.btn-link--danger      { color: #dc2626; }
.btn-link--danger:hover { color: #991b1b; }

.role-badge         { display: inline-block; border-radius: 4px; padding: 0.15rem 0.5rem; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.role-badge--admin  { background: #fef2f2; color: #991b1b; }
.role-badge--editor { background: #fffbeb; color: #92400e; }
.role-badge--viewer { background: #f0fdf4; color: #166534; }

.user-form  { max-width: 420px; display: flex; flex-direction: column; gap: 1rem; }
.form-field { display: flex; flex-direction: column; gap: 0.3rem; }

.form-field label                             { font-size: var(--font-size-sm); font-weight: 500; color: #374151; }
.form-field input, .form-field select         { border: 1px solid #d1d5db; border-radius: 6px; padding: 0.45rem 0.65rem; font-size: 14px; width: 100%; }
.form-field input:focus, .form-field select:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }

.form-actions { display: flex; gap: 0.75rem; align-items: center; padding-top: 0.5rem; }
