/* ========================================================
   KeysShop — Global Stylesheet
   ======================================================== */

:root {
  --bg:        #0f0f13;
  --surface:   #1a1a24;
  --surface2:  #242430;
  --border:    #2e2e3e;
  --accent:    #7c5cfc;
  --accent-h:  #9b80ff;
  --success:   #22c55e;
  --danger:    #ef4444;
  --text:      #e8e8f0;
  --muted:     #8888a8;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }

/* ---- Layout ---- */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* ---- Header ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.logo { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.logo:hover { text-decoration: none; color: var(--accent-h); }

nav a {
  color: var(--muted); font-size: 0.9rem;
  transition: color .2s;
}
nav a:hover { color: var(--text); text-decoration: none; }

/* ---- Hero ---- */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}
.hero h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 8px; }
.hero p  { color: var(--muted); font-size: 1.05rem; }

/* ---- Category filter bar ---- */
.toolbar-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  flex: 1;
}
.filter-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted); font-size: 0.85rem;
  padding: 5px 14px; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
  white-space: nowrap;
}
.filter-pill:hover  { color: var(--text); border-color: var(--accent); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sort-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 12px;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  transition: border-color .2s;
}
.sort-select:focus { border-color: var(--accent); }

/* ---- Product Grid ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  padding-bottom: 48px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  cursor: default;
}
.product-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  transform: translateY(-2px);
}

/* Thumbnail */
.product-thumb {
  position: relative;
  height: 140px;
  background: linear-gradient(135deg, #1e2230, #2a2f42);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.product-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}
.product-card:hover .product-thumb img { transform: scale(1.06); }
.product-initials {
  font-size: 2.4rem; font-weight: 900;
  color: rgba(255,255,255,.12);
  user-select: none; letter-spacing: -2px;
}
.country-badge {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.6);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem; font-weight: 600; color: #fff;
  backdrop-filter: blur(4px);
}
.price-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--accent);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.75rem; font-weight: 700; color: #fff;
  letter-spacing: .3px;
}

/* Card body */
.product-body {
  padding: 14px 14px 14px;
  display: flex; flex-direction: column; flex: 1;
}
.product-card .product-name {
  font-size: 0.92rem; font-weight: 700;
  line-height: 1.3; margin-bottom: 3px;
  /* 2 lines max */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card .product-cat {
  font-size: 0.72rem; color: var(--muted);
  margin-bottom: 10px;
}
.product-card .denom-list {
  list-style: none; display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: auto; padding-top: 10px;
}
.product-card .denom-list li { flex: 0 0 auto; }
.product-card .denom-list li button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s, transform .1s;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 52px;
}
.product-card .denom-list li button:hover {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.05);
}
.denom-label { font-size: 0.75rem; font-weight: 600; }
.denom-price { font-size: 0.7rem; font-weight: 700; color: var(--accent-h); }
.product-card .denom-list li button:hover .denom-price { color: rgba(255,255,255,.85); }
.out-of-stock {
  font-size: 0.8rem; color: var(--muted); margin-top: auto; padding-top: 10px;
}

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; }
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 10px; }

/* ---- Checkout ---- */
.checkout-wrap { max-width: 540px; margin: 32px auto 64px; }
.checkout-wrap h1 { margin-bottom: 24px; }

.summary-table { width: 100%; border-collapse: collapse; }
.summary-table tr td { padding: 6px 0; font-size: 0.92rem; }
.summary-table tr td:last-child { text-align: right; font-weight: 600; }

label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.optional { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

/* Standalone text/number input (used on checkout) */
.card input[type="text"],
.card input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color .2s;
}
.card input[type="text"]:focus,
.card input[type="number"]:focus {
  border-color: var(--accent);
}

.input-row {
  display: flex; align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.prefix {
  padding: 10px 12px;
  background: var(--surface2);
  color: var(--muted);
  border-right: 1px solid var(--border);
  font-size: 0.95rem;
}
.input-row input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); padding: 10px 12px; font-size: 0.95rem;
}

.hint { font-size: 0.82rem; color: var(--muted); margin-top: 8px; }
.hint.small { font-size: 0.78rem; }

/* ---- Qty picker ---- */
.qty-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.qty-btn {
  width: 36px; height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); font-size: 1.3rem; cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); }
#qty-value {
  width: 64px; text-align: center;
  font-size: 1.1rem; font-weight: 700;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
  outline: none;
}
#qty-value:focus { border-color: var(--accent); }
/* hide native number arrows */
#qty-value::-webkit-inner-spin-button,
#qty-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#qty-value { -moz-appearance: textfield; }
.total-price { font-size: 1.1rem; font-weight: 700; color: var(--accent-h); }

/* ---- TG bot notice ---- */
.tg-notice {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  background: rgba(124, 92, 252, .13);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  color: var(--text); font-size: 0.9rem; font-weight: 500;
  text-decoration: none;
  transition: background .2s;
}
.tg-notice:hover { background: rgba(124,92,252,.25); color: var(--text); text-decoration: none; }
.tg-notice span { color: var(--accent-h); font-weight: 700; white-space: nowrap; }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 10px;
  padding: 12px 28px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent-h); color: #fff; text-decoration: none; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary.btn-lg { width: 100%; text-align: center; padding: 14px; font-size: 1.05rem; }

.btn-secondary {
  display: inline-block;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 28px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
}
.btn-secondary:hover { background: var(--border); color: var(--text); text-decoration: none; }

/* ---- Success page ---- */
.success-wrap { max-width: 560px; margin: 40px auto 80px; text-align: center; }
.status-block { padding: 10px 0; }
.status-block h2 { font-size: 1.5rem; margin: 16px 0 8px; }
.status-block p  { color: var(--muted); margin-bottom: 20px; }
.check-icon, .x-icon { font-size: 3rem; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#keys-list { display: flex; flex-direction: column; gap: 10px; }

.key-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
}
.copy-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted); font-size: 0.78rem;
  padding: 3px 8px; cursor: pointer;
  transition: color .2s, border-color .2s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Misc ---- */
.loading-msg { text-align: center; padding: 48px; color: var(--muted); }
.error-msg   { text-align: center; padding: 24px; color: var(--danger); background: rgba(239,68,68,.1); border-radius: var(--radius); margin-bottom: 16px; }
.hidden { display: none !important; }

/* ---- Footer ---- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ============================
   Cart + Search additions
   ============================ */

/* Search bar */
.search-input {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 14px;
  box-sizing: border-box;
  transition: border-color .2s;
}
.search-input:focus { outline: none; border-color: var(--accent); }

/* Cart toggle button in header */
.cart-btn {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  padding: 6px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.cart-btn:hover { border-color: var(--accent); background: var(--surface); }

/* Cart badge */
.cart-badge {
  display: none;
  position: absolute;
  top: -6px; right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 99px;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* Cart overlay */
.cart-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 100;
}
.cart-overlay.open { display: block; }

/* Cart drawer */
.cart-drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: min(380px, 95vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s ease;
}
.cart-drawer.open { transform: translateX(0); }

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
}
.cart-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
.cart-close-btn:hover { color: var(--text); }

#cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#cart-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* Cart item row */
.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-label { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}
.qty-btn-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  width: 26px; height: 26px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.qty-btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.cart-item-price { font-size: 0.88rem; font-weight: 600; min-width: 50px; text-align: right; color: var(--accent); }
.cart-item-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.cart-item-remove:hover { color: var(--danger); }

/* Cart footer total */
.cart-footer-total { font-size: 1rem; font-weight: 600; }

/* Cart empty */
.cart-empty { text-align: center; color: var(--muted); padding: 32px 0; }

/* Denom button added state */
.denom-btn { width: 100%; }
.denom-btn.added { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

/* Checkout summary table */
.summary-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.summary-table thead th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.summary-table tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
.cart-total-row td {
  padding-top: 12px;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: none;
}

/* No results */
#no-results { text-align: center; color: var(--muted); padding: 48px 0; }
