/* ══════════════════════════════════════════════════
   tickets.css — NovaSounds Tickets Page Styles
══════════════════════════════════════════════════ */

/* ── Page layout ─────────────────────────────── */
.tickets-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 24px 72px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Page header ─────────────────────────────── */
.tk-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.tk-page-title {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem; font-weight: 700;
  color: var(--ink); margin: 0 0 6px;
}
html.light-theme .tk-page-title { color: #1a1610; }
.tk-page-sub { font-size: 13px; color: var(--ink3); line-height: 1.6; max-width: 480px; margin: 0; }

/* ── Stats strip ─────────────────────────────── */
.tk-stats-strip {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.tk-stat-cell {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 18px 12px; gap: 4px;
}
.tk-stat-num {
  font-family: 'Cinzel', serif; font-size: 1.4rem; font-weight: 700;
  color: var(--ink); line-height: 1;
}
html.light-theme .tk-stat-num { color: #1a1610; }
.tk-stat-lbl {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--ink3);
}
.tk-stat-sep { width: 1px; background: var(--border); }

/* ── Filter bar ──────────────────────────────── */
.tk-filter-bar {
  display: flex; gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tk-filter-bar::-webkit-scrollbar { display: none; }
.tk-filter-btn {
  padding: 8px 18px; background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--ink3); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  font-family: 'DM Sans', sans-serif; white-space: nowrap;
}
.tk-filter-btn:hover { color: var(--ink); }
.tk-filter-btn.active { color: var(--ink); border-bottom-color: var(--gold); }

/* ── Ticket card ─────────────────────────────── */
.tk-list { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

.tk-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex; align-items: center; gap: 18px;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none; color: inherit;
}
.tk-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}
.tk-card.tk-card-resolved { opacity: 0.6; }
.tk-card.tk-card-resolved:hover { opacity: 1; }

.tk-card-left { flex: 1; min-width: 0; }

.tk-card-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--ink3); margin-bottom: 5px;
}
.tk-card-title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 6px;
}
html.light-theme .tk-card-title { color: #1a1610; }
.tk-card-meta { font-size: 12px; color: var(--ink3); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-card-lead { color: var(--teal, #2eb8a4); font-weight: 500; }
.tk-card-unread {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); flex-shrink: 0;
}

.tk-card-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0;
}
.tk-card-time { font-size: 11px; color: var(--ink3); white-space: nowrap; }

/* ── Priority badges ─────────────────────────── */
.tk-priority-badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  white-space: nowrap;
}
.tk-priority-badge.critical { background: rgba(224,85,85,0.15); color: #e05555; border: 1px solid rgba(224,85,85,0.3); }
.tk-priority-badge.medium   { background: rgba(201,168,76,0.15); color: var(--gold); border: 1px solid rgba(201,168,76,0.3); }
.tk-priority-badge.low      { background: rgba(136,136,136,0.1); color: var(--ink3); border: 1px solid rgba(136,136,136,0.2); }

/* ── Status badges ───────────────────────────── */
.tk-status-badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
  white-space: nowrap;
}
.tk-status-badge.open       { background: rgba(201,168,76,0.12); color: var(--gold); border: 1px solid rgba(201,168,76,0.25); }
.tk-status-badge.inprogress { background: rgba(100,160,255,0.12); color: #78aaff;    border: 1px solid rgba(100,160,255,0.25); }
.tk-status-badge.resolved   { background: rgba(76,173,124,0.12); color: #4cad7c;     border: 1px solid rgba(76,173,124,0.25); }

/* ── Empty state ─────────────────────────────── */
.tk-empty {
  text-align: center; padding: 60px 24px;
  background: var(--card); border: 1px dashed var(--border);
  border-radius: 16px; color: var(--ink3);
}
.tk-empty-icon  { font-size: 2.5rem; margin-bottom: 12px; }
.tk-empty-title { font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
html.light-theme .tk-empty-title { color: #1a1610; }
.tk-empty-sub   { font-size: 13px; line-height: 1.6; max-width: 320px; margin: 0 auto 20px; }


/* ══════════════════════════════════════════════════
   CHAT VIEW
══════════════════════════════════════════════════ */

/* ── Chat header ─────────────────────────────── */
.tk-chat-header {
  display: flex; align-items: flex-start; gap: 16px;
  padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.tk-back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 13px;
  color: var(--ink2); font-size: 13px; cursor: pointer;
  transition: all 0.15s; white-space: nowrap; flex-shrink: 0;
  font-family: 'DM Sans', sans-serif;
}
.tk-back-btn:hover { border-color: var(--border2); color: var(--ink); }

.tk-chat-header-info { flex: 1; min-width: 0; }
.tk-chat-ticket-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--ink3); margin-bottom: 4px;
}
.tk-chat-title {
  font-size: 15px; font-weight: 700; color: var(--ink);
  margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html.light-theme .tk-chat-title { color: #1a1610; }
.tk-chat-meta-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.tk-chat-lead-tag { font-size: 12px; color: var(--teal, #2eb8a4); }

/* ── Rate nudge in header ────────────────────── */
/* Sits inline in the header, right-aligned, visible when lead is assigned + chat active */
.tk-header-rate-nudge {
  display: none; /* shown via JS */
  align-items: center; gap: 10px;
  background: linear-gradient(135deg, rgba(201,168,76,0.12), rgba(201,168,76,0.05));
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: 10px;
  padding: 8px 14px;
  flex-shrink: 0;
  animation: tkNudgePulse 3s ease-in-out infinite;
}
.tk-header-rate-nudge-text {
  display: flex; flex-direction: column; gap: 1px;
}
.tk-header-rate-nudge-title {
  font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap;
}
html.light-theme .tk-header-rate-nudge-title { color: #1a1610; }
.tk-header-rate-nudge-sub {
  font-size: 10.5px; color: var(--ink3); white-space: nowrap;
}
.tk-header-rate-nudge-btn {
  font-size: 11px !important; padding: 6px 13px !important; white-space: nowrap; flex-shrink: 0;
}
@keyframes tkNudgePulse {
  0%,100% { border-color: rgba(201,168,76,0.4); }
  50%      { border-color: rgba(201,168,76,0.75); box-shadow: 0 0 12px rgba(201,168,76,0.15); }
}

/* ── Messages ────────────────────────────────── */
.tk-chat-messages {
  flex: 1;
  min-height: 340px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.tk-msg { display: flex; flex-direction: column; max-width: 72%; }
.tk-msg.from-me     { align-self: flex-end; }
.tk-msg.from-lead   { align-self: flex-start; }
.tk-msg.from-system { align-self: center; max-width: 96%; }

.tk-bubble {
  padding: 11px 15px; border-radius: 16px;
  font-size: 13px; line-height: 1.6;
}
.from-me   .tk-bubble { background: var(--gold); color: #1a0e00; border-radius: 16px 16px 4px 16px; }
.from-lead .tk-bubble { background: var(--card); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; color: var(--ink); }
.from-system .tk-bubble {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 10px; color: var(--ink3); font-size: 12px; text-align: center;
}
html.light-theme .from-lead .tk-bubble   { color: #1a1610; background: #f3f0ea; border-color: #ddd; }
html.light-theme .from-system .tk-bubble { background: rgba(0,0,0,0.03); color: #777; border-color: #ddd; }

.tk-msg-meta { font-size: 10.5px; color: var(--ink3); margin-top: 4px; }
.from-me   .tk-msg-meta { text-align: right; }
.from-lead .tk-msg-meta { text-align: left; }
.from-system .tk-msg-meta { text-align: center; }

/* ── Chat input ──────────────────────────────── */
.tk-chat-input-wrap { padding-top: 4px; }
.tk-chat-input-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 8px 8px 14px;
  transition: border-color 0.15s;
}
.tk-chat-input-row:focus-within { border-color: var(--gold); }
.tk-chat-avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #b8892a);
  font-size: 10px; font-weight: 700; color: #1a0e00;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tk-chat-input {
  flex: 1; background: none; border: none;
  color: var(--ink); font-family: 'DM Sans', sans-serif; font-size: 13px;
}
.tk-chat-input::placeholder { color: var(--ink3); }
.tk-chat-input:focus { outline: none; }
.tk-send-btn {
  width: 36px; height: 36px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; flex-shrink: 0;
}

/* ── Resolved notice ─────────────────────────── */
.tk-resolved-notice {
  text-align: center; padding: 14px 20px;
  background: rgba(76,173,124,0.08);
  border: 1px dashed rgba(76,173,124,0.3);
  border-radius: 10px;
  font-size: 12px; color: var(--ink3); line-height: 1.6;
}
.tk-resolved-notice a { color: var(--gold); }


/* ══════════════════════════════════════════════════
   STRUCTURED SYSTEM BUBBLES
══════════════════════════════════════════════════ */
.sys-bubble {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  width: 100%;
}
.sys-bubble-user {
  background: rgba(46,184,164,0.07) !important;
  border: 1px solid rgba(46,184,164,0.25) !important;
  border-radius: 14px !important;
  padding: 16px 18px !important;
  width: 100% !important;
  box-sizing: border-box;
}
.sys-bubble-lead {
  background: rgba(201,168,76,0.07) !important;
  border: 1px solid rgba(201,168,76,0.28) !important;
  border-radius: 14px !important;
  padding: 16px 18px !important;
  width: 100% !important;
  box-sizing: border-box;
}
.from-system { max-width: 100% !important; align-self: stretch !important; }

.sys-msg-heading {
  font-size: 12.5px; font-weight: 700;
  color: var(--ink,#e8e0d0); margin-bottom: 12px;
}
.sys-detail-grid {
  display: flex; flex-direction: column; gap: 7px; margin-bottom: 2px;
}
.sys-detail-row {
  display: flex; align-items: baseline; gap: 10px;
}
.sys-dk {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink3,#888);
  white-space: nowrap; flex-shrink: 0;
}
.sys-dk::after { content: ':'; margin-right: 2px; }
.sys-dv {
  font-size: 13px; font-weight: 600;
  color: var(--ink,#e8e0d0); word-break: break-word;
}
.sys-issue-block {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sys-issue-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink3,#888); margin-bottom: 6px;
}
.sys-issue-text {
  font-size: 12.5px; color: var(--ink,#e8e0d0); line-height: 1.65;
}
html.light-theme .sys-msg-heading { color: #1a1610; }
html.light-theme .sys-dv          { color: #1a1610; }
html.light-theme .sys-issue-text  { color: #1a1610; }
html.light-theme .sys-bubble-user { background: rgba(46,184,164,0.06) !important; }
html.light-theme .sys-bubble-lead { background: rgba(201,168,76,0.06) !important; }


/* ══════════════════════════════════════════════════
   MODAL — NEW TICKET
══════════════════════════════════════════════════ */
.tk-modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.tk-modal-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 28px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,0.65);
  animation: tkSlideUp 0.24s cubic-bezier(0.22,1,0.36,1);
}
@keyframes tkSlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.tk-modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.tk-modal-title { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin-bottom: 5px; }
html.light-theme .tk-modal-title { color: #1a1610; }
.tk-modal-sub   { font-size: 12px; color: var(--ink3); line-height: 1.5; max-width: 340px; }
.tk-modal-close {
  background: none; border: none; font-size: 1rem;
  color: var(--ink3); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.tk-modal-close:hover { background: rgba(255,255,255,0.07); color: var(--ink); }
.tk-field-row { display: flex; gap: 14px; margin-bottom: 18px; }
.tk-field-row .tk-field { flex: 1; margin-bottom: 0; }
.tk-field { margin-bottom: 18px; }
.tk-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink2); margin-bottom: 8px; }
.tk-req   { color: var(--gold); }
.tk-input {
  width: 100%; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 13px;
  color: var(--ink); font-size: 13px; font-family: inherit; transition: border-color 0.15s;
}
.tk-input:focus { outline: none; border-color: var(--gold); }
.tk-input-locked { opacity: 0.55; cursor: not-allowed; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.tk-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.tk-hint { font-size: 10px; color: var(--ink3); margin-top: 5px; }
.tk-char-count { font-size: 10px; color: var(--ink3); text-align: right; margin-top: 4px; }
.tk-urgency-row { display: flex; gap: 10px; margin-bottom: 10px; }
.tk-urgency-btn {
  flex: 1; padding: 12px 10px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: all 0.15s; font-family: inherit;
}
.tk-urgency-btn:hover { border-color: var(--border2); }
.tk-urgency-btn.selected { border-color: var(--gold); background: rgba(201,168,76,0.08); }
.tk-urg-dot { width: 10px; height: 10px; border-radius: 50%; }
.urg-critical { background: #e05555; box-shadow: 0 0 8px rgba(224,85,85,0.5); }
.urg-medium   { background: #c9a84c; box-shadow: 0 0 8px rgba(201,168,76,0.5); }
.urg-low      { background: #888; }
.tk-urg-label { font-size: 12px; font-weight: 700; color: var(--ink); }
html.light-theme .tk-urg-label { color: #1a1610; }
.tk-urg-sub   { font-size: 10px; color: var(--ink3); text-align: center; }
.tk-urgency-note {
  font-size: 11px; color: var(--ink3);
  background: rgba(201,168,76,0.07); border: 1px dashed rgba(201,168,76,0.25);
  border-radius: 8px; padding: 8px 12px; line-height: 1.5;
}
.tk-success-wrap { text-align: center; padding: 8px 0; }
.tk-success-icon { font-size: 2.8rem; margin-bottom: 14px; }
.tk-success-title { font-size: 1.2rem; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
html.light-theme .tk-success-title { color: #1a1610; }
.tk-success-sub { font-size: 13px; color: var(--ink2); line-height: 1.65; margin-bottom: 20px; }
.tk-success-msgs { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-bottom: 4px; }
.tk-preview-msg {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 12px; color: var(--ink2); line-height: 1.55;
}
.tk-msg-system  { background: rgba(46,184,164,0.08); border: 1px solid rgba(46,184,164,0.2); }
.tk-msg-pending { background: rgba(255,255,255,0.04); border: 1px dashed rgba(255,255,255,0.1); }
.tk-preview-dot { width: 8px; height: 8px; border-radius: 50%; background: #2eb8a4; flex-shrink: 0; margin-top: 4px; }
.tk-dot-pending { background: #888; }


/* ══════════════════════════════════════════════════
   RATING MODAL
══════════════════════════════════════════════════ */
.rating-modal-box { max-width: 440px !important; }
.rating-stars-row {
  display: flex; justify-content: center; gap: 12px;
  margin: 8px 0 6px;
}
.rating-star {
  font-size: 2.8rem; color: var(--border2,#444);
  cursor: pointer; transition: color 0.1s, transform 0.1s;
  user-select: none; line-height: 1;
}
.rating-star.hover { color: rgba(201,168,76,0.55); transform: scale(1.15); }
.rating-star.lit   { color: var(--gold,#c9a84c); transform: scale(1.1); }
.rating-label-text {
  text-align: center; font-size: 13px; font-weight: 600;
  color: var(--ink2,#c0b8a8); min-height: 20px;
}
@keyframes tkShake {
  0%,100%{ transform: translateX(0) }
  20%    { transform: translateX(-8px) }
  40%    { transform: translateX(8px) }
  60%    { transform: translateX(-5px) }
  80%    { transform: translateX(5px) }
}

/* ── Rating receipt bubble ───────────────────── */
.sys-bubble-rating {
  background: rgba(201,168,76,0.08) !important;
  border: 1px solid rgba(201,168,76,0.3) !important;
}
.rating-receipt-stars   { font-size: 1.4rem; letter-spacing: 3px; margin: 6px 0 4px; }
.rating-receipt-comment { font-size: 12px; color: var(--ink3,#888); font-style: italic; margin-top: 6px; line-height: 1.55; }


/* ══════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════ */
.tk-toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card,#1a1a1a); border: 1px solid var(--border);
  border-radius: 40px; padding: 12px 24px;
  font-size: 13px; font-weight: 600; color: var(--ink,#e8e0d0);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1), opacity 0.3s;
  opacity: 0; white-space: nowrap; pointer-events: none;
}
.tk-toast-show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Light theme overrides ───────────────────── */
html.light-theme .rating-star       { color: #ccc; }
html.light-theme .rating-star.lit   { color: var(--gold); }
html.light-theme .rating-label-text { color: #555; }
html.light-theme .tk-toast          { background: #fff; color: #1a1610; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
  .tickets-page           { padding: 16px 14px 56px; }
  .tk-page-header         { gap: 10px; }
  .tk-urgency-row         { flex-direction: column; }
  .tk-field-row           { flex-direction: column; gap: 0; }
  .tk-stats-strip         { flex-wrap: wrap; }
  .tk-stat-cell           { min-width: 40%; }
  .tk-stat-sep            { display: none; }
  .tk-msg                 { max-width: 90%; }
  .tk-header-rate-nudge   { display: none !important; } /* too cramped on mobile */
}