/* App shell, sidebar frame, header, tabs, tables, charts, and loader layout. */
/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--surface-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 16px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 0;
}

.sidebar.collapsed {
  margin-left: -280px;
}

.logo {
  font-size: 1.1rem;
  font-weight: 900;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: -0.04em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 4px 12px var(--primary-glow));
  background: #fff;
  padding: 2px;
}

.logo-info {
  display: flex;
  flex-direction: column;
}

.logo-text {
  background: linear-gradient(to right, var(--text), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.1rem;
  line-height: 1.2;
}

.logo-subtitle {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 1px;
}


/* Main content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 50%);
}

.header {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 24px;
  backdrop-filter: blur(20px);
  z-index: 5;
  gap: 16px;
}

/* Header Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 5px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  font-family: 'Plus Jakarta Sans', sans-serif;
  position: relative;
  white-space: nowrap;
}

.nav-link svg {
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  font-weight: 700;
}

[data-theme="light"] .nav-link:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .nav-link.active {
  background: rgba(79, 70, 229, 0.08);
}

.nav-count-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
  line-height: 1.6;
}

.nav-link:not(.active) .nav-count-badge {
  background: rgba(99, 102, 241, 0.25);
  color: var(--text-muted);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.live-scan {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: live-pulse 2s infinite;
}

@keyframes live-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.header-stats {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: right;
  white-space: nowrap;
}

.stat-highlight {
  font-weight: 800;
  color: var(--primary);
}

.stat-highlight-green {
  font-weight: 800;
  color: var(--accent);
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--text-muted);
}

[data-theme="light"] .header-icon-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px 32px;
}

/* Tabs */
.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Sortable table headers */
.th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.th-sort:hover {
  color: var(--primary);
}

.th-sort .sort-icon {
  font-size: 0.7rem;
  opacity: 0.4;
  margin-left: 4px;
  transition: opacity 0.15s;
}

.th-sort:hover .sort-icon {
  opacity: 0.8;
}

.th-sort.sort-asc,
.th-sort.sort-desc {
  color: var(--primary);
}

.th-sort.sort-asc .sort-icon,
.th-sort.sort-desc .sort-icon {
  opacity: 1;
  color: var(--primary);
}

/* Table Filters */
.table-filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tf-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tf-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tf-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tf-input {
  width: 90px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.tf-input:focus {
  border-color: var(--primary);
}

.tf-dash {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.tf-btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: opacity 0.15s;
}

.tf-btn:hover {
  opacity: 0.85;
}

.tf-btn-reset {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tf-btn-reset:hover {
  color: var(--text);
  border-color: var(--text-muted);
  opacity: 1;
}

[data-theme="light"] .tf-input {
  background: rgba(0, 0, 0, 0.02);
}

/* Table */
.listings-view-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.listings-view-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
}

.listings-view-btn {
  min-width: 74px;
  height: 36px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.listings-view-btn:last-child {
  border-right: 0;
}

.listings-view-btn.active {
  background: var(--primary);
  color: #fff;
}

.listing-view[hidden] {
  display: none !important;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.listings-grid-shell {
  flex: 1;
  min-height: 0;
}

.listings-grid {
  padding-bottom: 16px;
}

.listing-grid-empty {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--text-muted);
}

.table-scroll {
  flex: 1;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.95);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  text-align: left;
  backdrop-filter: blur(10px);
  transition: background 0.3s;
}

[data-theme="light"] th {
  background: rgba(248, 250, 252, 0.95);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: rgba(99, 102, 241, 0.05);
}

[data-theme="light"] .clickable-row:hover td {
  background: rgba(99, 102, 241, 0.04);
}

.td-img {
  width: 60px;
  height: 45px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#tab-all table tbody td:nth-child(3) {
  display: none;
}

.td-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.td-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

#listingsTableBody {
  transition: opacity 0.3s ease;
}

#listingsTableBody.loading {
  opacity: 0.3;
  pointer-events: none;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(30, 41, 59, 0.95);
  border-top: 1px solid var(--border);
  z-index: 10;
  backdrop-filter: blur(10px);
  transition: background 0.3s;
}

[data-theme="light"] .pagination {
  background: rgba(248, 250, 252, 0.95);
}

.page-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Charts Area */
.chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  height: 450px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Loader */
.loader {
  position: absolute;
  inset: 0;
  background: var(--surface);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loader.show {
  opacity: 0.85;
  visibility: visible;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
