/* Internal Support Portal — production form styles (Option 3: Smart Stepper) */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #101921;
  --muted: #64748b;
  --muted-2: #94a3b8;
  /* Profit Builders brand */
  --primary: #005ee8;
  --primary-hover: #0049b8;
  --primary-weak: #e9f1fe;
  --primary-ring: #b3d0fb;
  --success: #16a34a;
  --danger: #dc2626;
  --danger-weak: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.page { max-width: 680px; margin: 0 auto; padding: 40px 20px 80px; }

.brandbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.brandbar .logo { height: 32px; width: auto; display: block; }
.brandbar .brand-sep {
  color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding-left: 12px; border-left: 1px solid var(--border);
}
h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 6px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 28px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 28px;
}

/* Progress */
.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps .s { flex: 1; height: 6px; border-radius: 999px; background: var(--border); transition: background .2s; }
.steps .s.done, .steps .s.active { background: var(--primary); }
.steplabel { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; margin-bottom: 6px; }
.stepq { font-size: 20px; font-weight: 650; margin: 0 0 18px; letter-spacing: -.01em; }
.stage { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateX(6px); } to { opacity: 1; transform: none; } }

/* Option list */
.search { margin-bottom: 12px; }
.optlist { display: flex; flex-direction: column; gap: 8px; }
.opt {
  text-align: left; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 14px 16px; cursor: pointer; display: flex;
  align-items: center; gap: 12px; transition: border-color .15s, box-shadow .15s, background .15s;
  font: inherit; color: inherit; width: 100%;
}
.opt:hover { border-color: var(--primary); background: var(--primary-weak); }
.opt:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.opt > span { min-width: 0; }
.opt .ic { flex: none; color: var(--primary); display: flex; }
.opt .lbl { display: block; font-weight: 600; font-size: 15px; }
.opt .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 1px; line-height: 1.45; }
.opt .chev { margin-left: auto; color: var(--muted-2); flex: none; }
.empty { color: var(--muted); font-size: 14px; padding: 12px 2px; }

/* Inputs */
.field { margin-bottom: 22px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 7px; }
.req { color: var(--danger); margin-left: 2px; }
.help { color: var(--muted); font-size: 13px; margin-top: 6px; }
.input, .textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 46px; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 120px; resize: vertical; }
.input:hover, .textarea:hover { border-color: var(--muted-2); }
.input:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.fielderror { color: var(--danger); font-size: 13px; margin-top: 6px; display: none; }
.fielderror.show { display: block; }

/* Priority selector (maps to hs_ticket_priority) */
.prio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.prio {
  flex: 1 1 0; min-width: 72px; padding: 11px 12px; cursor: pointer; text-align: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.prio:hover { border-color: var(--primary); }
.prio.sel { border-color: var(--primary); background: var(--primary-weak); box-shadow: 0 0 0 3px var(--primary-ring); }
.prio.prio-high.sel { border-color: #d97706; background: #fffbeb; box-shadow: 0 0 0 3px #fde68a; }
.prio.prio-urgent.sel { border-color: var(--danger); background: var(--danger-weak); box-shadow: 0 0 0 3px #fecaca; }

/* ---- Portal: tabs ---- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 9px 16px; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; font: inherit; font-weight: 600; font-size: 14px; color: var(--muted);
  cursor: pointer; transition: border-color .12s, color .12s, background .12s;
}
.tab:hover { border-color: var(--primary); color: var(--text); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- My Tickets list ---- */
.tix-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tix-head .stepq { margin: 0; }
.tix { display: flex; flex-direction: column; gap: 10px; }
.tixrow {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font: inherit; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.tixrow:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.tix-main { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.tix-subj { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tix-meta { color: var(--muted); font-size: 13px; }
.tixrow .chev { color: var(--muted-2); flex-shrink: 0; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge-open { background: var(--primary-weak); color: var(--primary-hover); }
.badge-closed { background: #f1f5f9; color: var(--muted); }

/* ---- Ticket detail thread ---- */
.thread { display: flex; flex-direction: column; gap: 12px; margin: 10px 0 20px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.msg { max-width: 85%; padding: 10px 13px; border-radius: 12px; font-size: 14px; }
.msg .msg-hd { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg .msg-body { line-height: 1.45; overflow-wrap: anywhere; }
.msg.theirs { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.mine { align-self: flex-end; background: var(--primary-weak); border: 1px solid var(--primary-ring); border-bottom-right-radius: 4px; }

/* ---- Attachments (drop/paste zone, picker previews + in-thread rendering) ---- */
.att-zone {
  display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 18px 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.att-zone:hover, .att-zone:focus { outline: none; border-color: var(--primary); color: var(--text); }
.att-zone.drag { border-color: var(--primary); background: var(--primary-weak); color: var(--primary-hover); }
.att-zone-ico { font-size: 18px; }
.att-zone-text { font-size: 14px; font-weight: 500; }
.att-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.att-thumb-wrap { position: relative; display: inline-block; }
.att-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.att-x {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; line-height: 18px; text-align: center;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 0;
}
.att-x:hover { color: var(--danger); border-color: var(--danger); }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 6px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: 13px;
  color: var(--text); text-decoration: none; position: relative;
}
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-img { max-width: 240px; max-height: 200px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; cursor: pointer; }

/* Review summary */
.review { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 18px; }
.review .row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 14px; }
.review .row .k { color: var(--muted); }
.review .row .v { font-weight: 600; text-align: right; }

/* Buttons */
.nav { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  padding: 12px 20px; min-height: 46px; border: 1px solid transparent;
  transition: background .15s, transform .08s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--border-strong); cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }

/* Feedback */
.banner { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: none; }
.banner.show { display: block; }
.banner.error { background: var(--danger-weak); border: 1px solid #fecaca; color: #991b1b; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.success { text-align: center; padding: 24px 12px; }
.success .check { width: 56px; height: 56px; border-radius: 50%; background: #dcfce7; color: var(--success); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.success h2 { margin: 0 0 6px; font-size: 20px; }
.success p { color: var(--muted); margin: 0 0 20px; }

.loading { color: var(--muted); padding: 20px 2px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
