/*
 * /ratings — Ratings & Reviews dashboard
 * Desktop: wide scrollable table (.ratings-table-wide)
 * Mobile: same table rows become stacked cards via data-label + @media (see bottom)
 */

.ratings-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ratings-table-wide {
  min-width: 1480px;
}

.ratings-app-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.ratings-app-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: cover;
}

.ratings-app-icon--placeholder {
  display: inline-block;
  background: var(--border);
}

.ratings-app-name {
  font-weight: 600;
}

.ratings-app-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.ratings-app-release {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mobile-app-identity-cell {
  align-items: flex-start;
}

.mobile-app-identity-title-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.mobile-app-identity-name-link {
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.mobile-app-identity-name-link:hover .mobile-app-identity-name {
  color: var(--accent, #38bdf8);
  text-decoration: underline;
}

.mobile-app-identity-info {
  position: relative;
  flex-shrink: 0;
}

.mobile-app-identity-info-btn {
  list-style: none;
  cursor: pointer;
}

.mobile-app-identity-info-btn::-webkit-details-marker {
  display: none;
}

.mobile-app-identity-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 220px;
  max-width: min(320px, 70vw);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border, #334155);
  background: var(--panel, #0f172a);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 0.45rem;
}

.mobile-app-identity-panel-row {
  display: grid;
  gap: 0.1rem;
  font-size: 0.82rem;
}

.mobile-app-identity-panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border, #334155);
}

.mobile-app-identity-panel-links a {
  color: var(--accent, #38bdf8);
  text-decoration: none;
  font-size: 0.82rem;
}

.mobile-app-identity-panel-links a:hover {
  text-decoration: underline;
}

.ratings-rating-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ratings-rating-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ratings-delta {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.ratings-delta--up {
  color: #4ade80;
}

.ratings-delta--down {
  color: #f87171;
}

.ratings-delta--na {
  color: var(--muted);
}

.ratings-trend-cell {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 120px;
}

.ratings-trend-stats {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.ratings-new-count-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ratings-sparkline {
  display: block;
}

.ratings-sparkline--up {
  color: #4ade80;
}

.ratings-sparkline--down {
  color: #f87171;
}

.ratings-sparkline--neutral {
  color: var(--muted);
}

.ratings-sparkline--empty {
  color: var(--muted);
}

.ratings-stars-bar {
  display: flex;
  width: 100%;
  min-width: 80px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}

.ratings-stars-segment--1 { background: #f87171; }
.ratings-stars-segment--2 { background: #fb923c; }
.ratings-stars-segment--3 { background: #facc15; }
.ratings-stars-segment--4 { background: #a3e635; }
.ratings-stars-segment--5 { background: #4ade80; }

.ratings-stars-bar--empty {
  font-size: 0.85rem;
}

.ratings-review-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Vertical star histogram (Android ratings + reusable elsewhere) */
.star-dist-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 7.5rem;
  height: 3.25rem;
}

.star-dist-chart--empty {
  color: var(--muted);
  font-size: 0.85rem;
  height: auto;
}

.star-dist-chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  height: 100%;
}

.star-dist-chart__track {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.12);
  overflow: hidden;
}

.star-dist-chart__bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 0;
}

.star-dist-chart__bar--1 { background: #f87171; }
.star-dist-chart__bar--2 { background: #fb923c; }
.star-dist-chart__bar--3 { background: #facc15; }
.star-dist-chart__bar--4 { background: #a3e635; }
.star-dist-chart__bar--5 { background: #4ade80; }

.star-dist-chart__label {
  font-size: 0.68rem;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.android-latest-review {
  max-width: 16rem;
}

.android-text-reviews-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.ratings-new-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  font-weight: 600;
  font-size: 0.85rem;
}

.ratings-latest-review {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 220px;
}

.ratings-latest-stars {
  color: var(--muted, #94a3b8);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.ratings-latest-title {
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.ratings-latest-title-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, currentColor 45%, transparent);
}

a.ratings-latest-title-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.ratings-latest-meta {
  font-size: 0.78rem;
}

.ratings-reply-status--needed {
  color: #f87171;
  font-weight: 600;
}

.ratings-reply-status--done {
  color: #4ade80;
}

.ratings-link {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.85rem;
}

.ratings-links-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
}

.ratings-link-asc {
  color: var(--accent);
}

.ratings-link-public {
  color: var(--text);
}

a.android-app-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  max-width: 100%;
  border-radius: 8px;
}

a.android-app-link:hover .ratings-app-name {
  color: var(--accent);
  text-decoration: underline;
}

a.android-app-link:hover .ratings-app-icon {
  box-shadow: 0 0 0 2px var(--accent);
}

a.android-app-link .ratings-app-cell {
  align-items: center;
}

a.ratings-needs-reply-link,
a.android-console-metric-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

a.ratings-needs-reply-link:hover .ratings-delta--down {
  text-decoration: underline;
}

a.android-console-metric-link:hover {
  color: var(--accent, #38bdf8);
  border-bottom-style: solid;
}

.ratings-table th a {
  color: inherit;
  text-decoration: none;
}

.ratings-table th.sortable a:hover {
  color: var(--accent);
}

.ratings-table th.sorted-desc a,
.ratings-table th.sorted-asc a {
  color: var(--accent);
}

/* Mobile: transform table rows into labeled cards (same pattern as /overview) */
@media (max-width: 768px), (max-width: 932px) and (max-height: 500px) {
  .ratings-table-wrap {
    overflow-x: visible;
    max-width: 100%;
  }

  .ratings-table.ratings-table-wide {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border: none;
    background: transparent;
    overflow: visible;
  }

  .ratings-table thead {
    display: none;
  }

  .ratings-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
  }

  .ratings-table .ratings-row {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    padding: 0.65rem 0.75rem;
  }

  .ratings-table .ratings-row td {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.35rem 0.75rem;
    width: 100%;
    padding: 0.35rem 0;
    border: none;
  }

  .ratings-table .ratings-row td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .ratings-table .ratings-row td[data-label="App"]::before {
    display: none;
  }

  .ratings-table .ratings-row td[data-label="App"] {
    display: block !important;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
  }

  .ratings-latest-review {
    max-width: none;
  }
}
