/* ==========================================================================
   GSMCritic Ranking Page — Clean & Elegant
   ========================================================================== */

/* ---- Reset conflicting old classes ---- */
.rk-page .item, .rk-page .long-list, .rk-page .phone-image { display: block !important; }

/* ---- Root ---- */
.rk-page {
  --p: #476d99; --pd: #2e4a6e; --s: #5a82b0;
  --bg: #fff; --bg2: #f4f6f8; --bdr: #e2e6ea;
  --tx: #1a1a2e; --tx2: #6b7280;
  --gr: #10b981; --rd: #ef4444; --gd: #f59e0b;
  --r: 10px; --sh: 0 1px 3px rgba(0,0,0,.08);
  font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  color: var(--tx);
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- Back banner ---- */
.rk-back-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #476d99 0%, #3a5c82 100%);
  padding: 8px 18px;
  border-radius: 20px;
  margin: 10px auto 0;
  display: block;
  text-align: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  width: fit-content;
  margin: 10px auto;
}
.rk-back-icon { font-size: 18px; }
.rk-back-text { text-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* ---- Banner title area ---- */
.rk-header {
  background: linear-gradient(135deg, #476d99 0%, #3a5c82 50%, #5a82b0 100%);
  padding: 24px 20px 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.rk-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.rk-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 2px;
  color: #fff !important;
}
.rk-subtitle {
  margin: 0;
  font-size: 13px;
  opacity: .8;
}

/* ---- Sort control ---- */
.rk-controls {
  margin-top: 14px;
  min-width: 220px;
}
.rk-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .7;
  margin-bottom: 4px;
}
.rk-select {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.rk-select option { color: #1a1a2e; background: #fff; }

/* ---- Filter bar ---- */
.rk-filters {
  margin-bottom: 20px;
}
.rk-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg2);
  border-radius: var(--r);
}
.rk-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.rk-year-row {
  align-items: center;
}
.rk-year-label { font-weight: 600; font-size: 13px; }
.rk-year-pills { display: flex; gap: 6px; }
.rk-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--tx2);
  border: 1px solid var(--bdr);
  transition: all .2s ease;
  user-select: none;
}
.rk-pill:hover { border-color: var(--p); color: var(--p); transform: translateY(-1px); }
.rk-pill-active {
  background: var(--p) !important;
  color: #fff !important;
  border-color: var(--p) !important;
  box-shadow: 0 2px 8px rgba(71,109,153,.35);
}

/* Spec unit and score slash */
.rk-spec-unit { font-weight: 400; font-size: 12px; color: var(--tx2); }
.rk-score-slash { font-weight: 400; font-size: 12px; color: var(--tx2); }
.rk-toggle-label { font-weight: 600; }

/* ---- Filter toggles ---- */
.rk-filter-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}
.rk-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}
.rk-toggle input { accent-color: var(--p); }
.rk-price-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}
.rk-price-input {
  width: 65px;
  padding: 4px 6px;
  border: 1px solid var(--bdr);
  border-radius: 6px;
  font-size: 13px;
}
.rk-currency-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.rk-price-select {
  padding: 3px 6px;
  border: 1px solid var(--bdr);
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
}
.rk-btn {
  padding: 7px 18px;
  background: var(--p);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}
.rk-btn:hover { background: var(--pd); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(71,109,153,.3); }

/* ---- Table wrapper ---- */
.rk-table-wrap {
  background: var(--bg);
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
  margin-bottom: 32px;
}

/* ---- Table ---- */
.rk-table {
  width: 100%;
  border-collapse: collapse;
}
.rk-table thead tr th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tx2);
  background: var(--bg2);
  border-bottom: 2px solid var(--bdr);
}
.rk-table thead tr th a,
.rk-table thead tr th * { color: var(--tx2) !important; }

.rk-table tbody tr { border-bottom: 1px solid var(--bdr); transition: all .2s ease; }
.rk-table tbody tr:hover { background: rgba(71,109,153,.05); transform: translateY(-1px); }
.rk-table tbody tr:last-child { border-bottom: none; }

.rk-table td {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--tx);
  vertical-align: middle;
}

/* ---- Column widths ---- */
.rk-th-rank { width: 48px; text-align: center; }
.rk-th-spec { width: 80px; text-align: center; }
.rk-th-score { width: 80px; text-align: center; }
.rk-th-user { width: 70px; text-align: center; }
.rk-th-price { width: 90px; text-align: right; }
.rk-th-action { width: 70px; }

/* ---- Rank column ---- */
.rk-c-rank {
  text-align: center;
  font-weight: 800;
  font-size: 17px;
  color: var(--p);
}

/* ---- Phone cell ---- */
.rk-phone {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rk-phone img {
  width: 28px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg2);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: transform .2s ease;
}
.rk-table tbody tr:hover .rk-phone img { transform: scale(1.05); }
.rk-phone-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rk-click { cursor: pointer; }
.rk-muted { opacity: .55; }
.rk-company {
  font-size: 11px;
  color: var(--tx2);
  font-weight: 500;
}
.rk-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--tx);
}
.rk-flag { font-size: 14px; margin-left: 3px; }

/* ---- Score column ---- */
.rk-c-score {
  text-align: center;
  font-weight: 800;
  font-size: 17px;
}
.rk-score-cam { color: var(--p); }
.rk-green { color: var(--gr); }
.rk-red { color: var(--rd); }

/* ---- Score badges ---- */
.rk-score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 14px;
  transition: transform .2s ease;
}
.rk-score-badge:hover { transform: scale(1.1); }
.rk-score-high { background: #d1fae5; color: #065f46; }
.rk-score-mid { background: #e0f2fe; color: #0c4a6e; }
.rk-score-low { background: #fee2e2; color: #991b1b; }
.rk-score-tiny { background: #f3f4f6; color: #4b5563; font-size: 12px; }

/* ---- Spec column ---- */
.rk-c-spec {
  text-align: center;
  font-size: 13px;
  color: var(--tx);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rk-th-spec {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- User column (camera mode only) ---- */
.rk-c-user {
  text-align: center;
  font-size: 13px;
  color: var(--tx2);
}

/* ---- Price column ---- */
.rk-c-price {
  text-align: right;
  font-size: 13px;
  color: var(--tx2);
}

/* ---- Action ---- */
.rk-rate-btn {
  padding: 5px 14px;
  background: var(--p);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.rk-rate-btn:hover { background: var(--pd); }

/* ---- Inline rate modal ---- */
.rk-rate-modal { background: var(--bg2); }
.rk-rate-modal td { padding: 0 !important; }

/* ---- Inline rate modal (mobile) ---- */
.rk-rate-inline {
  display: none;
  margin-top: 8px;
  padding: 12px;
  background: var(--bg2);
  border-radius: 8px;
}
.rk-rate-checked {
  color: var(--gr);
  font-weight: 600;
  font-size: 13px;
}
.rk-rate-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}
.rk-rate-title {
  font-weight: 700;
  font-size: 13px;
  width: 100%;
}
.rk-rate-select {
  padding: 5px 8px;
  border: 1px solid var(--bdr);
  border-radius: 6px;
  font-size: 13px;
}
.rk-rate-submit {
  padding: 5px 14px;
  background: var(--p);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.rk-close-btn {
  padding: 5px 14px;
  background: transparent;
  color: var(--tx);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.rk-msg-fail { font-size: 12px; color: var(--rd); font-weight: 600; }
.rk-thanks { font-size: 13px; color: var(--gr); font-weight: 600; }
.hidden { display: none; }

/* ---- Hint ---- */
.rk-hint {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--tx2);
  background: rgba(245,158,11,.08);
  border-radius: 0 0 var(--r) var(--r);
}
.rk-hint strong { color: var(--gd); }

/* ---- Mobile table scroll ---- */
.rk-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.rk-table { min-width: 400px; }
.rk-table-mobile { min-width: 320px; }

/* ---- Empty state ---- */
.rk-empty {
  text-align: center;
  padding: 48px 20px;
}
.rk-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.rk-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--tx);
  margin-bottom: 6px;
}
.rk-empty-text {
  font-size: 14px;
  color: var(--tx2);
}

/* ---- Hidden state ---- */
.rk-hidden {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================================================
   MOBILE — Beautiful ranking view
   ========================================================================== */

/* Mobile page padding */
.rk-mobile-page { padding: 0; }
.rk-back-banner-mobile { max-width: 90%; margin: 8px auto; }
.rk-mobile-bar { padding: 10px 12px; }
.rk-select-mobile { font-size: 13px; padding: 6px 10px; }

/* Mobile table sizing */
.rk-table-mobile thead th { font-size: 10px; padding: 8px 8px; }
.rk-table-mobile td { padding: 8px 8px; font-size: 13px; }
.rk-c-rank { font-size: 15px; }
.rk-c-score { font-size: 15px; }

/* ---- Mobile hero header ---- */
.rk-header-hero {
  padding: 40px 16px 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.rk-header-hero::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -30%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.rk-header-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
}
.rk-header-hero .rk-title {
  font-size: 26px;
  line-height: 1.2;
  margin-bottom: 6px;
}
.rk-header-hero .rk-subtitle {
  font-size: 15px;
  opacity: .85;
  margin-bottom: 16px;
}
.rk-header-hero .rk-controls {
  margin-top: 0;
  min-width: unset;
  width: 100%;
  max-width: 100%;
}

/* ---- Mobile sort select (white card) ---- */
.rk-header-hero .rk-select {
  background: rgba(255,255,255,.2) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
}
.rk-header-hero .rk-label { color: rgba(255,255,255,.8); }

/* ---- Mobile filter section ---- */
.rk-mobile-filters {
  padding: 0 12px;
  margin-bottom: 16px;
}
.rk-mobile-filters .rk-filter-bar {
  background: #f7f8fa;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.rk-mobile-filters .rk-label { color: #555; opacity: 1; }
.rk-mobile-filters .rk-year-pill { padding: 8px 18px; border-radius: 20px; transition: all .2s; }

/* Year pills mobile */
.rk-pill { padding: 6px 14px; font-size: 12px; }
@media(max-width: 768px) { .rk-pill { font-size: 13px; } }

/* Filter toggles mobile */
.rk-filter-toggles { gap: 12px; }
.rk-toggle { font-size: 12px; }
@media(max-width: 768px) {
  .rk-toggle { font-size: 13px; }
  .rk-price-group { font-size: 13px; }
}

/* Price input mobile */
.rk-price-input { padding: 6px 8px; border-radius: 8px; }

/* ---- Mobile table header ---- */
.rk-table-mobile thead th {
  font-size: 10px;
  padding: 10px 8px;
  background: #f1f5f9;
}

/* ---- Mobile table rows ---- */
.rk-table-mobile td {
  padding: 12px 8px;
  font-size: 13px;
}

/* Phone cell mobile */
.rk-table-mobile .rk-phone { gap: 8px; }
.rk-table-mobile .rk-phone img {
  width: 24px;
  height: 32px;
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.rk-company { font-size: 10px; }
.rk-name { font-size: 13px; }

/* Score badge mobile */
.rk-table-mobile .rk-score-badge {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

/* ---- Mobile specific ---- */
@media(max-width: 768px) {
  .rk-title { font-size: 18px; }
  .rk-header { padding: 16px 14px 14px; }
  .rk-controls { margin-top: 10px; }
  .rk-filter-bar { gap: 8px; padding: 10px 14px; }
  .rk-filter-row { gap: 6px; }
  .rk-filter-toggles { min-width: unset; }
  .rk-table td, .rk-table th { padding: 8px 10px; }
  .rk-phone img { width: 24px; height: 32px; }
  .rk-spec-unit { font-size: 11px; }
  .rk-score-slash { font-size: 11px; }
}

@media (max-width: 768px) {
  .rk-header-hero .rk-title { font-size: 24px; }
  .rk-header-hero .rk-subtitle { font-size: 14px; }
}

/* ---- Sort select overrides for mobile sections ---- */
.rk-mobile-bar .rk-select,
.rk-mobile-filters .rk-select {
  color: #1a1a2e !important;
  -webkit-text-fill-color: #1a1a2e !important;
  background: #fff !important;
  border: 1px solid #ddd !important;
  border-radius: 10px !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23666'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
}
