/* --- BUTTON AND ICON STYLES --- */
.custom-add-to-cart {
  background: #0073aa;
  color: white;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 3px;
  margin-top: 15px;
  display: inline-block;
}
.custom-add-to-cart:hover {
  background: #005a87;
}

/* --- POPUP STYLES --- */
#cart-popup {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
z-index: 11111;
}

/* REMOVED: html/body overflow rule. Handled by JS now. */

/* --- DESKTOP ANIMATIONS (Keyframes) --- */
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes slideOutRight {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

/* DESKTOP SIDEBAR STYLES (Default) */
.popup-content {
  position: absolute;
  top: 0;
  right: 0;
  background: white;
  width: 100%;
  max-width: 450px;
  height: 100%;
  max-height: 100vh;
  margin: 0;
  padding: 20px;
  border-radius: 0;
  overflow-y: auto;
  box-shadow: -5px 0 15px rgba(0,0,0,0.1);

  /* Slide In Animation - Runs automatically on display:block */
  animation: slideInRight 0.3s ease-out forwards;
}

/* Class for JS to toggle for exit animation: <div class="popup-content closing"> */
.popup-content.closing {
  animation: slideOutRight 0.3s ease-in forwards;
}

#cart-popup .close-popup {
position: absolute;
top: 10px;
right: 15px;
font-size: 24px!important;
cursor: pointer;
background: none;
border: none;
z-index: 10;
}
.popup-content h2 {
  margin-top: 0;
}

/* --- CART ITEM STYLES --- */
.cart-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
}
.cart-item:last-child {
  border-bottom: none;
}
.cart-item-image {
  display: flex;
  flex: 0 0 60px;
  height: 60px;
  background-color: #f0f0f1;
  border-radius: 4px;
}
.cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.item-details {
  flex-grow: 1;
}
.item-details h4 {
  margin: 0 0 5px 0;
  font-size: 1em;
}
.item-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}
.quantity-control {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  width: fit-content;
}
.quantity-btn {
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  width: 32px;
  height: 32px;
  transition: background-color 0.2s;
}
.quantity-btn:hover {
  background-color: #e0e0e0;
}
.quantity-display {
  padding: 0 12px;
  font-weight: bold;
  font-size: 16px;
  min-width: 20px;
  text-align: center;
}
.remove-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  color: #888;
  transition: color 0.2s;
}
.remove-item-btn:hover {
  color: #dc3232;
}
.remove-item-btn svg {
  display: block;
}
.cart-total {
  font-size: 16px;
  font-style: italic;
  color: #555;
  text-align: right;
  margin: 20px 0;
  padding-top: 15px;
  border-top: 2px solid #eee;
}

/* --- FORM STYLES --- */
.checkout-form {
  margin-top: 20px;
}
.form-row {
  margin-bottom: 15px;
  position: relative;
}
.form-row label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}
.form-row input {
  width: 100%;
  padding: 10px 10px 10px 45px;
  border: 1px solid #ddd;
  border-radius: 3px;
  box-sizing: border-box;
  height: 42px;
}

/* --- INPUT ICONS --- */
.form-row:has(input)::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 38px;
  height: 38px;
  background-color: #e9ecef;
  border-radius: 3px 0 0 3px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px;
  border: 1px solid #ddd;
  border-right: none;
  box-sizing: border-box;
}

.form-row:has(#full_name)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23555555' d='M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z'/%3E%3C/svg%3E");
}
.form-row:has(#mesto)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath fill='%23555555' d='M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67a24 24 0 0 1-35.464 0zM192 272a80 80 0 1 0 0-160 80 80 0 1 0 0 160z'/%3E%3C/svg%3E");
}
.form-row:has(#ulica)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'%3E%3Cpath fill='%23555555' d='M0 416c0 35.3 28.7 64 64 64l352 0c35.3 0 64-28.7 64-64L576 384c0-35.3-28.7-64-64-64L64 320c-35.3 0-64 28.7-64 64l0 32zm576-192L576 64c0-35.3-28.7-64-64-64L160 0C124.7 0 96 28.7 96 64L96 224c0 35.3 28.7 64 64 64l352 0c35.3 0 64-28.7 64-64zM224 160l0-64c0-8.8 7.2-16 16-16l64 0c8.8 0 16 7.2 16 16l0 64c0 8.8-7.2 16-16 16l-64 0c-8.8 0-16-7.2-16-16zm-32 256l0-64c0-8.8 7.2-16 16-16l64 0c8.8 0 16 7.2 16 16l0 64c0 8.8-7.2 16-16 16l-64 0c-8.8 0-16-7.2-16-16z'/%3E%3C/svg%3E");
}
.form-row:has(#phone)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23555555' d='M164.9 24.6c-7.7-18.6-28-28.5-47.4-23.2l-88 24C12.1 30.2 0 46 0 64C0 311.4 200.6 512 448 512c18 0 33.8-12.1 38.6-29.5l24-88c5.3-19.4-4.6-39.7-23.2-47.4l-96-40c-16.3-6.8-35.2-2.1-46.3 11.6L304.7 368C234.3 334.7 177.3 277.7 144 207.3L193.3 167c13.7-11.2 18.4-30 11.6-46.3l-40-96z'/%3E%3C/svg%3E");
}

/* --- SHIPPING AND FINAL TOTAL --- */
.shipping-option {
  align-items: center;
  border: 1px solid #ddd;
  padding: 3px 10px;
  border-radius: 4px;
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 5px;
}
.shipping-option input[type="radio"] {
  margin-right: 10px;
}
.shipping-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  cursor: pointer;
}
.shipping-name {
  font-weight: bold;
}
.shipping-price {
  color: #0073aa;
  font-weight: bold;
}
.checkout-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}
.final-total-label {
  font-size: 1em;
  color: #777;
}
.final-total-amount {
  font-size: 1.4em;
  font-weight: bold;
  color: #111;
  /* Ensure transform works for animation */
  display: inline-block;
  transform-origin: left center;
}
.checkout-button {
  width: 40%;
  padding: 8px;
  border-radius: 3px;
}
#checkout-form input {
padding-left: 46px;
}

#checkout-form .shipping-row input {
width: 16px;
}
#checkout-form h3 {
margin-bottom: 10px;
}
.shipping-row:before {
  display: none;
}

.shipping-option * {
  margin: 0 !important;
}

/* --- RESPONSIVE STYLES (MOBILE) --- */
@media (max-width: 768px) {
  /* Restore Mobile-specific Popup Positioning and Disable Animation */
  .popup-content {
    position: relative;
    right: auto;
    top: auto;
    width: calc(100vw - 20px);
    max-width: 600px;
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    margin: 10px;
    border-radius: 5px;
    box-shadow: none;

    /* DISABLE ANIMATION ON MOBILE */
    animation: none !important;
    transform: none !important;
  }

  #cart-popup .close-popup {
  top: 1px;
  right: 15px;
  }

  /* Original Mobile Styles */
  .cart-item-image {
    height: auto;
  }
  .shipping-row input {
    height: 22px;
  }
  .cart-total {
    margin: 0;
    padding: 0;
  }
  .popup-content {
    padding: 10px;
  }
  .cart-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: start;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 10px 0 0;
    border: none;
  }
  .item-details {
    width: calc(100% - 75px);
  }
  .item-actions {
    width: 100%;
    justify-content: space-between;
    margin-top: 10px;
  }
  .checkout-action-row {
    flex-direction: column;
    gap: 8px;
  }
  .checkout-button {
    width: 100%;
  }
  .popup-content h2, .popup-content h3 {
    font-size: 16px;
    padding: 0 0 8px;
    margin-bottom: 8px;
  }
  .item-details h4 {
    font-size: 14px;
    margin: 0;
  }
  #cart-popup * {
  font-size: 16px !important;
  }
  #cart-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 10px;
  }
  #cart-items h4 {
  padding: 0;
  }
  .popup-content *:is(h1, h2, h3, h4, h5 ,h6) {
    font-weight: 700;
  }
  #checkout-form {
  margin: 0;
  }
  .form-row label {
    margin-bottom: 0;
  }
  .form-row {
    margin-bottom: 14px;
  }
  .checkout-action-row {
    margin-top: 10px;
    padding-top: 8px;
  }
  /* --- Quantity Control Mobile Optimization --- */
  .quantity-btn {
    width: 24px;
    height: 20px;
    line-height: 20px;
    font-size: 14px !important;
    padding: 0;
  }
  .quantity-display {
    font-size: 14px !important;
    padding: 0 6px;
    min-width: 16px;
  }
  .item-quantity-trash {
    display: flex;
    justify-content: space-between;
  }#checkout-form input::placeholder {
    color: var(--ssc-struct-base) !important;
    opacity: 1; /* Required for Firefox */
  }
}

/* --- PRICE UPDATE ANIMATION --- */
/* Scale up slightly, flash the brand blue color, and fade slightly */
@keyframes pricePulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; color: #0073aa; }
  100% { transform: scale(1); opacity: 1; }
}

.price-updated {
  animation: pricePulse 0.2s ease-out forwards;
}
