/* ============================================================
   table.css — Product_Table stilleri, skeleton animasyonu
   Amazon Affiliate ROI Aracı
   ============================================================ */

/* ─── Table Container ──────────────────────────────────────── */
.table-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-toolbar__info {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.table-toolbar__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), opacity var(--transition);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn--secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn--sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--success {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.btn--success:hover {
  background: #15803d;
  border-color: #15803d;
}

/* ─── Sessions Panel ────────────────────────────────────────── */
.sessions-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
}

.sessions-section__header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sessions-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
  font-style: italic;
}

.session-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}

.session-card:hover {
  border-color: var(--accent);
  background: rgba(255,102,0,0.04);
}

.session-card__name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 22px;
}

.session-card__meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.session-card__delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  border-radius: 3px;
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}

.session-card__delete:hover {
  color: var(--danger);
  background: rgba(231,76,60,0.1);
}

/* ─── Save Session Modal ─────────────────────────────────────── */
.session-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.session-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.session-modal__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.session-modal__input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition);
}

.session-modal__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,102,0,0.2);
}

.session-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Table Scroll Wrapper ─────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  position: relative;
}

/* Disable interactions while loading */
.table-wrap.loading {
  pointer-events: none;
  user-select: none;
}

/* ─── Product Table ────────────────────────────────────────── */
.product-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 1200px;
}

/* ─── Column widths — design.md §Product_Table Sütun Düzeni ── */
.product-table col.col-image    { width: 60px;  }
.product-table col.col-title    { width: 200px; }
.product-table col.col-asin     { width: 110px; }
.product-table col.col-src-price { width: 90px; }
.product-table col.col-tgt-price { width: 90px; }
.product-table col.col-profit   { width: 90px;  }
.product-table col.col-roi      { width: 80px;  }
.product-table col.col-rank     { width: 80px;  }
.product-table col.col-rank90   { width: 80px;  }

/* ─── Sticky Header ────────────────────────────────────────── */
.product-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.product-table thead tr {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
}

.product-table th {
  padding: 10px 8px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  user-select: none;
  border-bottom: 2px solid var(--border);
}

/* Sortable header */
.product-table th.sortable {
  cursor: pointer;
  transition: color var(--transition);
}

.product-table th.sortable:hover {
  color: var(--text-primary);
}

/* Sort icons */
.sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.35;
  font-style: normal;
  font-size: 0.7rem;
  vertical-align: middle;
  transition: opacity var(--transition);
}

.product-table th.sort-asc  .sort-icon,
.product-table th.sort-desc .sort-icon {
  opacity: 1;
  color: var(--accent);
}

/* ↑ arrow for ascending */
.product-table th.sort-asc  .sort-icon::after { content: ' ↑'; }
/* ↓ arrow for descending */
.product-table th.sort-desc .sort-icon::after { content: ' ↓'; }
/* Default (unsorted) */
.product-table th:not(.sort-asc):not(.sort-desc) .sort-icon::after { content: ' ↕'; }

/* ─── Table Body ───────────────────────────────────────────── */
.product-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color var(--transition);
}

.product-table tbody tr:last-child {
  border-bottom: none;
}

.product-table tbody tr:hover {
  background-color: var(--bg-row-hover);
}

.product-table tbody tr.row--active {
  background-color: var(--bg-row-hover);
  border-left: 3px solid var(--accent);
}

.product-table td {
  padding: 10px 8px;
  font-size: 0.88rem;
  color: var(--text-primary);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Product image cell */
.td-image img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}

.td-image .img-placeholder {
  width: 48px;
  height: 48px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.65rem;
}

/* Title — max 80 chars, single line truncation */
.td-title {
  max-width: 200px;
}

.td-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ASIN — monospace */
.td-asin {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Numeric cells — right-aligned */
.td-number {
  text-align: right;
}

/* No results message row */
.td-no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 0.85rem;
}

/* ─── Detail / Accordion Row ───────────────────────────────── */
.product-table tr.detail-row td {
  padding: 0;
  cursor: default;
}

.product-table tr.detail-row:hover {
  background-color: transparent;
}

.detail-panel {
  padding: 16px 20px;
  background-color: rgba(15, 52, 96, 0.35);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.detail-market-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-market-card__header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-market-card__header img {
  width: 18px;
  height: 13px;
  border-radius: 2px;
}

.detail-market-card__roi {
  font-size: 1rem;
  font-weight: 700;
}

.detail-market-card__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.detail-market-card__row span:last-child {
  color: var(--text-primary);
  font-weight: 500;
}

.detail-market-card .btn--copy {
  margin-top: 4px;
  width: 100%;
  justify-content: center;
}

/* Best market highlight */
.detail-market-card.best-market {
  border-color: var(--accent);
  background-color: rgba(255, 102, 0, 0.08);
}

/* ─── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Skeleton Loading ─────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.85;
  }
}

.product-table tr.skeleton td {
  padding: 10px 8px;
}

.skeleton-cell {
  height: 14px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-row-hover);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

/* Vary widths for a realistic skeleton appearance */
.product-table tr.skeleton td:nth-child(1) .skeleton-cell { width: 48px; height: 48px; border-radius: var(--radius-sm); }
.product-table tr.skeleton td:nth-child(2) .skeleton-cell { width: 90%;  }
.product-table tr.skeleton td:nth-child(3) .skeleton-cell { width: 80%;  }
.product-table tr.skeleton td:nth-child(4) .skeleton-cell { width: 65%;  margin-left: auto; }
.product-table tr.skeleton td:nth-child(5) .skeleton-cell { width: 65%;  margin-left: auto; }
.product-table tr.skeleton td:nth-child(6) .skeleton-cell { width: 55%;  margin-left: auto; }
.product-table tr.skeleton td:nth-child(7) .skeleton-cell { width: 50%;  margin-left: auto; }
.product-table tr.skeleton td:nth-child(8) .skeleton-cell { width: 70%;  margin-left: auto; }
.product-table tr.skeleton td:nth-child(9) .skeleton-cell { width: 70%;  margin-left: auto; }

/* Staggered animation delay for each skeleton row */
.product-table tr.skeleton:nth-child(2)  td .skeleton-cell { animation-delay: 0.07s;  }
.product-table tr.skeleton:nth-child(3)  td .skeleton-cell { animation-delay: 0.14s;  }
.product-table tr.skeleton:nth-child(4)  td .skeleton-cell { animation-delay: 0.21s;  }
.product-table tr.skeleton:nth-child(5)  td .skeleton-cell { animation-delay: 0.28s;  }
.product-table tr.skeleton:nth-child(6)  td .skeleton-cell { animation-delay: 0.35s;  }
.product-table tr.skeleton:nth-child(7)  td .skeleton-cell { animation-delay: 0.42s;  }
.product-table tr.skeleton:nth-child(8)  td .skeleton-cell { animation-delay: 0.49s;  }
.product-table tr.skeleton:nth-child(9)  td .skeleton-cell { animation-delay: 0.56s;  }
.product-table tr.skeleton:nth-child(10) td .skeleton-cell { animation-delay: 0.63s;  }

/* ─── Column-based Filtering Styles ────────────────────────── */
.product-table th.sortable {
  position: relative;
  padding-right: 20px;
}

.cf-filter-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.35;
  font-size: 0.7rem;
  transition: opacity var(--transition), color var(--transition);
  padding: 2px 4px;
  margin-left: 4px;
  vertical-align: middle;
}

.cf-filter-icon:hover {
  opacity: 1;
  color: var(--accent);
}

.cf-filter-icon.active {
  opacity: 1;
  color: #22c55e;
}

/* Popover Panel */
.cf-popover {
  position: absolute;
  z-index: 9999;
  width: 240px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  padding: 12px;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: cf-fade-in 0.15s cubic-bezier(0, 0, 0.2, 1);
}

@keyframes cf-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cf-popover-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.cf-popover-operator {
  width: 100%;
}

.cf-popover-inputs {
  display: flex;
  gap: 6px;
}

.cf-popover-inputs input {
  flex: 1;
  min-width: 0;
}

.cf-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Chip/Badge for Active Filters in Toolbar */
.cf-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #22c55e;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-right: 4px;
  margin-bottom: 4px;
}

.cf-filter-tag__close {
  cursor: pointer;
  font-weight: 700;
  opacity: 0.6;
}

.cf-filter-tag__close:hover {
  opacity: 1;
}

/* Amazon view cell full width styling */
.amazon-view-cell {
  padding: 0 !important;
  vertical-align: stretch !important;
}

.amazon-view-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  height: 100%;
  justify-content: stretch;
}

.amazon-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  background-color: rgba(255, 153, 0, 0.05);
  color: #ff9900 !important;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color var(--transition);
  width: 100%;
  flex: 1;
}

.amazon-view-btn:first-child {
  border-bottom: 1px solid var(--border);
}

.amazon-view-btn:hover {
  background-color: rgba(255, 153, 0, 0.15);
}
