/* ==================================================================
   Forms, alerts, tables
   ================================================================== */
.form-group { margin-bottom: var(--sp-5); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
label { display: block; font-weight: 600; font-size: var(--fs-sm); color: var(--navy-800); margin-bottom: var(--sp-2); }
label .req { color: var(--red-500); }
.form-control, input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=date], input[type=search], input[type=url], select, textarea {
  width: 100%;
  padding: 0.85rem 1.05rem;
  font: inherit; font-size: var(--fs-sm);
  color: var(--text);
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { min-height: 140px; resize: vertical; }
.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(37,211,148,.12);
}
.form-control.is-invalid, input.is-invalid, textarea.is-invalid { border-color: var(--red-500); }
.form-error { color: var(--red-500); font-size: var(--fs-xs); margin-top: 4px; }
.form-hint { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 4px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-5); }
legend { padding: 0 var(--sp-3); font-weight: 700; color: var(--navy-800); }

.checkbox { display: flex; align-items: flex-start; gap: var(--sp-3); }
.checkbox input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--cyan-500); }

/* Inline alerts — borderless, soft tint */
.alert {
  padding: var(--sp-4) var(--sp-5); border-radius: var(--radius-sm);
  margin-bottom: var(--sp-5); border: 0; font-size: var(--fs-sm);
  box-shadow: var(--shadow-xs);
}
.alert-success { background: #e9f8f1; color: #0d6b4c; }
.alert-error, .alert-danger { background: #fdecec; color: #a01620; }
.alert-info { background: #e8f4f8; color: #0b5563; }
.alert-warning { background: #fdf3e7; color: #8a4d15; }

/* ---- Toast notifications — animated popup, borderless ---------- */
.toast-stack {
  position: fixed; top: 24px; right: 24px; z-index: 600;
  display: grid; gap: 10px; width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  position: relative; overflow: hidden; pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4); border: 0; border-radius: var(--radius);
  background: #fff; color: var(--text);
  box-shadow: 0 12px 32px rgba(16,24,40,.18), 0 2px 6px rgba(16,24,40,.08);
  animation: toast-in .38s cubic-bezier(.16,1,.3,1) both;
}
.toast.is-leaving { animation: toast-out .28s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.98); } }

.toast__icon { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.toast__body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.toast__title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.toast__msg { font-size: var(--fs-sm); color: var(--grey-600); line-height: 1.45; }
.toast__close {
  flex: 0 0 auto; width: 26px; height: 26px; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--grey-400); display: grid; place-items: center;
}
.toast__close:hover { background: var(--grey-100); color: var(--ink); }
.toast__bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: toast-bar 5s linear forwards; }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.toast--success .toast__icon { background: rgba(37,211,148,.16); color: #0d6b4c; }
.toast--success .toast__title { color: #0d6b4c; }
.toast--success .toast__bar { background: var(--teal-500); }
.toast--error .toast__icon { background: rgba(237,35,48,.12); color: #a01620; }
.toast--error .toast__title { color: #a01620; }
.toast--error .toast__bar { background: var(--brand-red); }
.toast--warning .toast__icon { background: rgba(230,126,34,.16); color: #8a4d15; }
.toast--warning .toast__title { color: #8a4d15; }
.toast--warning .toast__bar { background: var(--orange-500); }
.toast--info .toast__icon { background: rgba(44,95,124,.12); color: #0b5563; }
.toast--info .toast__title { color: #0b5563; }
.toast--info .toast__bar { background: #2c5f7c; }

@media (max-width: 560px) { .toast-stack { top: 12px; right: 12px; left: 12px; width: auto; } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast__bar { animation: none; display: none; }
}

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid rgba(24,17,68,.07); border-radius: var(--radius); background: #fff;  }
.table-wrap { box-shadow: var(--shadow-xs); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data thead th { background: var(--grey-50); color: var(--grey-600); font-weight: 700; text-transform: uppercase; font-size: var(--fs-xs); letter-spacing: .04em; white-space: nowrap; }
table.data tbody tr:hover { background: var(--grey-50); }
table.data tbody tr:last-child td { border-bottom: 0; }

/* Status pills */
.status { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; }
.status-new, .status-draft { background: var(--grey-100); color: var(--grey-600); }
.status-published, .status-paid, .status-active, .status-open, .status-resolved { background: #e9f8f1; color: #0d6b4c; }
.status-pending, .status-in_progress, .status-partial, .status-scheduled, .status-reviewing { background: #fdf3e7; color: #8a4d15; }
.status-overdue, .status-cancelled, .status-trash, .status-rejected, .status-spam { background: #fdecec; color: #a01620; }
.status-open     { background: #e8f1fd; color: #14508f; }
.status-answered { background: #e9f8f1; color: #0d6b4c; }

/* ---- Inline control row ----------------------------------------
   One consistent gap, equal control heights, bottoms aligned.
   Use for filter/search/export toolbars. ------------------------- */
.control-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.control-row .form-group { margin: 0; display: flex; flex-direction: column; gap: .4rem; min-width: 150px; }
.control-row .form-group > label {
  margin: 0; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--grey-500);
}
/* Equal heights: neutralise the differing vertical paddings */
.control-row input,
.control-row select,
.control-row .btn {
  height: 46px; margin: 0; padding-block: 0; line-height: normal;
}
.control-row .btn { white-space: nowrap; }
.control-row__grow { flex: 1 1 220px; min-width: 0; }
.control-row__grow input { width: 100%; }
/* Keep a two-item row (e.g. search + button) on one line; the field shrinks. */
.control-row--nowrap { flex-wrap: nowrap; }
.control-row--nowrap .control-row__grow { flex: 1 1 auto; min-width: 0; }
@media (max-width: 640px) {
  .control-row .form-group, .control-row__grow { flex: 1 1 100%; min-width: 100%; }
  .control-row .btn { flex: 1 1 auto; }
}

/* Priority pills */
.prio { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; }
.prio--low    { background: var(--grey-100); color: var(--grey-600); }
.prio--normal { background: #e9f8f1; color: #0d6b4c; }
.prio--high   { background: #fdf3e7; color: #8a4d15; }
.prio--urgent { background: #fdecec; color: #a01620; }

/* ---- Ticket status filter chips -------------------------------- */
.ticket-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-filter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  background: #fff; border: 1px solid var(--border); color: var(--grey-600);
  text-decoration: none; box-shadow: var(--shadow-xs);
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}
.ticket-filter__count {
  min-width: 22px; padding: 3px 7px; border-radius: 999px;
  background: var(--grey-100); color: var(--grey-600);
  font-size: .7rem; font-weight: 800; text-align: center; line-height: 1;
}
.ticket-filter:hover { border-color: var(--teal-500); color: var(--teal-600); transform: translateY(-1px); }
.ticket-filter:hover .ticket-filter__count { background: rgba(37,211,148,.16); color: var(--teal-600); }
.ticket-filter.is-active {
  background: var(--teal-500); border-color: var(--teal-500); color: #06301f; box-shadow: var(--shadow-sm);
}
.ticket-filter.is-active .ticket-filter__count { background: rgba(255,255,255,.55); color: #06301f; }

/* ---- Ticket conversation thread -------------------------------- */
.ticket-summary {
  display: flex; flex-wrap: wrap; gap: 2.5rem;
  padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.ticket-summary > div { display: grid; gap: 5px; align-content: start; }

.thread { display: grid; gap: 1rem; }
.thread__msg { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; background: #fff; }
.thread__msg--staff { background: rgba(37,211,148,.07); border-color: rgba(37,211,148,.35); }
.thread__msg--note  { background: #fdf6e7; border-color: #e8d3a2; }
.thread__head { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.thread__head strong { color: var(--ink); }
.thread__head time { margin-left: auto; font-size: var(--fs-xs); color: var(--grey-500); }
.thread__tag { font-size: var(--fs-xs); font-weight: 700; color: #8a5b12; background: #f6e3b8; padding: 2px 8px; border-radius: 999px; }
.thread__body { color: var(--text-muted); line-height: 1.7; }

.ticket-reply-box { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.ticket-reply-box h3 { margin-bottom: 1rem; }
.ticket-reply { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.ticket-reply textarea { width: 100%; }
.ticket-reply__foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; flex-wrap: wrap; }

/* Confirmation holding page mark */
.confirm-mark {
  width: 64px; height: 64px; margin: 0 auto 1.25rem;
  border-radius: 50%; display: grid; place-items: center;
  background: rgba(37,211,148,.12); color: var(--cyan-500);
}

/* Label with a trailing action (e.g. "Forgot password?") */
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.label-row > label { margin: 0; }
.label-row__link { font-size: var(--fs-xs); font-weight: 600; }

/* ---- Download rows (public site, CMS and portal) ---------------- */
.dl-list { display: grid; gap: .75rem; }
.dl-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.dl-row:hover { border-color: var(--teal-500); box-shadow: var(--shadow); }
.dl-row__icon {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--grey-100); color: var(--green-600);
}
.dl-row__main { flex: 1; min-width: 0; }
.dl-row__main h3 { margin: 0 0 3px; font-size: var(--fs-base); }
.dl-row__desc { margin: 0 0 .4rem; font-size: var(--fs-sm); color: var(--grey-600); line-height: 1.5; }
.dl-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; font-size: var(--fs-xs); color: var(--grey-500); }
.dl-badge {
  font-weight: 700; letter-spacing: .04em; color: var(--cyan-500);
  background: rgba(37,211,148,.12); padding: 2px 7px; border-radius: 4px;
}
.dl-row .btn-download { flex: 0 0 auto; }
@media (max-width: 560px) {
  .dl-row { flex-wrap: wrap; }
  .dl-row .btn-download { width: 100%; justify-content: center; }
}

/* Inside a panel the rows are edge-to-edge dividers, not floating cards. */
.portal-panel .dl-list { gap: 0; }
.portal-panel .dl-row {
  border: 0; border-bottom: 1px solid var(--border);
  border-radius: 0; box-shadow: none;
}
.portal-panel .dl-row:last-child { border-bottom: 0; }
.portal-panel .dl-row:hover { background: var(--grey-50); box-shadow: none; }

/* ---- Ticket attachments ----------------------------------------- */
.attachments { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.attachment {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .4rem .7rem; max-width: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--fs-xs); color: var(--ink); text-decoration: none;
  transition: border-color var(--transition), color var(--transition);
}
.attachment:hover { border-color: var(--teal-500); color: var(--teal-600); }
.attachment__icon { display: grid; place-items: center; color: var(--cyan-500); flex: 0 0 auto; }
.attachment:hover .attachment__icon { color: var(--teal-600); }
.attachment__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; font-weight: 600; }
.attachment__size { color: var(--grey-500); flex: 0 0 auto; }

/* Pagination */
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: var(--sp-6) 0 0; justify-content: center; }
.pagination a, .pagination span { display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid rgba(24,17,68,.08); border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--ink); background: var(--gloss-light); transition: all var(--transition); }
.pagination a, .pagination span { box-shadow: var(--shadow-xs); }
.pagination a:hover { color: var(--teal-500); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pagination .active span { background: var(--teal-500); color: #fff; border-color: var(--teal-500); }
