@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Reset & Base ──────────────────────────────────────────────────────── */

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

:root {
  --bg-primary: #0a0b0f;
  --bg-secondary: #12141a;
  --bg-card: #1a1d26;
  --bg-card-hover: #22262f;
  --bg-glass: rgba(26, 29, 38, 0.7);
  --bg-glass-light: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #f0f0f5;
  --text-secondary: #8b8fa3;
  --text-muted: #5a5e72;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* ─── Layout ────────────────────────────────────────────────────────────── */

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Header ────────────────────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 11, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-glass-light);
}

.nav-link.active {
  color: var(--accent);
}

/* ─── Page Title ────────────────────────────────────────────────────────── */

.page-header {
  padding: 32px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

.listing-count {
  background: var(--bg-card);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
}

/* ─── Controls Bar & Add Listing ─────────────────────────────────────── */

.add-listing-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 24px;
}

.add-listing-form {
  display: flex;
  gap: 12px;
}

.add-listing-form .filter-input {
  flex: 1;
}

.collect-status {
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.sort-select, .filter-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border var(--transition);
}

.sort-select:focus, .filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-input {
  flex: 1;
  min-width: 100px;
}


.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ─── Listings Grid ─────────────────────────────────────────────────────── */

.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}

/* ─── Listing Card ──────────────────────────────────────────────────────── */

.listing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

.listing-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.view-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-left: auto;
}

.btn-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-glass-light);
}

.btn-toggle.active {
  background: var(--accent);
  color: white;
}

/* Excel Style Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.excel-table th {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--transition);
}

.excel-table th:hover {
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
}

.excel-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.excel-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

.excel-table tbody tr:hover {
  background: var(--bg-glass-light);
}

.excel-table tbody tr:last-child td {
  border-bottom: none;
}

.listing-card:hover .card-image img {
  transform: scale(1.05);
}

.card-image {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 2rem;
}

.card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.card-body {
  padding: 16px 20px 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

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

.card-spec {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-spec-icon {
  font-size: 0.9rem;
  opacity: 0.6;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-seller {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.card-actions {
  display: flex;
  gap: 6px;
}

.card-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.card-action-btn:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.card-action-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ─── Listing Detail Page ───────────────────────────────────────────────── */

.detail-container {
  max-width: 1000px;
  margin: 0 auto;
  padding-bottom: 64px;
}

.detail-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.phone-display {
  background: var(--blue);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
}

.version-selector-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.version-selector-container label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.back-nav {
  margin-bottom: 20px;
}

.detail-gallery {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  margin-bottom: 24px;
}

.gallery-main {
  height: 500px;
  cursor: pointer;
  position: relative;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-secondary);
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-nav:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-50%) scale(1.1);
}

.gallery-nav.prev { left: 16px; }
.gallery-nav.next { right: 16px; }

.gallery-counter {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.gallery-thumbs {
  display: flex;
  gap: 4px;
  padding: 8px;
  overflow-x: auto;
  background: var(--bg-card);
}

.gallery-thumbs::-webkit-scrollbar {
  height: 4px;
}

.gallery-thumbs::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

.gallery-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  opacity: 0.6;
}

.gallery-thumb.active {
  border-color: var(--accent);
  opacity: 1;
}

.gallery-thumb:hover {
  opacity: 1;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Detail content layout */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.spec-row:nth-child(odd) {
  background: var(--bg-glass-light);
}

.spec-label {
  color: var(--text-secondary);
  font-weight: 400;
}

.spec-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
}

.detail-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -0.03em;
}

.detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.detail-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.description-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ─── Comparison Page ──────────────────────────────────────────────────── */

.compare-container {
  padding-bottom: 64px;
}

.compare-grid {
  display: grid;
  gap: 20px;
}

.compare-grid[data-cols="2"] { grid-template-columns: 1fr 1fr; }
.compare-grid[data-cols="3"] { grid-template-columns: 1fr 1fr 1fr; }
.compare-grid[data-cols="4"] { grid-template-columns: 1fr 1fr 1fr 1fr; }

@media (max-width: 900px) {
  .compare-grid { grid-template-columns: 1fr !important; }
}

.compare-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.compare-image {
  height: 200px;
  overflow: hidden;
}

.compare-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-body {
  padding: 20px;
}

.compare-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.compare-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 16px;
}

.compare-specs .spec-row {
  grid-template-columns: 1fr;
}

/* Highlight differences */
.spec-diff {
  background: rgba(99, 102, 241, 0.08) !important;
}

.spec-best {
  color: var(--green) !important;
  font-weight: 700 !important;
}

/* ─── Empty State ──────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  max-width: 400px;
  margin: 0 auto;
  font-size: 0.9rem;
  line-height: 1.6;
}

.empty-state code {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
}

/* ─── Lightbox ──────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ─── Compare floating bar ──────────────────────────────────────────────── */

.compare-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.3);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
}

.compare-bar.visible {
  transform: translateX(-50%) translateY(0);
}

.compare-bar-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.compare-bar-count {
  font-weight: 700;
  color: var(--accent);
}

/* ─── Animations ────────────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.listing-card {
  animation: fadeInUp 0.4s ease-out both;
}

.listing-card:nth-child(2) { animation-delay: 0.05s; }
.listing-card:nth-child(3) { animation-delay: 0.1s; }
.listing-card:nth-child(4) { animation-delay: 0.15s; }
.listing-card:nth-child(5) { animation-delay: 0.2s; }
.listing-card:nth-child(6) { animation-delay: 0.25s; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ─── Toasts ────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease-out;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* --- Modals --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalScale 0.3s ease-out;
}

@keyframes modalScale {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-form .form-group {
  margin-bottom: 16px;
}

.modal-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.modal-form .filter-input {
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* --- Highlights --- */
.listing-card.new {
  border-left: 4px solid var(--accent);
  position: relative;
}

.new-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 5;
}

.excel-table tr.new td:first-child {
  border-left: 4px solid var(--accent) !important;
}

.excel-table tr.new td {
  background: rgba(0, 243, 255, 0.05) !important;
}
/* ─── Auth Status ───────────────────────────────────────────────────────── */

.auth-status {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: 40px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 1000;
  border: 1px solid var(--border);
  animation: slideInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideInUp {
  from { transform: translateY(100%) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.auth-status span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-status strong {
  color: var(--text-primary);
  margin-left: 4px;
}

#logout-btn {
  background: var(--bg-glass-light);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all var(--transition);
}

#logout-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: white;
}
