/**
 * Advanced Ticketing — frontend
 */

.wts-app {
  --wts-primary: #2563eb;
  --wts-secondary: #0f766e;
  --wts-dark: #0f172a;
  --wts-muted: #64748b;
  --wts-bg: #f8fafc;
  --wts-card: #fff;
  --wts-border: #e2e8f0;
  --wts-radius: 12px;
  --wts-font: inherit;
  --wts-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  font-family: var(--wts-font);
  color: var(--wts-dark);
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 180px);
  width: 100%;
  max-width: 100%;
  background: var(--wts-bg);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--wts-border);
  box-sizing: border-box;
}

.wts-app[data-theme="dark"] {
  --wts-bg: #0f172a;
  --wts-card: #1e293b;
  --wts-dark: #e2e8f0;
  --wts-muted: #94a3b8;
  --wts-border: #334155;
}

@media (prefers-color-scheme: dark) {
  .wts-app[data-theme="auto"] {
    --wts-bg: #0f172a;
    --wts-card: #1e293b;
    --wts-dark: #e2e8f0;
    --wts-muted: #94a3b8;
    --wts-border: #334155;
  }
}

.wts-app.is-auth {
  display: block;
  background: transparent;
  border: 0;
  box-shadow: none;
  min-height: 0;
  overflow: visible;
  color: #0f172a;
}

.wts-app.is-auth .wts-main,
.wts-app.is-auth .wts-content {
  display: block;
  padding: 0;
  background: transparent;
}

.wts-sidebar {
  background: var(--wts-card);
  border-inline-end: 1px solid var(--wts-border);
  padding: 24px 16px;
}

.wts-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-weight: 700;
}

.wts-brand img {
  max-height: 36px;
}

.wts-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wts-sidebar a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--wts-dark);
  text-decoration: none;
}

.wts-sidebar a.is-active,
.wts-sidebar a:hover {
  background: color-mix(in srgb, var(--wts-primary) 10%, transparent);
  color: var(--wts-primary);
}

.wts-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wts-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--wts-card);
  border-bottom: 1px solid var(--wts-border);
}

.wts-search-wrap {
  flex: 1;
  position: relative;
}

.wts-search-wrap input,
.wts-field input,
.wts-field textarea,
.wts-field select,
.wts-toolbar input,
.wts-toolbar select {
  width: 100%;
  border: 1px solid var(--wts-border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: var(--wts-card);
  color: var(--wts-dark);
}

#wts-search-results {
  position: absolute;
  inset-inline-start: 0;
  right: 0;
  top: 110%;
  background: var(--wts-card);
  border: 1px solid var(--wts-border);
  border-radius: 12px;
  box-shadow: var(--wts-shadow);
  z-index: 20;
  padding: 8px;
}

#wts-search-results a {
  display: block;
  padding: 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--wts-dark);
}

.wts-content {
  padding: 24px;
}

.wts-page-head,
.wts-ticket-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.wts-page-head h1,
.wts-ticket-head h1,
.wts-auth h1 {
  margin: 0;
  font-size: 28px;
}

.wts-kicker {
  margin: 0;
  color: var(--wts-muted);
  font-weight: 700;
}

.wts-btn,
.wts-app button.wts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--wts-primary);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.wts-btn.is-ghost {
  background: transparent;
  color: var(--wts-primary);
  border: 1px solid var(--wts-border);
}

.wts-btn:disabled {
  opacity: 0.6;
}

.wts-stats,
.wts-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.wts-stat,
.wts-box,
.wts-side-card {
  background: var(--wts-card);
  border: 1px solid var(--wts-border);
  border-radius: var(--wts-radius);
  padding: 18px;
  box-shadow: var(--wts-shadow);
}

.wts-stat span,
.wts-side-card span {
  color: var(--wts-muted);
  display: block;
}

.wts-stat strong {
  font-size: 28px;
}

.wts-table-wrap {
  overflow: auto;
}

.wts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--wts-card);
  border-radius: var(--wts-radius);
}

.wts-table th,
.wts-table td {
  padding: 12px;
  border-bottom: 1px solid var(--wts-border);
  text-align: start;
}

.wts-pill,
.wts-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.wts-form .wts-field {
  margin-bottom: 14px;
}

.wts-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.wts-field span {
  color: #dc2626;
}

.wts-field small {
  display: block;
  color: var(--wts-muted);
  margin-bottom: 6px;
}

.wts-inline {
  display: inline-flex;
  gap: 6px;
  margin-inline-end: 12px;
  font-weight: 500;
}

.wts-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.wts-status {
  display: block;
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 13px;
  font-weight: 600;
}

.wts-status.is-error {
  color: #dc2626;
}

.wts-status.is-ok {
  color: #00A676;
}

.wts-ticket-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
}

.wts-bubble {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.wts-bubble img,
.wts-profile-card img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.wts-bubble > div {
  background: var(--wts-card);
  border: 1px solid var(--wts-border);
  border-radius: 16px;
  padding: 12px 14px;
  flex: 1;
}

.wts-bubble.is-staff > div {
  background: color-mix(in srgb, var(--wts-secondary) 10%, var(--wts-card));
}

.wts-bubble.is-internal > div {
  background: #fff7ed;
  border-style: dashed;
}

.wts-bubble header {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.wts-bubble time,
.wts-notes small {
  color: var(--wts-muted);
  font-size: 12px;
}

.wts-editor-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.wts-editor-bar button {
  border: 1px solid var(--wts-border);
  background: var(--wts-card);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.wts-editor {
  min-height: 120px;
  border: 1px solid var(--wts-border);
  border-radius: 12px;
  padding: 12px;
  background: var(--wts-card);
}

.wts-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.wts-att-img img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.wts-side-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wts-side-card li {
  margin-bottom: 12px;
}

.wts-auth {
  display: flex;
  justify-content: center;
  padding: 8px 0 16px;
}

.wts-auth .wts-box {
  width: min(440px, 100%);
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

.wts-auth .wts-kicker {
  color: var(--wts-primary, #2563eb);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.wts-app.is-auth .wts-auth h1,
.wts-app.is-auth .wts-auth h2,
.wts-auth h1,
.wts-auth h2 {
  color: #0f172a !important;
  margin: 0 0 8px;
  line-height: 1.25;
}

.wts-auth h1 {
  font-size: 28px;
}

.wts-auth h2 {
  font-size: 18px;
}

.wts-auth-lead,
.wts-auth .wts-switch,
.wts-auth label,
.wts-auth .wts-inline {
  color: #475569;
}

.wts-auth-lead {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
}

.wts-auth .wts-field label {
  color: #0f172a;
}

.wts-auth .wts-field input {
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.wts-auth .wts-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--wts-primary, #2563eb) 35%, transparent);
  border-color: var(--wts-primary, #2563eb);
}

.wts-auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
  flex-wrap: wrap;
}

.wts-forgot-toggle {
  border: 0;
  background: none;
  padding: 0;
  color: var(--wts-primary, #2563eb);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.wts-auth .wts-btn {
  width: 100%;
}

.wts-auth .wts-form-actions {
  flex-direction: column;
  align-items: stretch;
}

.wts-lost-form {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.wts-lost-form[hidden] {
  display: none !important;
}

.wts-auth .wts-switch {
  text-align: center;
  margin: 20px 0 0;
}

.wts-auth .wts-switch a {
  color: var(--wts-primary, #2563eb);
  font-weight: 700;
  text-decoration: none;
}

.wts-profile {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

.wts-empty,
.wts-alert {
  padding: 20px;
  background: var(--wts-card);
  border-radius: var(--wts-radius);
  border: 1px dashed var(--wts-border);
  color: var(--wts-muted);
}

.wts-alert.is-success {
  border-style: solid;
  color: #00A676;
}

.wts-notes {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wts-notes li {
  padding: 10px 0;
  border-bottom: 1px solid var(--wts-border);
}

.wts-notes .is-unread {
  font-weight: 700;
}

.wts-bell,
.wts-theme-toggle,
.wts-nav-toggle {
  border: 1px solid var(--wts-border);
  background: var(--wts-card);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  position: relative;
}

.wts-counter {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 6px;
}

.wts-stars label {
  font-size: 28px;
  cursor: pointer;
  color: #d1d5db;
}

.wts-stars input {
  display: none;
}

.wts-stars input:checked + span,
.wts-stars label:has(input:checked) {
  color: #f59e0b;
}

.wts-pager {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

.wts-pager a {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--wts-border);
  text-decoration: none;
}

.wts-pager .is-active {
  background: var(--wts-primary);
  color: #fff;
}

.wts-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.wts-nav-toggle {
  display: none;
}

@media (max-width: 900px) {
  .wts-app {
    grid-template-columns: 1fr;
  }
  .wts-sidebar {
    display: none;
  }
  .wts-app.is-nav-open .wts-sidebar {
    display: block;
  }
  .wts-nav-toggle {
    display: inline-flex;
  }
  .wts-stats,
  .wts-ticket-grid,
  .wts-profile {
    grid-template-columns: 1fr;
  }
  .wts-page-head,
  .wts-ticket-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

.wts-widget {
  position: fixed;
  inset-inline-end: 20px;
  bottom: 20px;
  z-index: 99999;
  font-family: var(--wts-font, inherit);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.wts-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  background: var(--wts-primary, #2563eb);
  color: #fff;
  border-radius: 999px;
  padding: 12px 18px 12px 14px;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
}

.wts-launcher-icon {
  font-size: 18px;
}

.wts-widget-panel {
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 110px));
  background: #fff;
  color: #0f172a;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  padding: 0;
  border: 1px solid #e2e8f0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.wts-widget.is-open .wts-widget-panel {
  display: flex;
}

.wts-widget-panel[hidden] {
  display: none !important;
}

.wts-widget-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 14px 12px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.wts-widget-head > div {
  min-width: 0;
  flex: 1;
}

.wts-widget-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--wts-primary, #2563eb);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wts-widget-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wts-widget-close,
.wts-widget-back {
  border: 0;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.wts-widget-back[hidden] {
  display: none;
}

.wts-widget-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.wts-widget-screen {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.wts-widget-screen.is-active {
  display: block;
}

.wts-widget-screen.is-active[data-screen="chat"] {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.wts-widget-screen[hidden] {
  display: none !important;
}

.wts-widget-intro,
.wts-widget-muted {
  color: #64748b;
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
}

.wts-widget-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wts-widget-btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  color: #0f172a;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  box-sizing: border-box;
}

.wts-widget-btn[hidden],
.wts-guest-only[hidden],
.wts-auth-only[hidden] {
  display: none !important;
}

.wts-widget-btn.is-primary {
  background: var(--wts-primary, #2563eb);
  border-color: transparent;
  color: #fff;
}

.wts-widget-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.wts-widget-link {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 0;
  background: none;
  color: var(--wts-primary, #2563eb);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.wts-widget-form .wts-field {
  margin-bottom: 12px;
}

.wts-widget-form .wts-field input,
.wts-widget-form .wts-field textarea,
.wts-widget-form .wts-field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
}

.wts-widget-form .wts-form-actions {
  flex-wrap: wrap;
}

.wts-widget-ticket {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: start;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.wts-widget-ticket strong {
  font-size: 12px;
  color: var(--wts-primary, #2563eb);
}

.wts-widget-ticket span {
  font-weight: 600;
}

.wts-widget-ticket em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.wts-chat-thread {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  background: #f8fafc;
}

.wts-chat-msg {
  max-width: 86%;
  margin-bottom: 12px;
}

.wts-chat-msg.is-me {
  margin-inline-start: auto;
}

.wts-chat-meta {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}

.wts-chat-msg.is-me .wts-chat-meta {
  text-align: end;
}

.wts-chat-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px 14px 14px 4px;
  padding: 8px 11px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.wts-chat-msg.is-me .wts-chat-bubble {
  background: var(--wts-primary, #2563eb);
  border-color: transparent;
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.wts-chat-msg.is-staff .wts-chat-bubble {
  background: #eef6ff;
  border-color: #dbeafe;
}

.wts-chat-bubble p {
  margin: 0 0 6px;
}

.wts-chat-bubble p:last-child {
  margin: 0;
}

.wts-chat-files {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wts-chat-file {
  color: inherit;
  font-size: 12px;
  font-weight: 700;
}

.wts-chat-file img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
}

.wts-chat-composer {
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px 12px;
  background: #fff;
}

.wts-chat-composer textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  resize: none;
}

.wts-chat-composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.wts-chat-composer-bar .wts-widget-btn {
  width: auto;
  margin-inline-start: auto;
  padding: 8px 16px;
}

.wts-chat-attach {
  position: relative;
  font-size: 13px;
  font-weight: 700;
  color: var(--wts-primary, #2563eb);
  cursor: pointer;
  margin: 0;
}

.wts-chat-attach input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.wts-chat-closed {
  margin: 0;
  padding: 12px 14px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  border-top: 1px solid #e2e8f0;
}

.wts-chat-closed[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .wts-launcher-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .wts-launcher {
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
  }
  .wts-widget {
    inset-inline-end: 12px;
    bottom: 12px;
  }
  .wts-widget-panel {
    width: min(380px, calc(100vw - 24px));
    height: min(560px, calc(100vh - 88px));
  }
}

body.wts-portal {
  overflow-x: hidden;
}

body.wts-portal .section:has(.wts-app),
body.wts-portal .elementor-section:has(.wts-app),
body.wts-portal .elementor-widget:has(.wts-app) {
  padding: 16px 24px 32px !important;
  margin: 0 !important;
}

body.wts-portal .container:has(.wts-app),
body.wts-portal .entry-content:has(.wts-app),
body.wts-portal .elementor-widget-container:has(.wts-app),
body.wts-portal .elementor-container:has(.wts-app) {
  max-width: none !important;
  width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.wts-portal .wts-app {
  width: 100%;
  max-width: none;
  margin: 0;
  border-radius: 16px;
  border: 1px solid var(--wts-border);
}

body.wts-portal .wts-app.is-auth {
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.wts-portal:has(.wts-app.is-auth) .section:has(.wts-app),
body.wts-portal:has(.wts-app.is-auth) .elementor-section:has(.wts-app),
body.wts-portal:has(.wts-app.is-auth) .elementor-widget:has(.wts-app) {
  padding: 48px 24px 64px !important;
}

@media (max-width: 640px) {
  body.wts-portal .section:has(.wts-app),
  body.wts-portal .elementor-section:has(.wts-app),
  body.wts-portal .elementor-widget:has(.wts-app) {
    padding: 12px 16px 24px !important;
  }

  body.wts-portal:has(.wts-app.is-auth) .section:has(.wts-app),
  body.wts-portal:has(.wts-app.is-auth) .elementor-section:has(.wts-app),
  body.wts-portal:has(.wts-app.is-auth) .elementor-widget:has(.wts-app) {
    padding: 28px 16px 40px !important;
  }
}
