/* ========================================================
   ForexBro Support Tickets - Polished UI
   ======================================================== */

/* Page header */
.sup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.sup-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.sup-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sup-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sup-stat-icon.ic-open { background: rgba(34,197,94,.12); color: #22c55e; }
.sup-stat-icon.ic-progress { background: rgba(59,130,246,.12); color: #3b82f6; }
.sup-stat-icon.ic-waiting { background: rgba(234,179,8,.12); color: #eab308; }
.sup-stat-icon.ic-closed { background: rgba(148,163,184,.12); color: #94a3b8; }
.sup-stat-icon.ic-unread { background: rgba(239,68,68,.12); color: #ef4444; }
.sup-stat-icon.ic-today { background: rgba(168,85,247,.12); color: #a855f7; }

.sup-stat-info { display: flex; flex-direction: column; gap: 2px; }
.sup-stat-num { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.sup-stat-label { font-size: 11px; color: var(--text-muted); }

/* Ticket list */
.sup-list {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
}

.sup-list-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sup-filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sup-tab {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all .15s;
}
.sup-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sup-tab.active {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
  font-weight: 600;
}
.sup-tab .badge-count {
  background: rgba(0,0,0,.2);
  color: inherit;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.sup-tab:not(.active) .badge-count {
  background: var(--bg-tertiary);
}

.sup-ticket-row {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background .15s;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
}
.sup-ticket-row:hover { background: var(--bg-tertiary); }
.sup-ticket-row:last-child { border-bottom: none; }

.sup-ticket-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.cat-payment      { background: rgba(34,197,94,.12); color: #22c55e; }
.cat-subscription { background: rgba(168,85,247,.12); color: #a855f7; }
.cat-telegram     { background: rgba(59,130,246,.12); color: #3b82f6; }
.cat-signals      { background: rgba(234,179,8,.12); color: #eab308; }
.cat-account      { background: rgba(20,184,166,.12); color: #14b8a6; }
.cat-general      { background: rgba(148,163,184,.12); color: #94a3b8; }
.cat-complaint    { background: rgba(239,68,68,.12); color: #ef4444; }
.cat-special      { background: rgba(244,114,182,.12); color: #f472b6; }

.sup-ticket-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sup-ticket-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sup-ticket-num {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 7px;
  border-radius: 6px;
}
.sup-ticket-subject {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sup-ticket-preview {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.sup-ticket-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.sup-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.st-open             { background: rgba(34,197,94,.15); color: #22c55e; }
.st-in_progress      { background: rgba(59,130,246,.15); color: #3b82f6; }
.st-waiting_customer { background: rgba(234,179,8,.15); color: #eab308; }
.st-closed           { background: rgba(148,163,184,.15); color: #94a3b8; }
.st-archived         { background: rgba(100,116,139,.10); color: #64748b; }

.sup-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239,68,68,.2);
  flex-shrink: 0;
}

.sup-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.sup-empty-icon { font-size: 48px; margin-bottom: 14px; opacity: .4; }
.sup-empty-text { font-size: 15px; margin-bottom: 8px; color: var(--text-secondary); }
.sup-empty-hint { font-size: 13px; }

/* New ticket button */
.sup-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-gold);
  color: #000;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  font-size: 14px;
  transition: transform .15s, filter .15s;
}
.sup-new-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.sup-new-btn:active { transform: translateY(0); }

/* ============= MODAL: New Ticket Wizard ============= */
.sup-wizard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .2s;
}
.sup-wizard-overlay.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sup-wizard {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp .25s;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sup-wizard-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sup-wizard-title { font-size: 17px; font-weight: 700; }
.sup-wizard-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sup-wizard-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.sup-wizard-steps {
  display: flex;
  padding: 14px 22px;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.sup-step {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  transition: background .25s;
}
.sup-step.active { background: var(--accent-gold); }
.sup-step.done { background: #22c55e; }

.sup-wizard-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.sup-wizard-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* Category cards */
.sup-cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 480px) {
  .sup-cat-grid { grid-template-columns: 1fr; }
}

.sup-cat-card {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all .15s;
  text-align: start;
}
.sup-cat-card:hover {
  border-color: var(--accent-gold-soft, rgba(245,158,11,.4));
  background: var(--bg-tertiary);
}
.sup-cat-card.selected {
  border-color: var(--accent-gold);
  background: rgba(245,158,11,.08);
}
.sup-cat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sup-cat-card-text { display: flex; flex-direction: column; gap: 2px; }
.sup-cat-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.sup-cat-card-desc { font-size: 11px; color: var(--text-muted); }

/* Form fields */
.sup-field { margin-bottom: 16px; }
.sup-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.sup-field-input,
.sup-field-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 11px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.sup-field-input:focus,
.sup-field-textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(245,158,11,.12);
}
.sup-field-textarea { min-height: 120px; }
.sup-field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.sup-char-counter { float: inline-end; font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Image upload */
.sup-uploader {
  border: 2px dashed var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}
.sup-uploader:hover {
  border-color: var(--accent-gold);
  background: rgba(245,158,11,.04);
}
.sup-uploader-icon { font-size: 32px; opacity: .5; margin-bottom: 8px; }
.sup-uploader-text { font-size: 13px; color: var(--text-secondary); }
.sup-uploader-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.sup-img-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.sup-img-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.sup-img-preview img { width: 100%; height: 100%; object-fit: cover; }
.sup-img-remove {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  background: rgba(0,0,0,.7);
  color: #fff;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.sup-img-progress {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  height: 3px;
  background: var(--accent-gold);
  transition: width .25s;
}

/* Summary */
.sup-summary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
}
.sup-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 14px;
}
.sup-summary-row:last-child { border-bottom: none; }
.sup-summary-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.sup-summary-value { font-size: 13px; color: var(--text-primary); text-align: end; word-break: break-word; }

/* ============= CHAT VIEW ============= */
.sup-chat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  height: 75vh;
  min-height: 500px;
  max-height: 800px;
  overflow: hidden;
}

.sup-chat-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sup-back-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.sup-back-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.sup-chat-title-area { flex: 1; min-width: 0; }
.sup-chat-num {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--text-muted);
}
.sup-chat-subject {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sup-chat-meta-line {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sup-chat-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sup-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-primary);
}

/* Date divider */
.sup-date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0;
  position: relative;
}
.sup-date-divider span {
  background: var(--bg-primary);
  padding: 0 10px;
  position: relative;
  z-index: 1;
}
.sup-date-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-subtle);
}

/* Message bubbles */
.sup-msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: msgIn .25s;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.sup-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.sup-msg.theirs { align-self: flex-start; }
.sup-msg.system { align-self: center; max-width: 90%; }

.sup-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}
.sup-avatar.admin { background: linear-gradient(135deg, var(--accent-gold) 0%, #d97706 100%); color: #000; }

.sup-bubble {
  background: var(--bg-secondary);
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 80px;
}
.sup-msg.mine .sup-bubble {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #d97706 100%);
  color: #000;
  border-color: transparent;
}
.sup-msg.system .sup-bubble {
  background: var(--bg-tertiary);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.sup-bubble-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.sup-msg.mine .sup-bubble-sender { color: rgba(0,0,0,.7); }

.sup-bubble-body {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.sup-bubble-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.sup-bubble-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(0,0,0,.1);
}

.sup-bubble-time {
  font-size: 10px;
  color: var(--text-muted);
  align-self: flex-end;
}
.sup-msg.mine .sup-bubble-time { color: rgba(0,0,0,.55); }

/* Typing indicator */
.sup-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.sup-typing-dots { display: inline-flex; gap: 3px; }
.sup-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingPulse 1.2s infinite;
}
.sup-typing-dots span:nth-child(2) { animation-delay: .2s; }
.sup-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingPulse {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Compose */
.sup-compose {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 16px;
  background: var(--bg-secondary);
}

.sup-compose-attach-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 80px));
  gap: 8px;
  margin-bottom: 8px;
}
.sup-compose-attach-row:empty { display: none; }

.sup-compose-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.sup-compose-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sup-compose-thumb .sup-img-remove { width: 20px; height: 20px; font-size: 12px; }

.sup-compose-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.sup-compose-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  max-height: 140px;
  min-height: 42px;
  line-height: 1.4;
}
.sup-compose-input:focus {
  outline: none;
  border-color: var(--accent-gold);
}
.sup-compose-input:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.sup-compose-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  transition: all .15s;
}
.sup-compose-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.sup-compose-btn.send { background: var(--accent-gold); color: #000; border-color: var(--accent-gold); }
.sup-compose-btn.send:hover { filter: brightness(1.1); }
.sup-compose-btn.send:disabled { opacity: .4; cursor: not-allowed; filter: none; }

.sup-closed-banner {
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-subtle);
  padding: 14px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Image lightbox */
.sup-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  cursor: zoom-out;
  padding: 20px;
}
.sup-lightbox.show { display: flex; }
.sup-lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
}
