:root {
  --bg-dark: #08090d;
  --bg-card: rgba(18, 20, 29, 0.7);
  --bg-card-hover: rgba(28, 32, 48, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-neon: rgba(0, 240, 255, 0.3);
  
  --primary-cyan: #00f0ff;
  --primary-purple: #7000ff;
  --accent-amber: #ffb703;
  --accent-green: #00ff88;
  --accent-pink: #ff0055;
  
  --text-main: #f0f2f8;
  --text-muted: #9499b1;
  --text-dark: #61667d;

  --font-family: 'Inter', 'Noto Sans Sinhala', -apple-system, sans-serif;
  --font-title: 'Outfit', 'Noto Sans Sinhala', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow-x: hidden;
  min-height: 100vh;
  line-height: 1.6;
}

/* Background Canvas */
#vfx-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 9, 13, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 12px 24px;
}

.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

.brand-icon {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(112, 0, 255, 0.3));
  border: 1px solid var(--border-neon);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-cyan);
}

.pulse-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-cyan);
  box-shadow: 0 0 10px var(--primary-cyan);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.7); }
  70% { transform: scale(1.2); box-shadow: 0 0 0 10px rgba(0, 240, 255, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.logo-main {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
}

.logo-main .highlight {
  color: var(--primary-cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.logo-sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

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

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: 30px;
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: var(--font-family);
  transition: all 0.3s ease;
}

.search-box input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

.nav-actions {
  display: flex;
  gap: 12px;
}

.nav-btn {
  padding: 9px 16px;
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.gemini-btn {
  background: linear-gradient(135deg, rgba(112, 0, 255, 0.3), rgba(0, 240, 255, 0.3));
  border: 1px solid var(--border-neon);
  color: #ffffff;
}

.gemini-btn:hover {
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
  transform: translateY(-1px);
}

/* Hero Section */
.hero-section {
  max-width: 1000px;
  margin: 40px auto 20px;
  text-align: center;
  padding: 0 20px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: var(--primary-cyan);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.hero-title {
  font-family: var(--font-title);
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 14px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 720px;
  margin: 0 auto 30px;
}

/* Filter Chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip {
  padding: 8px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.chip:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.chip.active {
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.3);
}

/* Main Content & Grid */
.main-content {
  max-width: 1300px;
  margin: 40px auto;
  padding: 0 24px;
}

.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.results-count {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

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

.sort-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
}

/* Phones Grid Cards */
.phones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 24px;
}

.phone-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 20px;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.phone-card:hover {
  transform: translateY(-8px);
  background: var(--bg-card-hover);
  border-color: var(--border-neon);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 240, 255, 0.15);
}

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

.card-brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary-cyan);
  background: rgba(0, 240, 255, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
}

.card-rating {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 38px;
}

.specs-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-main);
}

.spec-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-cyan);
  flex-shrink: 0;
}

.card-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-price-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.card-price-usd {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
}

.card-price-lkr {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card-btn {
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
}

.btn-3d {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(112, 0, 255, 0.2));
  border: 1px solid var(--border-neon);
  color: #ffffff;
}

.btn-3d:hover {
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple));
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.btn-ai {
  background: rgba(255, 183, 3, 0.1);
  border: 1px solid rgba(255, 183, 3, 0.3);
  color: var(--accent-amber);
}

.btn-ai:hover {
  background: rgba(255, 183, 3, 0.25);
  box-shadow: 0 0 12px rgba(255, 183, 3, 0.3);
}

/* Modal System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 5, 8, 0.85);
  backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0f1118;
  border: 1px solid var(--border-neon);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 240, 255, 0.2);
  position: relative;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.full-modal {
  width: 1100px;
  height: 650px;
}

.drawer-modal {
  width: 720px;
  height: 80vh;
}

.wide-modal {
  width: 950px;
  max-height: 85vh;
  padding: 30px;
}

.small-modal {
  width: 440px;
  padding: 30px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--accent-pink);
  color: #ffffff;
  border-color: transparent;
}

/* 3D Modal Grid */
.modal-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  height: 100%;
}

.viewport-column {
  background: radial-gradient(circle at center, rgba(16, 20, 36, 1) 0%, rgba(8, 9, 13, 1) 100%);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  position: relative;
}

.viewport-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-3d {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary-cyan);
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--border-neon);
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 1px;
}

.drag-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.three-container {
  flex: 1;
  width: 100%;
  min-height: 360px;
  cursor: grab;
}

.three-container:active {
  cursor: grabbing;
}

.viewport-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border-glass);
}

.view-presets {
  display: flex;
  gap: 8px;
}

.preset-btn {
  flex: 1;
  padding: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn.active, .preset-btn:hover {
  background: rgba(0, 240, 255, 0.2);
  color: var(--primary-cyan);
  border-color: var(--primary-cyan);
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.color-pills {
  display: flex;
  gap: 8px;
}

.color-pill {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.color-pill:hover, .color-pill.active {
  transform: scale(1.25);
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Specs Column Right */
.specs-column {
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
}

.phone-brand-tag {
  color: var(--primary-cyan);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.phone-modal-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 4px;
}

.phone-modal-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.price-rating-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 12px 18px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.price-usd {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-green);
  display: block;
}

.price-lkr {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rating-block {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-amber);
}

.rating-max {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.specs-details-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 20px;
}

.spec-detail-row {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--primary-cyan);
}

.spec-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.spec-val {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 500;
}

.action-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.primary-glow {
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple));
  border: none;
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4);
}

.primary-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 240, 255, 0.6);
}

.danger-btn {
  background: rgba(255, 0, 85, 0.15);
  border: 1px solid rgba(255, 0, 85, 0.4);
  color: var(--accent-pink);
}

/* AI Sinhala Drawer Modal */
.ai-modal-header {
  padding: 24px 30px 16px;
  border-bottom: 1px solid var(--border-glass);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-amber);
  margin-bottom: 6px;
}

.ai-model-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ai-content-body {
  padding: 24px 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ai-card {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--border-glass);
}

.glow-cyan { border-left: 4px solid var(--primary-cyan); }
.glow-purple { border-left: 4px solid var(--primary-purple); }
.glow-amber { border-left: 4px solid var(--accent-amber); }

.ai-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.sinhala-text {
  font-family: 'Noto Sans Sinhala', sans-serif;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #e0e4f0;
  white-space: pre-line;
}

.ai-chat-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  padding: 18px;
  border-radius: 16px;
  margin-top: 10px;
}

.ai-chat-box h3 {
  font-size: 0.85rem;
  margin-bottom: 12px;
  color: var(--text-main);
}

.chat-input-wrapper {
  display: flex;
  gap: 10px;
}

.chat-input-wrapper input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-family: 'Noto Sans Sinhala', sans-serif;
  outline: none;
}

.chat-send-btn {
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--primary-cyan);
  color: #000000;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.chat-response-box {
  margin-top: 14px;
  padding: 12px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 10px;
  font-family: 'Noto Sans Sinhala', sans-serif;
  font-size: 0.88rem;
  line-height: 1.6;
}

.hidden { display: none; }

/* Compare Table */
.compare-header h2 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.compare-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

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

.compare-table th, .compare-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.85rem;
}

.compare-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--primary-cyan);
  font-weight: 700;
}

/* Key Modal */
.key-modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.key-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.key-input-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.key-input-block input {
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-neon);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

.key-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.key-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Responsive */
@media (max-width: 900px) {
  .full-modal {
    width: 95vw;
    height: 85vh;
  }
  .modal-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .viewport-column {
    height: 320px;
  }
  .hero-title {
    font-size: 1.8rem;
  }
  .nav-container {
    flex-wrap: wrap;
  }
  .search-box {
    order: 3;
    max-width: 100%;
    margin-top: 8px;
  }
}
