/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Body */
body {
  font-family: Arial, sans-serif;
  background: url("background.png") no-repeat center center fixed;
  background-size: cover;
  color: #333;
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 128, 171, 0.3); /* semi-transparent pink overlay */
  z-index: -1;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ff80ab;
  color: white;
  padding: 15px 30px;
}

header .logo {
  font-size: 1.5em;
  font-weight: bold;
}

header nav a {
  color: white;
  margin: 0 10px;
  text-decoration: none;
  font-weight: bold;
}

header nav a:hover {
  text-decoration: underline;
}

/* Main content */
main {
  padding: 40px 20px;
  max-width: 1200px;
  margin: auto;
}

main h2 {
  text-align: center;
  margin-bottom: 20px;
}

/* Product grid */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fit, 250px);
  gap: 20px;
  justify-content: center;
}

.product-card {
  background: rgb(255, 223, 240);
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
  margin: 0 auto;
}

.product-card img {
  max-width: 100%;
  border-radius: 8px;
}

.product-card h3 {
  margin: 15px 0 5px;
}

.product-card button {
  background: #ff80ab;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.3s;
}

.product-card button:hover {
  background: #ff4d8b;
}

/* Forms (admin page) */
form {
  max-width: 600px;
  margin: 20px auto;
  background: rgb(255, 233, 246);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 3px 6px rgba(0,0,0,0.05);
}

form label {
  display: block;
  margin-bottom: 10px;
}

form input {
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  border-radius: 5px;
  border: 1px solid #ccc;
}

form button {
  display: block;
  width: 100%;
  background: #ff80ab;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 20px;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.3s;
}

form button:hover {
  background: #ff4d8b;
}

/* Footer */
footer {
  text-align: center;
  background: #ff80ab;
  color: white;
  padding: 15px;
  margin-top: 30px;
}

/* Filters */
.filters {
  text-align: center;
  margin-bottom: 20px;
}

.filters a {
  display: inline-block;
  background: #ff80ab;
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  text-decoration: none;
  margin: 0 8px;
  transition: background 0.3s;
  font-weight: bold;
  margin: 6px;
}

.filters a:hover {
  background: #ff4d8b;
}

.filters a.active {
  background: #ff4d8b; /* darker pink */
}

/* Cart dropdown */
.cart-wrapper {
  position: relative;
  display: inline-block;
}

#cart-btn {
  background: #ff80ab;
  color: rgb(255, 255, 255);
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
}

#cart-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: #ffdaf3;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  width: 300px;
  padding: 15px;
  z-index: 100;
  color: #000;

  /* animation-ready */
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#cart-dropdown.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

#cart-dropdown ul {
  list-style: none;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
  padding: 0 10px 0 0;
}

#cart-dropdown li {
  display: grid;
  grid-template-columns: 1fr auto auto; /* namn tar plats, qty+remove fasta */
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

#cart-dropdown li span.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qty-input {
  width: 40px;
  margin: 0 5px;
}

.remove-btn {
  background: transparent;
  border: none;
  color: #ff4d8b;
  cursor: pointer;
  font-size: 16px;
}

.checkout-btn {
  display: block;
  text-align: center;
  background: #ff80ab;
  color: white;
  padding: 10px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: bold;
  margin-top: 10px;
}

.checkout-btn:hover {
  background: #ff4d8b;
}


/* Cart table */
.cart-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.cart-table th, .cart-table td {
  border: 1px solid #ddd;
  padding: 10px;
  text-align: center;
}

.cart-table th {
  background: #ff80ab;
  color: white;
}

.cart-summary {
  text-align: right;
  margin-top: 20px;
}

.cart-summary p {
  font-size: 18px;
  margin-bottom: 10px;
}


.cart-summary .checkout-btn {
  background: #4caf50;
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: bold;
}

.cart-summary .checkout-btn:hover {
  background: #388e3c;
}

.product-card img {
  width: 250px;        /* fixed width */
  height: 250px;       /* fixed height */
  object-fit: cover;   /* crop to fit without distortion */
  border-radius: 8px;
  display: block;
  margin: 0 auto 10px; /* center and add bottom spacing */
}

.back-btn {
  display: inline-block;
  background: #ffa2c1;
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.3s;
}

.back-btn:hover {
  background: #ff4d8b;
}

/* Generic button link style */
.btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: bold;
  color: white;
  margin: 0 4px;
  transition: background 0.3s;
}

/* Specific buttons */
.edit-btn {
  background: #4caf50; /* green */
}
.edit-btn:hover {
  background: #388e3c;
}

.delete-btn {
  background: #f44336; /* red */
}
.delete-btn:hover {
  background: #d32f2f;
}

#cart-dropdown.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

button[disabled], 
button.out-of-stock {
  background: #ccc;     /* ljusgrå bakgrund */
  color: #666;          /* mörkgrå text */
  cursor: not-allowed;  /* visar stopp-symbol när man hovrar */
  border: 1px solid #aaa;
}

button[disabled]:hover,
button.out-of-stock:hover {
  background: #888888;  /* mörkare grå vid hover */
  color: white;
}


.empty-cart {
  background: #ffe3ee;     /* ljus bakgrund */
  border: 1px solid #ddd;  /* tunn ram */
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  font-size: 16px;
  color: #444;
  margin: 20px auto;
  max-width: 400px;
}

.empty-cart a {
  display: inline-block;
  margin-left: 8px;
  padding: 6px 12px;
  background: #ff80ab;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.2s;
}

.empty-cart a:hover {
  background: #e64a85;
}


.product-detail {
  text-align: center;
  max-width: 600px;
  margin: 0 auto; /* centrerar hela boxen */
  padding: 20px;
}

.product-detail h1 {
  margin-bottom: 20px;
}

.product-detail .product-img {
  max-width: 300px;
  display: block;
  margin: 0 auto 20px auto;
  border-radius: 8px;
}

.product-card a {
  text-decoration: none;   /* ta bort underline */
  color: inherit;          /* ärv textfärg från omgivande element */
}

.product-card a:hover h3 {
  color: #ff4081;          /* valfri hoverfärg (rosa exempel) */
}


/* -------------------------------- */
/* RESPONSIVE (MOBILE FIRST) */
/* -------------------------------- */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    text-align: center;
  }

  .shop-back {
  margin-top: 50px;
}

  header nav {
    flex-direction: column;
    margin-top: 10px;
  }

  .products {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .product-card img {
    height: 150px;
  }

  .filters {
    flex-direction: column;
    gap: 10px;
  }

  #cart-dropdown {
    width: 90vw;   /* full width on mobile */
    left: 50%;
    transform: translateX(-50%) scale(0.95);
  }

  #cart-dropdown.show {
    transform: translateX(-50%) scale(1);
  }

  .cart-table th, .cart-table td {
    font-size: 12px;
    padding: 6px;
  }

  .cart-summary p {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .product-card {
    padding: 10px;
  }

  .product-card h3 {
    font-size: 0.9em;
  }

  .product-card button {
    padding: 8px 15px;
    font-size: 0.9em;
  }

  #cart-btn {
    padding: 6px 12px;
    font-size: 0.9em;
  }
}

@media (max-width: 768px) {
  #cart-dropdown {
    width: 90vw;
    left: 50%;
    transform: translateX(-50%) scale(0.95);
  }
  #cart-dropdown.show {
    transform: translateX(-50%) scale(1);
  }
}

@media (max-width: 768px) {
  .btn, .edit-btn, .delete-btn {
    padding: 4px 8px;
    font-size: 0.8em;
    border-radius: 4px;
  }

  /* Optional: stack actions vertically instead of side-by-side */
  .cart-table td a {
    display: block;
    overflow-x: auto;
    margin: 2px 0;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .cart-table th, 
  .cart-table td {
    font-size: 12px;
    padding: 6px;
    word-wrap: break-word; /* tvingar text att stanna inom cellen */
  }

  .cart-table td button {
    display: block;       /* lägger knappen på egen rad */
    margin: 4px auto 0;   /* centrerar den i cellen */
    max-width: 100%;      /* gör så att den inte trycker ut cellen */
  }
}
@media (max-width: 768px) {
  .cart-table,
  .cart-table thead,
  .cart-table tbody,
  .cart-table th,
  .cart-table td,
  .cart-table tr {
    display: block;
    width: 100%;
  }

  .cart-table thead {
    display: none; /* Dölj rubrikraden */
  }

  .cart-table tr {
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    background: #fff;
  }

  .cart-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    border: none;
    border-bottom: 1px solid #eee;
  }

  .cart-table td:last-child {
    border-bottom: none;
  }

  .cart-table td img {
    max-width: 60px;
    height: auto;
    border-radius: 4px;
  }

  .cart-table td button {
    background: #ff80ab;
    border: none;
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}


@media (max-width: 768px) {
  #cart-dropdown {
    width: 85vw;             /* nästan hela skärmen */
    left: 10%;               /* centrera */
    right: auto;             /* ignorera högerkant */
    transform: translateX(-50%) scale(0.95);
  }
  #cart-dropdown.show {
    transform: translateX(-50%) scale(1);
  }
}
