/* === Cardex Go — Main Stylesheet === */

:root {
  /* Dark theme (default) */
  --bg: #0f1117;
  --bg-secondary: #1a1d29;
  --surface: #1e2130;
  --surface-hover: #262a3d;
  --border: #2a2e3f;
  --text: #e1e4eb;
  --text-secondary: #8b8fa3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --gold: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
  --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-secondary: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f0f0f2;
  --border: #e5e5e7;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --shadow: rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* === Navbar === */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.5px;
}

.navbar-logo span {
  color: var(--text);
  font-weight: 400;
}

.navbar-search {
  flex: 1;
  max-width: 400px;
  margin: 0 24px;
  position: relative;
}

.navbar-search input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

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

.navbar-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 14px;
}

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

.navbar-actions button, .navbar-actions select {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.navbar-actions button:hover, .navbar-actions select:hover {
  background: var(--surface-hover);
}

.btn-login {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.btn-login:hover {
  background: var(--accent-hover) !important;
}

/* === Search History Dropdown === */
.search-history {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 4px 12px var(--shadow);
  display: none;
  z-index: 50;
}

.search-history.show { display: block; }

.search-history-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-history-item:hover {
  background: var(--surface-hover);
}

.search-history-item .remove {
  opacity: 0;
  color: var(--red);
  font-size: 12px;
}

.search-history-item:hover .remove { opacity: 1; }

/* === Brand Tabs === */
.brand-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand-tab {
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.brand-tab.active, .brand-tab:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === Product Grid === */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  padding: 24px;
}

.product-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow);
}

.product-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-secondary);
}

.product-card-body {
  padding: 12px;
}

.product-card-name {
  font-size: 13px;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  min-height: 36px;
}

.product-card-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  margin-top: 6px;
}

.product-card-add {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.product-card-add:hover {
  background: var(--accent);
  color: #fff;
}

/* === Currency Selector === */
.currency-selector {
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.currency-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
}

.currency-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === Loading === */
.loading {
  display: flex;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px;
}

.pagination button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.pagination button:hover { background: var(--surface-hover); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { padding: 8px 16px; color: var(--text-secondary); font-size: 14px; }

/* === Footer === */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; }
  .navbar-search { margin: 0 12px; }
  .product-grid { padding: 16px; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .brand-tabs { padding: 12px 16px; overflow-x: auto; }
}

@media (max-width: 480px) {
  .navbar-actions .lang-select, .navbar-actions .theme-toggle { display: none; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}
