/* ============================================================
   Drexora Support — Team Management & Ticket System
   Supplement to styles.css (Premium Modern Dark Theme)
   ============================================================ */

/* ── Content wrapper (team / tickets pages) ─────────────────── */
.content-wrap { padding: 28px 32px; flex: 1; }
@media (max-width: 768px) { .content-wrap { padding: 18px; } }

/* ── Shared utilities ───────────────────────────────────────── */
.text-muted { color: var(--text-muted); font-size: .875rem; }
.req { color: var(--danger); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.section-desc { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Form additions ─────────────────────────────────────────── */
.form-label { font-size: .82rem; font-weight: 600; color: var(--text-secondary); }
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .875rem;
  transition: var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--primary); }
.form-select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A3A3A3' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; }
.form-textarea { resize: vertical; min-height: 90px; }

/* ── Search bar ─────────────────────────────────────────────── */
.tt-search-wrap {
  position: relative; display: flex; align-items: center;
}
.tt-search-icon {
  position: absolute; left: 12px; width: 15px; height: 15px;
  color: var(--text-muted); pointer-events: none;
}
.tt-search-input {
  padding: 9px 14px 9px 36px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .85rem;
  outline: none;
  transition: var(--transition);
  width: 220px;
}
.tt-search-input:focus { border-color: var(--primary); width: 260px; }

/* ── Table enhancements ─────────────────────────────────────── */
.table-wrap, .tt-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tt-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.tt-table th {
  padding: 11px 16px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.tt-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tt-table tr:last-child td { border-bottom: none; }
.tt-table tbody tr { transition: var(--transition); cursor: pointer; }
.tt-table tbody tr:hover { background: var(--glass-hover); }

/* ── Member cell ────────────────────────────────────────────── */
.member-cell { display: flex; align-items: center; gap: 10px; }
.member-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  border: 1px solid var(--border);
}
.member-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.member-avatar-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: rgba(59, 130, 246, .15);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 700;
}
.member-name { font-size: .875rem; font-weight: 600; line-height: 1.3; color: var(--text-primary); }
.member-email { font-size: .78rem; color: var(--text-muted); }

/* ── Status indicator ───────────────────────────────────────── */
.status-cell { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  animation: pulseDot 2s ease-in-out infinite;
}
.status-online  { background: var(--success); }
.status-away    { background: var(--warning); }
.status-offline { background: var(--text-muted); animation: none; }
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Action menu ────────────────────────────────────────────── */
.action-menu-wrap { position: relative; display: inline-block; }
.action-menu-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: var(--transition);
}
.action-menu-btn svg { width: 16px; height: 16px; }
.action-menu-btn:hover { background: var(--glass-hover); border-color: var(--border); color: var(--text-primary); }
.action-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
  min-width: 180px;
  overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(-6px) scale(.97);
  transition: opacity .15s ease, transform .15s ease;
}
.action-menu.open { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }
.action-menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  font-size: .84rem; font-weight: 500;
  color: var(--text-primary);
  background: none; border: none; cursor: pointer;
  text-align: left; transition: var(--transition);
}
.action-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-muted); }
.action-menu-item:hover { background: var(--glass-hover); }
.action-menu-item--danger { color: var(--danger); }
.action-menu-item--danger svg { color: var(--danger); }
.action-menu-item--danger:hover { background: rgba(239, 68, 68, .12); }
.action-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Stat icon variants ─────────────────────────────────────── */
.stat-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: grid; place-items: center; margin-bottom: 12px;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue   { background: rgba(59, 130, 246, .15);  color: var(--info); }
.stat-icon.green  { background: rgba(16, 185, 129, .15);  color: var(--success); }
.stat-icon.amber  { background: rgba(245, 158, 11, .15);  color: var(--warning); }
.stat-icon.purple { background: rgba(139, 92, 246, .15); color: #8b5cf6; }
.stat-icon.red    { background: rgba(239, 68, 68, .15);  color: var(--danger); }
.stat-icon.cyan   { background: rgba(6, 182, 212, .15);  color: #06b6d4; }

/* ── Invitations list ───────────────────────────────────────── */
.invitations-list { display: flex; flex-direction: column; gap: 2px; }
.invitation-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.invitation-item:hover { background: var(--glass-hover); }

/* ── Invite modal photo ─────────────────────────────────────── */
.invite-photo-row {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px; padding: 16px;
  background: var(--glass-bg); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.invite-photo-preview {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--surface-raised); border: 2px dashed var(--border);
  display: grid; place-items: center; overflow: hidden; flex-shrink: 0;
  transition: var(--transition);
}
.invite-photo-preview:hover { border-color: var(--primary); }

/* ── Permission preview box ─────────────────────────────────── */
.perm-preview-box {
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 6px; margin-bottom: 8px;
}
.perm-preview-title { font-size: .85rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.perm-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}
.perm-item {
  display: flex; align-items: center; gap: 7px;
  font-size: .8rem; color: var(--text-secondary);
}
.perm-icon { font-size: .85rem; font-weight: 700; flex-shrink: 0; }
.perm-yes .perm-icon { color: var(--success); }
.perm-no  .perm-icon { color: var(--text-muted); opacity: .5; }
.perm-no  { opacity: .55; }

/* ── Permission editor ──────────────────────────────────────── */
.perm-editor-title {
  font-size: .82rem; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 10px; margin-top: 4px;
}
.perm-editor-grid { display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow-y: auto; }
.perm-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: var(--transition); font-size: .875rem;
}
.perm-toggle-row:hover { background: var(--glass-hover); }

/* ── Toggle switch ──────────────────────────────────────────── */
.tt-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.tt-switch input { opacity: 0; width: 0; height: 0; }
.tt-switch-slider {
  position: absolute; inset: 0;
  background: var(--border-strong); border-radius: 99px;
  cursor: pointer; transition: .2s;
}
.tt-switch-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; bottom: 3px; left: 3px;
  transition: .2s;
}
.tt-switch input:checked + .tt-switch-slider { background: var(--primary); }
.tt-switch input:checked + .tt-switch-slider::before { transform: translateX(16px); }

/* ── Skeleton loader ────────────────────────────────────────── */
.skeleton-row {
  height: 18px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--glass-hover) 50%, var(--surface-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin: 12px 0;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Ticket filters bar ─────────────────────────────────────── */
.ticket-filters-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.tt-filter-select {
  width: auto; min-width: 140px; padding: 9px 34px 9px 12px; font-size: .82rem;
}

/* ── Ticket ID badge ────────────────────────────────────────── */
.ticket-id-badge {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .78rem; font-weight: 700;
  color: var(--primary);
  background: rgba(59, 130, 246, .12);
  border: 1px solid rgba(59, 130, 246, .25);
  padding: 3px 8px; border-radius: 6px;
  white-space: nowrap;
}

/* ── Channel badge ──────────────────────────────────────────── */
.channel-badge {
  font-size: .78rem; font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 99px;
  white-space: nowrap;
}

/* ── Priority badges ────────────────────────────────────────── */
.priority-low    { background: rgba(16, 185, 129, .12); color: var(--success); border: 1px solid rgba(16, 185, 129, .3); }
.priority-medium { background: rgba(59, 130, 246, .15); color: var(--info);    border: 1px solid rgba(59, 130, 246, .3); }
.priority-high   { background: rgba(245, 158, 11, .12); color: var(--warning); border: 1px solid rgba(245, 158, 11, .3); }
.priority-urgent { background: rgba(239, 68, 68, .12); color: var(--danger);  border: 1px solid rgba(239, 68, 68, .3); }

/* ── Active ticket row ──────────────────────────────────────── */
.ticket-row--active { background: var(--glass-active) !important; }

/* ── Ticket Detail Panel ────────────────────────────────────── */
.ticket-detail-panel {
  position: fixed; top: 0; right: -520px; bottom: 0;
  width: 520px; max-width: 100vw;
  background: var(--modal-bg);
  border-left: 1px solid var(--border);
  z-index: 500;
  display: flex; flex-direction: column;
  transition: right .3s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
.ticket-detail-panel.open { right: 0; }
.tdp-overlay {
  position: fixed; inset: 0; z-index: 490;
  background: rgba(0, 0, 0, .6);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.tdp-overlay.open { opacity: 1; pointer-events: all; }

.tdp-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
  flex-shrink: 0;
}
.tdp-ticket-id {
  font-family: 'SF Mono', monospace; font-size: .82rem;
  color: var(--primary); font-weight: 700;
  background: rgba(59, 130, 246, .12); border: 1px solid rgba(59, 130, 246, .25);
  padding: 3px 8px; border-radius: 6px; display: inline-block; margin-bottom: 6px;
}
.tdp-subject { font-size: .95rem; font-weight: 700; color: var(--text-primary); }

.tdp-body {
  flex: 1; overflow-y: auto; padding: 0;
}

.tdp-section {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.tdp-section:last-child { border-bottom: none; }
.tdp-section-title {
  font-size: .78rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 12px;
}
.tdp-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tdp-info-item { display: flex; flex-direction: column; gap: 2px; }
.tdp-info-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; }
.tdp-meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tdp-meta-item { display: flex; flex-direction: column; gap: 6px; }

/* ── Messages ───────────────────────────────────────────────── */
.tdp-messages { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.tdp-msg { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.tdp-msg--agent { background: rgba(59, 130, 246, .10); border-color: rgba(59, 130, 246, .25); }
.tdp-msg--customer { background: var(--surface-raised); }
.tdp-msg-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: .82rem; }
.tdp-msg-body { font-size: .875rem; color: var(--text-secondary); line-height: 1.6; }
.tdp-reply-box { padding-top: 8px; }

/* ── Internal note ──────────────────────────────────────────── */
.tdp-note {
  padding: 12px 14px; border-radius: var(--radius);
  background: rgba(245, 158, 11, .10); border: 1px dashed rgba(245, 158, 11, .30);
  margin-bottom: 8px; font-size: .875rem; color: var(--text-primary);
}
.dark-mode .tdp-note { background: rgba(245, 158, 11, .10); }

/* ── Tags ───────────────────────────────────────────────────── */
.tdp-tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tdp-tag {
  font-size: .75rem; font-weight: 600;
  background: rgba(59, 130, 246, .15); color: var(--primary);
  border: 1px solid rgba(59, 130, 246, .3);
  padding: 3px 10px; border-radius: 99px;
}
.tdp-tag-input {
  border: 1px dashed var(--border); border-radius: 99px;
  padding: 3px 12px; font-size: .78rem;
  background: transparent; color: var(--text-primary); outline: none;
  width: 100px; transition: var(--transition);
}
.tdp-tag-input:focus { width: 150px; border-color: var(--primary); }

/* ── Detail panel actions ───────────────────────────────────── */
.tdp-actions { display: flex; gap: 8px; padding: 16px 24px; flex-wrap: wrap; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fadeUp { animation: fadeUp .35s ease both; }
.stagger-1 { animation-delay: .06s; }
.stagger-2 { animation-delay: .12s; }
.stagger-3 { animation-delay: .18s; }
.stagger-4 { animation-delay: .24s; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .ticket-detail-panel { width: 100%; right: -100%; }
  .tdp-info-grid { grid-template-columns: 1fr; }
  .tdp-meta-row  { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .content-wrap { padding: 16px 12px; }
  .ticket-filters-bar { flex-direction: column; align-items: stretch; }
  .tt-filter-select { width: 100%; }
  .tt-search-wrap { width: 100%; }
  .tt-search-input { width: 100%; }
  .tt-search-input:focus { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .invite-photo-row { flex-direction: column; text-align: center; }
  .action-menu { right: 0; left: auto; max-width: calc(100vw - 32px); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .perm-preview-grid { grid-template-columns: 1fr; }
}

.team-welcome-card {
  max-width: 560px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.team-welcome-icon { font-size: 2.4rem; margin-bottom: 12px; }
.team-welcome-card h2 { font-size: 1.35rem; margin: 0 0 10px; color: var(--text-primary); }
.team-welcome-card p { color: var(--text-secondary); line-height: 1.65; margin: 0 0 14px; }
.team-welcome-card ul { margin: 0 0 22px; padding-left: 18px; color: var(--text-secondary); line-height: 1.7; }
.ws-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
  overflow-x: auto;
}
.ws-tab {
  padding: 12px 22px;
  font-size: .88rem;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.ws-tab:hover { color: var(--text-primary); }
.ws-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
