@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700;800&family=Mulish:wght@400;500;600;700;800&display=swap");

* { box-sizing: border-box; }

:root {
  --ink: #16273F;
  --body: #5B6675;
  --muted: #8791A0;
  --muted3: #98A2B0;
  --card-border: #EAEDF3;
  --panel-border: #E7EBF1;
  --btn-border: #E4E8EF;
  --input-bg: #F6F8FC;
  --input-border: #E4E9F1;
  --red: #E8402A;
  --red-hover: #D5361F;
  --link: #2F6FE0;
}

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: "Mulish", system-ui, sans-serif;
  color: var(--body);
  background: linear-gradient(180deg, #F5F3FB 0%, #F1F6F6 100%);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
input::placeholder, textarea::placeholder { color: #A2ABBA; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
body.auth-pending .app-shell { display: none; }

.app-shell .rm-header-inner,
.app-shell .rm-footer-inner { max-width: 90%; }

@keyframes spFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spModalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ------------------------------- Hero ------------------------------- */
.sp-hero-inner { max-width: 90%; margin: 0 auto; padding: 32px 32px 8px; }
.sp-title {
  font-family: "Lexend", sans-serif;
  font-weight: 700;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 0 0 6px;
}
.sp-subtitle { font-size: 15.5px; color: var(--muted); margin: 0; }

/* ------------------------------- Tabs ------------------------------- */
.sp-tabs {
  background: #fff;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 1px 2px rgba(18, 38, 63, 0.03);
  margin-top: 14px;
}
.sp-tabs-inner { max-width: 90%; margin: 0 auto; padding: 0 32px; display: flex; gap: 8px; }
.sp-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: "Lexend", sans-serif;
  font-weight: 600;
  font-size: 15.5px;
  color: var(--muted);
  padding: 16px 18px;
  margin: 0 0 -1px;
}
.sp-tab.active { font-weight: 700; color: var(--ink); border-bottom-color: var(--red); }
.sp-tab:focus-visible { outline: 2px solid var(--link); outline-offset: -4px; border-radius: 6px; }

/* ------------------------------- Main ------------------------------- */
.sp-main { flex: 1; max-width: 90%; width: 100%; margin: 0 auto; padding: 28px 32px 56px; }
.sp-view { animation: spFadeUp 0.3s ease both; }

/* ------------------------------- Tickets: toolbar ------------------------------- */
.sp-tickets-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.sp-filters {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 1px 2px rgba(18, 38, 63, 0.05);
}
.sp-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  background: transparent;
  border: none;
  border-radius: 9px;
  font-family: "Lexend", sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--body);
  padding: 9px 17px;
}
.sp-filter.active { color: #fff; background: var(--ink); }
.sp-filter-count { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 11px; color: var(--muted3); background: #EEF1F6; border-radius: 6px; padding: 1px 7px; }
.sp-filter.active .sp-filter-count { color: #CBD8EA; background: rgba(255, 255, 255, 0.14); }
.sp-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--red);
  border: none;
  color: #fff;
  font-family: "Lexend", sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 13px 22px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(232, 64, 42, 0.28);
}
.sp-new-btn svg { stroke: #fff; }
.sp-new-btn:hover { background: var(--red-hover); }

/* ------------------------------- Ticket cards ------------------------------- */
.sp-ticket-list { display: flex; flex-direction: column; gap: 14px; }
.sp-ticket {
  background: #fff;
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--muted3);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.sp-ticket-main { flex: 1; min-width: 260px; }
.sp-ticket-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-ticket-id { font-family: "Lexend", sans-serif; font-weight: 800; font-size: 12.5px; color: #B7C0CE; }
.sp-ticket-subject { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 16.5px; color: var(--ink); margin: 8px 0 0; letter-spacing: -0.2px; }
.sp-ticket-meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.sp-product-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Mulish", sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: #3B5678;
  background: #EEF2FA;
  border-radius: 7px;
  padding: 4px 10px;
}
.sp-ticket-side { display: flex; align-items: center; gap: 20px; }
.sp-ticket-updated { text-align: right; }
.sp-ticket-updated-label { font-size: 12px; color: var(--muted3); }
.sp-ticket-updated-val { font-family: "Lexend", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--body); margin-top: 2px; }
.sp-view-btn {
  font-family: "Lexend", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  padding: 10px 20px;
}
.sp-view-btn:hover { border-color: #3C7CE0; color: #3C7CE0; }

/* status & priority badges */
.sp-badge { display: inline-block; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 11.5px; border-radius: 999px; padding: 3px 12px; border: 1px solid; }
.sp-st-open { color: #2F6FE0; background: #EAF1FC; border-color: #D4E2F8; }
.sp-st-progress { color: #B5772E; background: #FCF6E4; border-color: #F0E4B8; }
.sp-st-awaiting { color: #6A45C9; background: #F1EEFC; border-color: #DDD1F5; }
.sp-st-resolved { color: #1F8A5B; background: #E7F7F1; border-color: #C9EBDD; }
.sp-st-closed { color: #5B6675; background: #EEF1F6; border-color: #DDE3EC; }
.sp-ac-open { border-left-color: #2F6FE0; }
.sp-ac-progress { border-left-color: #E0A21E; }
.sp-ac-awaiting { border-left-color: #7A5AF0; }
.sp-ac-resolved { border-left-color: #28B36B; }
.sp-ac-closed { border-left-color: #98A2B0; }
.sp-prio-high { color: #C0392B; background: #FCECEC; border-color: #F3D3D3; }
.sp-prio-medium { color: #B5772E; background: #FCF6E4; border-color: #F0E4B8; }
.sp-prio-low { color: #5B6675; background: #EEF1F6; border-color: #DDE3EC; }

/* empty state */
.sp-empty { background: #fff; border: 1px dashed #D5DDE8; border-radius: 18px; padding: 52px; text-align: center; }
.sp-empty-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.sp-empty-sub { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* ------------------------------- Contact ------------------------------- */
.sp-contact-grid { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
.sp-contact-methods { display: flex; flex-direction: column; gap: 16px; }
.sp-method {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  text-align: left;
  width: 100%;
}
.sp-method-icon { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sp-method-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.sp-method-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.sp-method-value { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 15px; margin-top: 10px; }
button.sp-method { cursor: pointer; }
button.sp-method:hover { border-color: #C7D0DE; }

.sp-online { background: #EAF7F1; border: 1px solid #C9EBDD; border-radius: 16px; padding: 20px 22px; }
.sp-online-head { display: flex; align-items: center; gap: 10px; }
.sp-online-dot { width: 9px; height: 9px; border-radius: 50%; background: #28B36B; box-shadow: 0 0 0 4px rgba(40, 179, 107, 0.18); }
.sp-online-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 14px; color: #1F7A50; }
.sp-online-sub { font-size: 13px; color: #5F9B7E; margin-top: 8px; line-height: 1.5; }

/* message form */
.sp-form-card { background: #fff; border: 1px solid var(--card-border); border-radius: 18px; box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05); padding: 28px; }
.sp-form-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 20px; color: var(--ink); margin: 0 0 4px; }
.sp-form-sub { font-size: 13.5px; color: var(--muted); margin: 0 0 22px; }
.sp-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sp-form-field { margin-top: 16px; }
.sp-form-field:first-child, .sp-form-row .sp-form-field { margin-top: 0; }
.sp-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; flex-wrap: wrap; }
.sp-form-note { font-size: 12.5px; color: var(--muted3); }
.sp-form-note a { font-weight: 600; }
.sp-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--red);
  border: none;
  color: #fff;
  font-family: "Lexend", sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(232, 64, 42, 0.28);
}
.sp-send-btn svg { stroke: #fff; }
.sp-send-btn:hover { background: var(--red-hover); }
.sp-sent-note { display: inline-flex; align-items: center; gap: 7px; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 13px; color: #1F8A5B; }

/* ------------------------------- Shared form controls ------------------------------- */
.sp-label { display: block; font-family: "Lexend", sans-serif; font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 8px; }
.sp-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  font-family: "Mulish", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1.6px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.sp-textarea { height: 140px; resize: vertical; padding: 14px 16px; line-height: 1.6; }
.sp-input:focus { border-color: var(--link); box-shadow: 0 0 0 4px rgba(47, 111, 224, 0.12); background: #fff; }
.sp-select-wrap { position: relative; }
.sp-select {
  width: 100%;
  height: 50px;
  padding: 0 40px 0 16px;
  font-family: "Mulish", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1.6px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  appearance: none;
  cursor: pointer;
}
.sp-select:focus { border-color: var(--link); box-shadow: 0 0 0 4px rgba(47, 111, 224, 0.12); background: #fff; }
.sp-select-caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; display: flex; }

/* ------------------------------- Modal ------------------------------- */
.sp-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 50px 20px; overflow-y: auto; }
.sp-modal-backdrop { position: fixed; inset: 0; background: rgba(16, 26, 40, 0.5); }
.sp-modal-panel {
  position: relative;
  width: 100%;
  max-width: 600px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 80px -18px rgba(16, 26, 40, 0.5);
  overflow: hidden;
  animation: spModalIn 0.28s cubic-bezier(.22,.61,.36,1) both;
}
.sp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 28px; border-bottom: 1px solid #EEF1F6; }
.sp-modal-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 21px; color: var(--ink); margin: 0; }
.sp-modal-sub { font-size: 13.5px; color: var(--muted); margin: 3px 0 0; }
.sp-modal-close { width: 40px; height: 40px; border-radius: 12px; background: #F4F6FA; border: 1px solid var(--btn-border); color: var(--body); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sp-modal-close:hover { background: #EBEFF5; }
.sp-modal-body { padding: 24px 28px; display: flex; flex-direction: column; gap: 18px; }
.sp-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sp-prio-row { display: flex; gap: 9px; flex-wrap: wrap; }
.sp-prio {
  font-family: "Lexend", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--body);
  background: #fff;
  border: 1.6px solid var(--input-border);
  border-radius: 999px;
  padding: 9px 20px;
}
.sp-prio.active { color: #fff; background: var(--ink); border-color: var(--ink); }
.sp-modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 18px 28px; border-top: 1px solid #EEF1F6; background: #FBFCFE; }
.sp-btn-ghost { font-family: "Lexend", sans-serif; font-weight: 600; font-size: 14.5px; color: var(--body); background: #fff; border: 1px solid var(--btn-border); border-radius: 11px; padding: 11px 22px; }
.sp-btn-ghost:hover { border-color: #C7D0DE; }
.sp-btn-primary { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 14.5px; color: #fff; background: var(--red); border: none; border-radius: 11px; padding: 11px 24px; box-shadow: 0 6px 16px rgba(232, 64, 42, 0.28); }
.sp-btn-primary:hover { background: var(--red-hover); }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 900px) {
  .sp-contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .sp-form-row, .sp-field-row { grid-template-columns: 1fr; }
  .sp-ticket-side { width: 100%; justify-content: space-between; }
  .sp-hero-inner, .sp-tabs-inner, .sp-main { padding-left: 20px; padding-right: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-view, .sp-modal-panel { animation: none; }
}

/* ============================ Ticket detail (wired) ============================ */
.sp-back {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer;
  font-family: "Poppins", sans-serif; font-weight: 600; font-size: 13.5px; color: #3B5678; padding: 0; margin-bottom: 16px;
}
.sp-back:hover { color: #16273F; }
.sp-detail {
  background: #fff; border: 1px solid #E7EBF1; border-radius: 16px; box-shadow: 0 4px 16px rgba(18,38,63,0.05); padding: 26px 28px;
}
.sp-detail-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sp-detail-subject { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 22px; color: #16273F; margin: 0 0 12px; }
.sp-detail-author { font-size: 13px; color: #8791A0; }
.sp-detail-desc { margin-top: 16px; background: #F7F9FC; border: 1px solid #E7EBF1; border-radius: 12px; padding: 14px 16px; font-size: 14.5px; line-height: 1.6; color: #33404F; white-space: pre-wrap; }
.sp-detail-feature { margin-top: 10px; font-size: 13px; color: #8791A0; }
.sp-reply-count { font-size: 12.5px; color: #8791A0; font-weight: 600; }

.sp-thread-head { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 15px; color: #16273F; margin: 24px 0 12px; }
.sp-thread { display: flex; flex-direction: column; gap: 12px; }
.sp-thread-empty { font-size: 13.5px; color: #8791A0; }
.sp-reply { background: #F7F9FC; border: 1px solid #EAEEF4; border-radius: 12px; padding: 12px 14px; }
.sp-reply-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.sp-reply-author { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13.5px; color: #16273F; }
.sp-reply-time { font-size: 12px; color: #8791A0; }
.sp-reply-body { font-size: 14px; line-height: 1.55; color: #33404F; white-space: pre-wrap; }

.sp-reply-form { margin-top: 20px; }
.sp-detail-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.sp-btn-secondary {
  font-family: "Poppins", sans-serif; font-weight: 600; font-size: 13.5px; color: #16273F;
  background: #fff; border: 1.5px solid #DCE1E9; border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
.sp-btn-secondary:hover { border-color: #16273F; }
.sp-reply-note { font-size: 12.5px; color: #8791A0; margin-top: 8px; }
