:root {
  --primary-color: #ffffff;
  --secondary-color: #b0b0b0;
  --background-color: #121212;
  --surface-color: #1e1e1e;
  --accent-color: #bb86fc;
  --accent-color-dark: #3700b3;
  --error-color: #cf6679;
  --success-color: #03dac6;
  --border-radius: 8px;
  --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: 'Roboto', 'Noto Sans SC', 'Noto Sans TC', sans-serif;
  background-color: var(--background-color);
  color: var(--primary-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex-grow: 1;
  padding: 2rem 5%;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 5%;
  background-color: rgba(30, 30, 30, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #333;
}

.header-left {
  font-size: 1.5rem;
  font-weight: bold;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-center a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 1rem;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.3s, color 0.3s;
}

.header-center a:hover {
  background-color: var(--accent-color);
  color: #000;
}

.genre-select {
  color: var(--primary-color);
  background-color: var(--surface-color);
  border: 1px solid #444;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background-color 0.3s;
}

.genre-select:hover {
    background-color: #333;
}

.search-bar {
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #444;
  background-color: var(--surface-color);
  color: var(--primary-color);
  width: 250px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-icon {
  position: relative;
  cursor: pointer;
  width: 24px;
  height: 24px;
  transition: transform 0.2s;
}

.header-icon svg {
  width: 100%;
  height: 100%;
}

.header-icon:hover {
  transform: scale(1.1);
}

.cart-badge {
  position: absolute;
  top: -5px;
  right: -8px;
  background-color: var(--accent-color);
  color: #000;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  font-weight: bold;
}

.login-button {
  background-color: var(--accent-color);
  color: #000;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s;
}

.login-button:hover {
  background-color: #a764fa;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info span {
  font-weight: 500;
}

.logout-button {
  background-color: transparent;
  border: 1px solid var(--secondary-color);
  color: var(--secondary-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s;
}

.logout-button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}


/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.product-card {
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

.product-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.product-info {
  padding: 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.product-artist {
  font-size: 1rem;
  color: var(--secondary-color);
  margin-bottom: 0.5rem;
}

.product-description {
  font-size: 0.9rem;
  color: var(--secondary-color);
  margin-bottom: 1rem;
  flex-grow: 1;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.product-price {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent-color);
}

.add-to-cart-button {
  background-color: transparent;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

.add-to-cart-button:hover {
  background-color: var(--accent-color);
  color: #000;
}

/* Floating Action Buttons */
.fab-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 1050;
}

.fab {
  background-color: var(--accent-color);
  color: #000;
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.2s, background-color 0.3s;
}

.fab:hover {
  transform: scale(1.1);
  background-color: #a764fa;
}

.fab svg {
  width: 24px;
  height: 24px;
}


/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem 5%;
  margin-top: 3rem;
  background-color: var(--surface-color);
  font-size: 0.85rem;
  color: var(--secondary-color);
}

/* Status Containers */
.status-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  font-size: 1.5rem;
  padding: 2rem;
  text-align: center;
  min-height: calc(100vh - 80px); /* Adjust based on header height */
}

.status-container.error {
  color: var(--error-color);
}

/* --- Overlays, Modals, Sidebars --- */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1010;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background-color: var(--surface-color);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  z-index: 1020;
  width: 90%;
  max-width: 500px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease-in-out;
}

.overlay.show .modal {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--secondary-color);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal h2 {
  margin-bottom: 1.5rem;
  text-align: center;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-form input {
  padding: 0.8rem;
  border-radius: 4px;
  border: 1px solid #444;
  background-color: var(--background-color);
  color: var(--primary-color);
  font-size: 1rem;
}

.modal-button {
  padding: 0.8rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: opacity 0.2s;
}

.modal-button:hover:not(:disabled) {
  opacity: 0.8;
}

.modal-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-button.primary {
  background-color: var(--accent-color);
  color: #000;
}

.modal-button.secondary {
  background-color: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.modal-error {
  color: var(--error-color);
  text-align: center;
  margin-top: -0.5rem;
  margin-bottom: 0.5rem;
}

.modal-success {
  color: var(--success-color);
  text-align: center;
  font-weight: bold;
  padding: 0.8rem;
  background-color: rgba(3, 218, 198, 0.1);
  border-radius: 4px;
}


.toggle-auth-mode {
  background: none;
  border: none;
  color: var(--accent-color);
  cursor: pointer;
  text-decoration: underline;
  margin-top: 1.5rem;
  text-align: center;
  width: 100%;
}


/* Cart Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 400px;
  height: 100%;
  background-color: var(--surface-color);
  z-index: 1030;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  box-shadow: -5px 0 15px rgba(0,0,0,0.3);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-content {
  padding: 1.5rem;
  overflow-y: auto;
  flex-grow: 1;
}

.cart-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.cart-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.cart-item-info { flex-grow: 1; }
.cart-item-info h4 { font-size: 1rem; margin-bottom: 0.25rem; }
.cart-item-info p { font-size: 0.9rem; color: var(--secondary-color); }

.cart-item-price { font-weight: bold; }

.cart-item-remove {
  background: none;
  border: 1px solid #444;
  color: var(--secondary-color);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-empty-message { text-align: center; color: var(--secondary-color); }

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid #333;
}

.totals p {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  color: var(--secondary-color);
}
.totals p.total {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--primary-color);
}
.sidebar-footer .modal-button {
  width: 100%;
  margin-top: 1rem;
}

/* Chat Window */
.chat-window {
  position: fixed;
  bottom: calc(2rem + 56px + 1rem + 56px + 1rem); /* Position above FABs */
  right: 2rem;
  width: 350px;
  height: 450px;
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 0.75rem 1rem;
  background-color: #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-body {
  flex-grow: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message { max-width: 80%; }
.chat-message p {
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  line-height: 1.4;
}
.chat-message.bot { align-self: flex-start; }
.chat-message.bot p { background-color: #333; }
.chat-message.user { align-self: flex-end; }
.chat-message.user p { background-color: var(--accent-color); color: #000; }

.chat-footer {
  padding: 0.75rem;
  border-top: 1px solid #333;
  display: flex;
  gap: 0.5rem;
}
.chat-footer input {
  flex-grow: 1;
  padding: 0.5rem;
  border-radius: 20px;
  border: 1px solid #444;
  background-color: var(--background-color);
  color: var(--primary-color);
}
.chat-footer button {
  background-color: var(--accent-color);
  color: #000;
  border: none;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: bold;
}

/* Checkout Modal */
.checkout-content { display: flex; flex-direction: column; gap: 2rem; }
.order-summary, .payment-details { display: flex; flex-direction: column; }
.summary-item { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.summary-item.total { font-weight: bold; font-size: 1.1rem; margin-top: 0.5rem; }
hr { border: none; border-top: 1px solid #333; margin: 1rem 0; }
.stripe-placeholder {
  border: 1px solid #444;
  background-color: var(--background-color);
  border-radius: 4px;
  padding: 2rem;
  text-align: center;
  color: var(--secondary-color);
  margin: 1rem 0;
}
.pay-button { width: 100%; }

/* Responsive */
@media (max-width: 900px) {
  .header-center {
    display: none;
  }
}

@media (max-width: 480px) {
  .header-left { font-size: 1.2rem; }
  .header-right { gap: 1rem; }
  .login-button { padding: 0.5rem 0.8rem; font-size: 0.9rem; }
  main { padding: 1.5rem 5%; }
  .product-grid { grid-template-columns: 1fr; }
  .sidebar { max-width: 90vw; }
  .modal { width: 90vw; }
  .chat-window {
    width: 90vw;
    height: 70vh;
    bottom: 1rem;
    right: 1rem;
  }
  .fab-container {
    bottom: 1rem;
    right: 1rem;
  }
}