/* ==========================================================================
   Design System & Variables
   ========================================================================== */
:root {
  /* Colors */
  --color-primary: #1e293b; /* Slate 800 */
  --color-primary-light: #334155;
  --color-accent: #c2410c; /* Orange 700 - for buttons/highlights */
  --color-accent-hover: #9a3412;
  --color-background: #f8fafc; /* Slate 50 */
  --color-surface: #ffffff;
  --color-text-primary: #0f172a; /* Slate 900 */
  --color-text-secondary: #475569; /* Slate 600 */
  --color-border: #e2e8f0; /* Slate 200 */
  --color-success: #16a34a;
  --color-error: #dc2626;

  /* Typography */
  --font-family-base: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-heading: 'Playfair Display', serif; /* For a classic bookish feel */
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Border Radius */
  --radius-md: 0.375rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family-base);
  color: var(--color-text-primary);
  background-color: var(--color-background);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-primary);
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

/* ==========================================================================
   Typography Utilities
   ========================================================================== */
.text-center { text-align: center; }
.text-accent { color: var(--color-accent); }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }

/* ==========================================================================
   Layout & Container
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  flex: 1; /* Pushes footer to bottom */
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .grid-cols-4, .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* ==========================================================================
   Components
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-normal);
  text-align: center;
}

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

.btn-primary:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

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

.btn-block {
  width: 100%;
}

/* Header */
header {
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  height: 80px;
}

.logo {
  font-family: var(--font-family-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: var(--color-text-secondary);
  font-weight: 500;
  position: relative;
}

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

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-accent);
  transition: width var(--transition-normal);
}

.nav-link:hover::after, .nav-link.active::after {
  width: 100%;
}

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

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--color-background);
  color: var(--color-text-primary);
  transition: background-color var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--color-border);
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--color-accent);
  color: white;
  font-size: 0.65rem;
  font-weight: bold;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

/* Hero Section */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  padding: 6rem 0;
  overflow: hidden;
}

.hero .container {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-content {
  max-width: 500px;
}

.hero-title {
  font-size: 3.5rem;
  color: white;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: #cbd5e1;
  margin-bottom: 2rem;
}

.hero-image {
  flex-shrink: 0;
  width: 500px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: perspective(1000px) rotateY(-10deg);
  transition: transform var(--transition-normal);
}

.hero-image:hover {
  transform: perspective(1000px) rotateY(0);
}

/* Product Card */
.product-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.product-image {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-bottom: 1px solid var(--color-border);
}

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

.product-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.product-title {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.product-author {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
  flex: 1; /* Pushes price to bottom */
}

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

.product-price {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-primary);
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--color-text-primary);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.1);
}

/* Card / Box */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

/* Footer */
footer {
  background-color: var(--color-primary);
  color: #cbd5e1;
  padding: 4rem 0 2rem;
  margin-top: auto; /* Pushes to bottom */
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.footer-heading {
  color: white;
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
}

.footer-links li {
  margin-bottom: 0.75rem;
}

.footer-links a:hover {
  color: white;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--color-primary-light);
  font-size: 0.875rem;
}

/* Detail Page Specific */
.detail-gallery {
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.detail-img {
  max-width: 350px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.detail-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-accent);
}

.qty-control {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.qty-btn {
  padding: 0.5rem 1rem;
  background-color: var(--color-background);
  font-weight: bold;
}

.qty-btn:hover {
  background-color: var(--color-border);
}

.qty-input {
  width: 50px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  font-weight: 500;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Cart Specific */
.cart-table {
  width: 100%;
  border-collapse: collapse;
}

.cart-table th,
.cart-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.cart-table th {
  font-weight: 600;
  color: var(--color-text-secondary);
}

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

.cart-item-img {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.cart-summary {
  background-color: var(--color-background);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.summary-total {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
  font-weight: 700;
  font-size: 1.25rem;
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 2rem;
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

/* Auth Layout */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 80px - 300px); /* Approx viewport minus header & footer */
  padding: 4rem 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 450px;
}

/* Toasts / Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toast {
  background-color: var(--color-surface);
  color: var(--color-text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--color-success);
  transform: translateX(120%);
  transition: transform var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast.show {
  transform: translateX(0);
}
