/* ========================================
   Apple One Pricing — Design System
   ======================================== */

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-border: rgba(255, 255, 255, 0.08);

  --text-primary: #f0f0f5;
  --text-secondary: #8e8ea0;
  --text-muted: #5a5a6e;

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;

  --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  --gradient-green: linear-gradient(135deg, #10b981, #34d399);
  --gradient-amber: linear-gradient(135deg, #f59e0b, #fbbf24);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(255, 255, 255, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 0 30px rgba(59, 130, 246, 0.15);
  --shadow-glow-purple: 0 0 30px rgba(139, 92, 246, 0.15);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --bg-header: rgba(10, 10, 15, 0.85);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: rgba(0, 0, 0, 0.03);
  --bg-glass: rgba(255, 255, 255, 0.75);
  --bg-glass-border: rgba(0, 0, 0, 0.08);
  --bg-header: rgba(248, 250, 252, 0.85);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-accent: rgba(0, 0, 0, 0.15);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* --- Ambient Glow Effects --- */
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.glow-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, transparent 70%);
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  animation: float-glow 12s ease-in-out infinite;
}

.glow-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
  bottom: -100px;
  right: -100px;
  animation: float-glow 15s ease-in-out infinite reverse;
}

.glow-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.08) 0%, transparent 70%);
  bottom: 20%;
  left: -80px;
  animation: float-glow 18s ease-in-out infinite 3s;
}

@keyframes float-glow {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-30px) scale(1.1);
  }
}

/* --- Container --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  position: relative;
  z-index: 1;
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInDown 0.6s ease;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.apple-logo {
  width: 48px;
  height: 48px;
  background: var(--gradient-brand);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow-blue);
}

.header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.5;
}

/* --- Controls --- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  animation: fadeInUp 0.6s ease 0.1s both;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Plan Tabs */
.plan-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 4px;
  backdrop-filter: blur(12px);
}

.plan-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.plan-tab:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.plan-tab.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.1);
}

.tab-icon {
  font-size: 1rem;
}

/* Search */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 180px;
  padding: 8px 12px 8px 36px;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-normal);
  backdrop-filter: blur(12px);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  width: 220px;
}

/* Currency Select */
.currency-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.currency-select-wrapper label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.currency-select-wrapper select {
  padding: 8px 32px 8px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8ea0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--transition-normal);
  backdrop-filter: blur(12px);
}

.currency-select-wrapper select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.currency-select-wrapper select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  backdrop-filter: blur(12px);
  padding: 0;
  outline: none;
}

.theme-toggle:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sun-icon {
  display: none;
}

.moon-icon {
  display: block;
}

[data-theme="light"] .sun-icon {
  display: block;
}

[data-theme="light"] .moon-icon {
  display: none;
}

/* --- Plan Info Cards --- */
.plan-info {
  margin-bottom: 20px;
  animation: fadeInUp 0.6s ease 0.15s both;
}

.plan-card {
  display: none;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  backdrop-filter: blur(16px);
}

.plan-card.active {
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.plan-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.plan-card-icon {
  font-size: 1.3rem;
}

.plan-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.plan-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* --- Stats Bar --- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  animation: fadeInUp 0.6s ease 0.2s both;
}

.stat {
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
  backdrop-filter: blur(12px);
  transition: all var(--transition-normal);
}

.stat:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* --- Table --- */
.table-container {
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.6s ease 0.25s both;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead tr {
  background: var(--bg-header);
  backdrop-filter: blur(16px);
}

th {
  padding: 14px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

th.th-rank {
  width: 48px;
  text-align: center;
}

th.th-country {
  min-width: 180px;
}

th.th-currency {
  width: 100px;
}

th.th-price {
  width: 160px;
}

th.th-converted {
  width: 140px;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

th.sortable:hover {
  color: var(--text-secondary);
}

th.sortable.sort-active {
  color: var(--accent-blue);
}

.th-label {
  margin-right: 6px;
}

.sort-arrows {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  vertical-align: middle;
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

th.sortable:hover .sort-arrows,
th.sortable.sort-active .sort-arrows {
  opacity: 1;
}

.sort-arrow {
  display: block;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

th.sort-active[data-direction="asc"] .sort-asc {
  color: var(--accent-blue);
}

th.sort-active[data-direction="desc"] .sort-desc {
  color: var(--accent-blue);
}

/* Table Body */
tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-normal);
}

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

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody tr.best-row {
  background: rgba(16, 185, 129, 0.04);
}

tbody tr.best-row:hover {
  background: rgba(16, 185, 129, 0.08);
}

td {
  padding: 12px 16px;
  font-size: 0.9rem;
  vertical-align: middle;
}

/* Rank */
.cell-rank {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
}

.rank-1 {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1a2e;
  font-weight: 700;
}

.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #1a1a2e;
  font-weight: 700;
}

.rank-3 {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #1a1a2e;
  font-weight: 700;
}

/* Country */
.cell-country {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.country-flag {
  font-size: 1.35rem;
  line-height: 1;
}

.country-name {
  color: var(--text-primary);
}

/* Currency */
.cell-currency {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Price */
.cell-price {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.price-na {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

/* Converted Price */
.cell-converted {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Best Badge */
.badge-best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--gradient-green);
  color: #052e16;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 8px;
  vertical-align: middle;
  animation: pulseBadge 2s ease-in-out infinite;
}

@keyframes pulseBadge {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3);
  }

  50% {
    box-shadow: 0 0 8px 2px rgba(16, 185, 129, 0.15);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- Footer --- */
.footer {
  text-align: center;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  animation: fadeInUp 0.6s ease 0.3s both;
}

.footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--accent-blue);
}

.dot {
  color: var(--text-muted);
  font-size: 0.6rem;
}

/* --- Animations --- */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Row animation */
tbody tr {
  animation: fadeIn 0.3s ease;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .container {
    padding: 24px 16px 40px;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .header-desc {
    font-size: 0.9rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-left,
  .controls-right {
    justify-content: center;
    flex-wrap: wrap;
  }

  .plan-tabs {
    width: 100%;
    justify-content: center;
  }

  .plan-tab span:not(.tab-icon) {
    display: none;
  }

  .plan-tab {
    padding: 8px 12px;
    flex: 1;
    justify-content: center;
  }

  .tab-icon {
    font-size: 1.2rem;
  }

  .search-box {
    flex: 1;
    min-width: 140px;
  }

  .search-box input {
    width: 100%;
  }

  .search-box input:focus {
    width: 100%;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .plan-card.active {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .table-container {
    border-radius: var(--radius-md);
    overflow-x: auto;
  }

  table {
    min-width: 580px;
  }

  th,
  td {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .header-brand {
    gap: 12px;
  }

  .apple-logo {
    width: 40px;
    height: 40px;
  }

  .apple-logo svg {
    width: 24px;
    height: 24px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .stats-bar {
    gap: 8px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat-value {
    font-size: 1rem;
  }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}