/* Reset & Core Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --bg-main: #090a0f;
  --bg-card: rgba(18, 22, 34, 0.85);
  --bg-card-hover: rgba(26, 32, 50, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);

  --accent-cyan: #00f2ff;
  --accent-magenta: #ff007f;
  --accent-gold: #ffd700;
  --accent-purple: #9d4edd;
  --accent-green: #10b981;

  --tier-s-plus: linear-gradient(135deg, #ffd700 0%, #ff8800 100%);
  --tier-s: linear-gradient(135deg, #00f2ff 0%, #0077ff 100%);
  --tier-a: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  --tier-b: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --tier-c: linear-gradient(135deg, #64748b 0%, #475569 100%);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-lg: 20px;
  --radius-md: 14px;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-main);
  font-family: 'Tajawal', sans-serif;
  color: var(--text-main);
  direction: rtl;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 242, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 0, 127, 0.05) 0%, transparent 40%);
}

/* App Container */
.app-container {
  min-height: 100vh;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.app-container.hidden {
  display: none !important;
}

/* Modal Overlay Global */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 12, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

/* Onboarding & Details Card */
.modal-card {
  width: 100%;
  max-width: 480px;
  background: rgba(20, 25, 40, 0.95);
  border: 1px solid rgba(0, 242, 255, 0.25);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 242, 255, 0.15);
  position: relative;
  animation: cardPop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.details-card {
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  border-color: rgba(255, 0, 127, 0.3);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8), 0 0 35px rgba(255, 0, 127, 0.15);
}

@keyframes cardPop {
  0% { transform: scale(0.92) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.card-badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(0, 242, 255, 0.1);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Onboarding Form */
.onboarding-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: right;
}

.input-group label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(10, 14, 24, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-magenta) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 242, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Header UI */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2.2rem;
  background: rgba(255, 0, 127, 0.15);
  border: 1px solid var(--accent-magenta);
  padding: 8px;
  border-radius: 16px;
}

.logo-text h2 {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.2;
}

.logo-text span {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-weight: 700;
}

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 50px;
}

.user-avatar {
  font-size: 1.2rem;
}

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

.user-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.user-fullname {
  font-size: 0.95rem;
  color: var(--accent-gold);
  font-weight: 800;
}

.btn-icon-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 4px;
}

.btn-voice {
  background: rgba(0, 242, 255, 0.12);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 10px 16px;
  border-radius: 50px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-voice:active {
  transform: scale(0.95);
  background: var(--accent-cyan);
  color: #000;
}

/* Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg, rgba(20, 28, 48, 0.9) 0%, rgba(35, 18, 50, 0.9) 100%);
  border: 1px solid rgba(0, 242, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.banner-content h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.banner-content p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.banner-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.banner-badge span {
  background: rgba(255, 0, 127, 0.15);
  border: 1px solid var(--accent-magenta);
  color: var(--accent-magenta);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-btn.active {
  background: rgba(0, 242, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
}

.cat-btn:active {
  transform: scale(0.96);
}

/* Filter Toolbar */
.filter-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  background: rgba(18, 22, 34, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-cyan);
}

.tier-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tier-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.tier-pill {
  flex: 0 0 auto;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.tier-pill.active {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.tier-s-plus.active { background: var(--accent-gold); color: #000; border-color: var(--accent-gold); }
.tier-s.active { background: var(--accent-cyan); color: #000; border-color: var(--accent-cyan); }
.tier-a.active { background: var(--accent-purple); color: #fff; border-color: var(--accent-purple); }

/* Main Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

.results-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-weight: 700;
}

.sort-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sort-box select {
  background: rgba(18, 22, 34, 0.9);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  outline: none;
}

/* Devices Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* Individual Device Card */
.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}

.device-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 242, 255, 0.4);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 255, 0.1);
  background: var(--bg-card-hover);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.device-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-icon {
  font-size: 2rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 14px;
}

.device-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
}

.device-cat {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Tier Badges */
.badge-tier {
  padding: 6px 14px;
  border-radius: 50px;
  font-weight: 900;
  font-size: 0.85rem;
  color: #000;
  letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.badge-tier.tier-s-plus { background: var(--tier-s-plus); color: #000; }
.badge-tier.tier-s { background: var(--tier-s); color: #000; }
.badge-tier.tier-a { background: var(--tier-a); color: #fff; }
.badge-tier.tier-b { background: var(--tier-b); color: #fff; }
.badge-tier.tier-c { background: var(--tier-c); color: #fff; }

/* Metrics Bar */
.power-meter {
  margin-bottom: 16px;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.meter-header .label { color: var(--text-muted); }
.meter-header .value { color: var(--accent-gold); }

.bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-magenta) 100%);
}

/* Quick Specs Grid */
.specs-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.82rem;
}

.spec-item {
  display: flex;
  flex-direction: column;
}

.spec-item .s-label { color: var(--text-muted); font-size: 0.72rem; }
.spec-item .s-val { color: #fff; font-weight: 700; }

.card-footer-btns {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.btn-details {
  flex: 1;
  padding: 10px;
  background: rgba(0, 242, 255, 0.1);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-details:hover {
  background: var(--accent-cyan);
  color: #000;
}

/* Close Button */
.btn-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal Details Content */
.details-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.details-icon {
  font-size: 2.8rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: 20px;
}

.details-title h2 {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
}

.details-title span {
  font-size: 0.88rem;
  color: var(--accent-gold);
}

.fps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.fps-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: center;
}

.fps-card .game-name { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.fps-card .fps-val { font-size: 1.4rem; font-weight: 900; color: var(--accent-cyan); }

.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}

.pros-box, .cons-box {
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.pros-box { background: rgba(16, 185, 129, 0.1); border: 1px solid var(--accent-green); }
.cons-box { background: rgba(255, 0, 127, 0.1); border: 1px solid var(--accent-magenta); }

.pros-box h4 { color: var(--accent-green); margin-bottom: 8px; }
.cons-box h4 { color: var(--accent-magenta); margin-bottom: 8px; }

/* Compare View Layout */
.compare-view {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.compare-header {
  text-align: center;
  margin-bottom: 24px;
}

.compare-header h3 { font-size: 1.5rem; color: var(--accent-cyan); margin-bottom: 6px; }
.compare-header p { font-size: 0.9rem; color: var(--text-muted); }

.compare-selectors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.select-box {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.select-box label { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }

.custom-select {
  width: 100%;
  padding: 14px;
  background: rgba(10, 14, 24, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.vs-badge {
  font-size: 1.4rem;
  font-weight: 900;
  background: var(--accent-magenta);
  color: #fff;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.5);
}

.compare-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-right {
    justify-content: space-between;
  }
  .welcome-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .banner-badge {
    flex-direction: row;
    align-items: center;
  }
  .compare-results {
    grid-template-columns: 1fr;
  }
  .pros-cons {
    grid-template-columns: 1fr;
  }
}