/* 
=====================================================
   06-desktop.css — Excel-like Table Module (Tracking + Reports)
   Inspired by BizViet work-source-table layout
   ===================================================== */

/* ---------- Module Tab Bar ---------- */

/* Override parent grid to single-column for Excel table mode */
.tracking-focus-grid:has(.kc-module-tabs),
.report-focus-grid:has(.kc-module-tabs) {
  display: flex;
  flex-direction: column;
  grid-template-columns: unset;
  gap: 0;
  padding: 0;
}

.kc-module-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 2px solid rgba(122, 242, 255, 0.12);
  margin-bottom: 0;
}

.kc-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #8b93a6);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}

.kc-tab:hover {
  color: #d0d6e0;
}

.kc-tab.active {
  color: #7af2ff;
  border-bottom-color: #7af2ff;
}

.kc-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  background: rgba(122, 242, 255, 0.12);
  color: #7af2ff;
}

.kc-tab.active .kc-tab-count {
  background: rgba(122, 242, 255, 0.2);
}

/* ---------- Toolbar ---------- */
.kc-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  flex-wrap: wrap;
}

.kc-table-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: #e0e4ec;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

.kc-table-search:focus {
  border-color: rgba(122, 242, 255, 0.35);
}

.kc-table-search::placeholder {
  color: var(--muted, #8b93a6);
}

.kc-summary-strip {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kc-summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  min-width: 72px;
}

.kc-summary-stat span {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted, #8b93a6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kc-summary-stat strong {
  font-size: 20px;
  font-weight: 800;
  color: #e0e4ec;
  line-height: 1.1;
}

/* ---------- Table Info / Pagination Bar ---------- */
.kc-table-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px;
  font-size: 11.5px;
  color: var(--muted, #8b93a6);
}

.kc-table-pager {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kc-table-pager button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted, #8b93a6);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.kc-table-pager button:hover:not(:disabled) {
  background: rgba(122, 242, 255, 0.1);
  color: #7af2ff;
}

.kc-table-pager button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---------- Excel-like Table ---------- */
.kc-table-scroll {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(11, 14, 36, 0.45);
}

.kc-excel-table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: auto;
}

.kc-excel-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.kc-excel-table thead th {
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted, #8b93a6);
  background: rgba(20, 24, 52, 0.95);
  border-bottom: 2px solid rgba(122, 242, 255, 0.1);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.kc-excel-table thead th:first-child {
  width: 36px;
  text-align: center;
}

.kc-excel-table tbody tr {
  transition: background 0.12s;
  cursor: pointer;
}

.kc-excel-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.kc-excel-table tbody tr:hover {
  background: rgba(122, 242, 255, 0.04);
}

.kc-excel-table tbody tr.active-row {
  background: rgba(122, 242, 255, 0.08);
}

.kc-excel-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  color: #d0d6e0;
}

.kc-excel-table tbody td:first-child {
  text-align: center;
}

.kc-excel-table tbody td strong {
  display: block;
  font-weight: 600;
  color: #e0e4ec;
  font-size: 12.5px;
}

.kc-excel-table tbody td small {
  display: block;
  font-size: 11px;
  color: var(--muted, #8b93a6);
  margin-top: 1px;
}

/* ---------- Group Header Row ---------- */
.kc-excel-table tbody tr.kc-group-header td {
  padding: 8px 10px;
  font-weight: 700;
  font-size: 12px;
  color: #b0b8c8;
  background: rgba(122, 242, 255, 0.04);
  border-bottom: 1px solid rgba(122, 242, 255, 0.1);
  cursor: default;
}

.kc-group-header-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kc-group-header-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #8b93a6);
}

/* ---------- Metric Cells ---------- */
.kc-metric-cell {
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px;
  white-space: nowrap;
}

.kc-metric-cell.heart {
  color: #ff79dc;
}
.kc-metric-cell.comment {
  color: #7af2ff;
}
.kc-metric-cell.save {
  color: #ffd36b;
}
.kc-metric-cell.share {
  color: #82f7c7;
}

/* ---------- Status Badges ---------- */
.kc-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

.kc-status.verified {
  background: rgba(130, 247, 199, 0.12);
  color: #82f7c7;
  border: 1px solid rgba(130, 247, 199, 0.25);
}

.kc-status.pending {
  background: rgba(255, 214, 102, 0.1);
  color: #ffd666;
  border: 1px solid rgba(255, 214, 102, 0.2);
}

.kc-status.rejected {
  background: rgba(255, 121, 220, 0.1);
  color: #ff79dc;
  border: 1px solid rgba(255, 121, 220, 0.2);
}

.kc-status.no-upload {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted, #8b93a6);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.kc-status.live-type {
  background: rgba(255, 121, 220, 0.1);
  color: #ff79dc;
  border: 1px solid rgba(255, 121, 220, 0.2);
}

.kc-status.video-type {
  background: rgba(122, 242, 255, 0.1);
  color: #7af2ff;
  border: 1px solid rgba(122, 242, 255, 0.2);
}

/* ---------- Scan thumbnail ---------- */
.kc-scan-thumb {
  width: 32px;
  height: 42px;
  object-fit: cover;
  border-radius: 3px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.kc-scan-thumb.verified {
  border-color: rgba(130, 247, 199, 0.4);
}
.kc-scan-thumb.pending {
  border-color: rgba(255, 214, 102, 0.4);
}
.kc-scan-thumb.rejected {
  border-color: rgba(255, 121, 220, 0.4);
}

/* ---------- Detail + Chat Panel (inline) ---------- */
.kc-detail-slide {
  display: none;
  background: rgba(20, 22, 40, 0.95);
  border: 1px solid rgba(122, 242, 255, 0.1);
  border-radius: 8px;
  margin: 8px 0;
  overflow: hidden;
}

.kc-detail-slide.open {
  display: block;
}

.kc-detail-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

/* ---------- Detail Popup Overlay ---------- */
.kc-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 90000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.kc-detail-overlay.visible {
  opacity: 1;
}
.kc-detail-popup {
  background: linear-gradient(135deg, #1a1e36, #222842);
  border: 1px solid rgba(122, 242, 255, 0.18);
  border-radius: 14px;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(122, 242, 255, 0.06);
  width: 560px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.2s ease;
}
.kc-detail-overlay.visible .kc-detail-popup {
  transform: translateY(0) scale(1);
}
.kc-detail-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(122, 242, 255, 0.1);
}
.kc-detail-popup-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #e0e4ec;
}
.kc-detail-popup-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #8b93a6;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
}
.kc-detail-popup-close:hover {
  background: rgba(255, 80, 80, 0.18);
  color: #ff7878;
}
.kc-detail-popup-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.kc-detail-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kc-detail-field {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.kc-detail-field-label {
  width: 140px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #8b93a6);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.kc-detail-field-value {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  color: #d0d6e0;
}

.kc-detail-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------- Inline Chat ---------- */
.kc-chat-shell {
  display: flex;
  flex-direction: column;
  max-height: 320px;
}

.kc-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 8px;
}

.kc-chat-head h4 {
  font-size: 13px;
  font-weight: 700;
  color: #e0e4ec;
  margin: 0;
}

.kc-chat-head .pill-value {
  font-size: 11px;
}

/* ---------- Empty State ---------- */
.kc-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 16px;
  text-align: center;
}

.kc-empty-state strong {
  font-size: 14px;
  color: #e0e4ec;
}

.kc-empty-state small {
  font-size: 12px;
  color: var(--muted, #8b93a6);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kc-detail-inner {
    grid-template-columns: 1fr;
  }

  .kc-summary-strip {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .kc-module-tabs {
    overflow-x: auto;
  }

  .kc-tab {
    padding: 8px 12px;
    font-size: 12px;
  }

  .kc-table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .kc-table-search {
    max-width: none;
  }

  .kc-summary-strip {
    justify-content: center;
  }
}

/* ── Upgrade Notice Toast ─────────────────── */
.upgrade-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(20, 26, 50, 0.96), rgba(30, 38, 68, 0.96));
  border: 1px solid rgba(122, 242, 255, 0.25);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(122, 242, 255, 0.08);
  backdrop-filter: blur(16px);
  transition:
    opacity 0.35s,
    transform 0.35s;
  pointer-events: none;
}
.upgrade-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.upgrade-toast-icon {
  font-size: 20px;
}
.upgrade-toast-text {
  font-size: 14px;
  color: #c8d6e5;
  line-height: 1.4;
}
.upgrade-toast-text strong {
  color: #7af2ff;
}

/* ---------- KOL Report History ---------- */
.kc-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}
.kc-history-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  transition: background 0.15s;
}
.kc-history-row:hover {
  background: rgba(255, 255, 255, 0.07);
}
.kc-history-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.kc-history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kc-history-no-img {
  color: var(--muted, #888);
  font-size: 1.2rem;
}
.kc-history-info {
  flex: 1;
  min-width: 0;
}
.kc-history-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: #e4e9f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kc-history-date {
  font-size: 0.82rem;
  color: #a0aec0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kc-history-status {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
}
.kc-history-status.done {
  background: rgba(130, 247, 199, 0.15);
  color: #82f7c7;
}
.kc-history-status.pending {
  background: rgba(255, 211, 107, 0.15);
  color: #ffd36b;
}
.kc-history-link {
  margin-top: 3px;
}
.kc-history-link a {
  color: #7af2ff;
  font-size: 0.82rem;
  text-decoration: none;
}
.kc-history-link a:hover {
  text-decoration: underline;
}
.kc-history-metrics {
  font-size: 0.82rem;
  color: #c8d6e5;
  margin-top: 3px;
}
.kc-history-empty {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 0.95rem;
}
.report-focus-card.history {
  --card-accent: #82f7c7;
}

/* ---------- Date Filter ---------- */
.kc-date-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.kc-date-filter label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: #c8d6e5;
}
.kc-date-filter input[type='date'] {
  background: rgba(122, 242, 255, 0.06);
  border: 1px solid rgba(122, 242, 255, 0.18);
  border-radius: 6px;
  color: #e0e6ed;
  padding: 4px 8px;
  font-size: 0.82rem;
  outline: none;
}
.kc-date-filter input[type='date']:focus {
  border-color: rgba(122, 242, 255, 0.45);
}
