@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #f6f3fb;
  --bg-overlay: radial-gradient(circle at 18% 18%, rgba(139, 92, 246, 0.08), transparent 40%),
                radial-gradient(circle at 82% 4%, rgba(88, 28, 135, 0.06), transparent 46%);
  --card: #ffffff;
  --text: #1c1129;
  --muted: #5b4b73;
  --line: rgba(44, 24, 67, 0.12);
  --pill: rgba(44, 24, 67, 0.08);
  --primary-start: #7c3aed;
  --primary-end: #5b21b6;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --surface-strong: #1c1129;
  --surface-strong-text: #f3e8ff;
  --ghost: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] {
  --bg: #0d0716;
  --bg-overlay: radial-gradient(circle at 16% 10%, rgba(139, 92, 246, 0.2), transparent 44%),
                radial-gradient(circle at 78% 8%, rgba(88, 28, 135, 0.22), transparent 50%);
  --card: #150c24;
  --text: #f5ecff;
  --muted: #c7b3e6;
  --line: rgba(196, 181, 253, 0.18);
  --pill: rgba(196, 181, 253, 0.14);
  --primary-start: #8b5cf6;
  --primary-end: #6d28d9;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --surface-strong: #0f081b;
  --surface-strong-text: #ede9fe;
  --ghost: rgba(21, 12, 36, 0.9);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg-overlay), var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
  color: var(--muted);
}

/* Header & Navigation */
header {
  padding: 24px clamp(16px, 6vw, 72px);
  position: sticky;
  top: 0;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  background: rgba(21, 12, 36, 0.7);
  border-bottom: 1px solid var(--line);
  z-index: 100;
}

[data-theme="light"] header {
  background: rgba(255, 255, 255, 0.7);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  max-width: 1400px;
  margin: 0 auto;
}

.brand {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-links a,
.nav-links button,
.nav-links select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-links a:hover,
.nav-links button:hover,
.nav-links select:hover {
  background: var(--pill);
  transform: translateY(-2px);
}

.nav-links .pill {
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  color: #f8fafc;
  border: none;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.nav-links .pill:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(139, 92, 246, 0.4);
}

.cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Language Switcher */
.lang-switcher {
  position: relative;
}

.lang-button {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
}

.lang-button:hover {
  background: var(--pill);
  transform: translateY(-2px);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: 1001;
  min-width: 160px;
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-menu[hidden] {
  display: none;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.lang-option:hover {
  background: var(--pill);
  padding-left: 20px;
}

.lang-option:active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(88, 28, 135, 0.1));
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Main Content */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px clamp(16px, 6vw, 72px);
}

.section {
  margin: 60px 0;
}

.section-head {
  margin-bottom: 40px;
  animation: fadeInUp 0.6s ease-out;
}

.section-head h2 {
  font-size: clamp(28px, 5vw, 42px);
  margin-bottom: 12px;
}

.section-head p {
  font-size: 16px;
  color: var(--muted);
  max-width: 600px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(88, 28, 135, 0.05));
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  color: var(--primary-start);
}

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-start), var(--primary-end));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.card:hover::before {
  transform: scaleX(1);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.card.product-card {
  cursor: pointer;
}

.card h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.card h4 {
  font-size: 16px;
  margin-bottom: 8px;
}

.card .meta {
  color: var(--muted);
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.5;
}

.card p {
  margin-bottom: 8px;
}

.price {
  font-size: 24px;
  font-weight: 700;
  margin-top: 16px;
  color: var(--primary-start);
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.1);
  color: #22d3ee;
  font-weight: 600;
  font-size: 12px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  margin-bottom: 12px;
}

/* Buttons & Actions */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--text);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cta.primary {
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  color: #f8fafc;
  border: none;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.cta.primary:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(139, 92, 246, 0.4);
}

.cta.ghost {
  background: var(--ghost);
  border-color: var(--line);
}

.card-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card-actions .cta {
  padding: 8px 12px;
  font-size: 12px;
  flex: 1;
  min-width: 80px;
}

/* Modal */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  color: var(--text);
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  padding: 32px;
  display: grid;
  gap: 16px;
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.modal-header h3 {
  font-size: 22px;
}

.modal-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap-reverse;
}

.modal-actions .cta {
  flex: 1;
  min-width: 120px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-weight: 500;
  display: none;
}

/* Forms */
form {
  display: grid;
  gap: 16px;
}

form > div {
  display: grid;
  gap: 8px;
}

label {
  font-weight: 600;
  color: var(--text);
  display: block;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-start);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: var(--card);
  transform: translateY(-2px);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Utility Classes */
.card h3 {
  margin-bottom: 20px;
}

.admin-guard-text {
  padding: 40px;
  text-align: center;
  font-size: 16px;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-button-margin {
  margin-top: 8px;
}

.empty-visible {
  display: block !important;
  padding: 40px 20px;
  text-align: center;
}

.table-centered {
  text-align: center;
}

.table-right {
  text-align: right;
}

.table-rank {
  text-align: center;
  font-weight: 700;
  color: var(--primary-start);
}

/* Helper Text */
.helper {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 16px clamp(12px, 4vw, 40px);
  }

  .nav {
    gap: 12px;
  }

  main {
    padding: 24px clamp(12px, 4vw, 40px);
  }

  .section {
    margin: 40px 0;
  }

  .section-head {
    margin-bottom: 24px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 24px;
  }

  .card-actions {
    flex-direction: column;
  }

  .card-actions .cta {
    width: 100%;
  }
}

/* Tabs (Admin Panel) */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
  padding-bottom: 0;
}

.tab {
  padding: 14px 20px;
  border-radius: 8px 8px 0 0;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
  border-bottom: 3px solid transparent;
}

.tab:hover {
  color: var(--text);
  background: rgba(139, 92, 246, 0.05);
}

.tab.active {
  color: var(--primary-start);
  border-bottom: 3px solid var(--primary-start);
  background: transparent;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
  min-height: 500px;
}

.tab-content.active {
  display: block;
}

/* Admin Tab Grid Layout */
#products-tab .grid,
#vouchers-tab .grid {
  grid-template-columns: 350px 1fr;
  gap: 24px;
}

/* Admin List Items */
.admin-list {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.admin-item {
  display: grid;
  gap: 16px;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(88, 28, 135, 0.02));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-item:hover {
  border-color: var(--primary-start);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(88, 28, 135, 0.08));
  box-shadow: 0 12px 32px rgba(139, 92, 246, 0.2);
  transform: translateY(-6px);
}

.admin-item h4 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 700;
}

.admin-item .meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.admin-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.admin-col {
  display: grid;
  gap: 8px;
  flex: 1;
  min-width: 150px;
}

.admin-col label {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-actions .cta {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.edit-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(88, 28, 135, 0.04));
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.edit-form[hidden] {
  display: none;
}

.pill-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(88, 28, 135, 0.05));
  border: 1px solid var(--line);
  color: var(--primary-start);
  font-size: 12px;
  font-weight: 600;
}

/* Auth Cards (Login) */
.auth-card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: start;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0;
}

.divider::before,
.divider::after {
  content: '';
  height: 1px;
  background: var(--line);
}

.auth-actions {
  display: grid;
  gap: 10px;
}

/* Table (Leaderboard) */
.table {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 60px 1fr 120px;
  padding: 14px 16px;
  align-items: center;
  gap: 16px;
}

.table-head {
  background: rgba(241, 245, 249, 0.5);
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="dark"] .table-head {
  background: rgba(255, 255, 255, 0.03);
}

.table-row {
  border-bottom: 1px solid var(--line);
  transition: all 0.3s ease;
}

.table-row:last-child {
  border-bottom: none;
}

.table-row:hover {
  background: rgba(139, 92, 246, 0.05);
}

.table-row strong {
  font-size: 18px;
  color: var(--text);
}

@media (max-width: 480px) {
  .nav {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .nav-links {
    flex-direction: column;
    width: 100%;
  }

  .nav-links a,
  .nav-links button,
  .nav-links select {
    width: 100%;
    text-align: left;
  }

  .brand {
    width: 100%;
  }

  .section-head h2 {
    font-size: 24px;
  }

  .modal-card {
    padding: 20px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .cta {
    width: 100%;
  }

  .tabs {
    gap: 4px;
  }

  .tab {
    padding: 10px 12px;
    font-size: 13px;
  }

  .table-head,
  .table-row {
    grid-template-columns: 40px 1fr 80px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .table-row strong {
    font-size: 16px;
  }
}