/* =====================================================
   DESSERT SHOP — styles.css
   UPGRADED with Payment Modal + Success Modal styles
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@400;600;700;800&family=Red+Hat+Text:wght@400;500;600;700&display=swap');

:root {
  --red:       #c73b0f;
  --red-dark:  #952c09;
  --bg:        #fcf8f6;
  --white:     #ffffff;
  --border:    #e0d5d0;
  --border-lt: #f5ebe7;
  --txt-black: #260f08;
  --txt-dark:  #3d1b0e;
  --txt-brown: #8a6055;
  --txt-light: #ad8a85;
  --green:     #1ea952;
  --font-h:    'Red Hat Display', sans-serif;
  --font-b:    'Red Hat Text', sans-serif;
}

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

body {
  font-family: var(--font-b);
  background-color: var(--bg);
  color: var(--txt-dark);
  font-size: 14px;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font-b); border: none; background: none; }

/* =====================================================
   PAGE WRAPPER
   ===================================================== */
.page-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 1024px) {
  .page-wrapper {
    grid-template-columns: 1fr 380px;
    align-items: start;
  }
}

/* =====================================================
   PAGE HEADING
   ===================================================== */
.page-heading { margin-bottom: 32px; }

.page-heading h1 {
  font-family: var(--font-h);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--txt-black);
}

.page-heading p {
  font-size: 0.9rem;
  color: var(--txt-light);
  margin-top: 4px;
}

/* =====================================================
   PRODUCTS GRID
   ===================================================== */
.products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

@media (min-width: 640px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =====================================================
   PRODUCT CARD
   ===================================================== */
.product-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.card-img-wrap {
  position: relative;
  border-radius: 12px;
  overflow: visible;
  margin-bottom: 0;
}

.card-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  background-color: #f0e8e4;
}

.product-card.in-cart .card-img {
  border: 2px solid var(--red);
}

.add-to-cart-btn {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  color: var(--txt-black);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.add-to-cart-btn:hover {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.btn-cart-icon { width: 18px; height: 18px; flex-shrink: 0; }

.quantity-control {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  min-width: 150px;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(199,59,15,0.4);
}

.qty-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.6);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.qty-btn:hover { background: rgba(255,255,255,0.25); }

.qty-number {
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  min-width: 28px;
}

.card-body {
  padding-top: 30px;
  padding-left: 4px;
  padding-right: 4px;
  padding-bottom: 8px;
}

.card-category { font-size: 12px; color: var(--txt-light); font-weight: 400; margin-bottom: 3px; }
.card-name { font-family: var(--font-h); font-size: 15px; font-weight: 700; color: var(--txt-black); margin-bottom: 4px; line-height: 1.3; }
.card-price { font-size: 15px; font-weight: 700; color: var(--red); }

/* =====================================================
   CART SECTION
   ===================================================== */
.cart-section {
  background: var(--white);
  border-radius: 16px;
  padding: 28px 24px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.cart-heading {
  font-family: var(--font-h);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 20px;
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 8px;
  gap: 14px;
  text-align: center;
}

.cart-empty img { width: 120px; opacity: 0.75; }
.cart-empty p { font-size: 13px; font-weight: 600; color: var(--txt-light); }

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-lt);
}
.cart-item:last-child { border-bottom: none; }

.cart-item-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #f0e8e4;
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt-dark);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-details {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cart-item-qty { font-size: 13px; font-weight: 700; color: var(--red); }
.cart-item-unit { font-size: 12px; color: var(--txt-light); }
.cart-item-subtotal { font-size: 13px; font-weight: 600; color: var(--txt-brown); }

.cart-item-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--txt-light);
  color: var(--txt-light);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s;
}

.cart-item-remove:hover {
  background: var(--txt-black);
  border-color: var(--txt-black);
  color: white;
}

.cart-total-section { margin-top: 12px; }

.cart-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.cart-total-row span { font-size: 14px; color: var(--txt-dark); font-weight: 500; }

.cart-total-price {
  font-family: var(--font-h);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--txt-black);
}

.carbon-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
  margin: 4px 0 16px 0;
}

.carbon-notice p { font-size: 13px; color: var(--txt-dark); }

.confirm-btn {
  width: 100%;
  padding: 16px;
  background: var(--red);
  color: var(--white);
  border-radius: 50px;
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
  transition: background 0.2s;
}

.confirm-btn:hover { background: var(--red-dark); }

/* =====================================================
   SHARED MODAL BASE STYLES
   (Used by all three modals)
   ===================================================== */
.modal-overlay {
  /*
    display: none = hidden by default.
    JavaScript adds .active class to show it.
    We use display:flex so inner content can be centered.
  */
  display: none;
  position: fixed;        /* Stays in place even when page scrolls */
  inset: 0;               /* Shorthand for top:0 right:0 bottom:0 left:0 */
  background: rgba(0,0,0,0.5);  /* Semi-transparent dark backdrop */
  z-index: 1000;          /* On top of everything else */
  align-items: flex-end;  /* On mobile: slide up from bottom */
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.3s ease;  /* Fades in smoothly */
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;  /* On desktop: centered vertically */
    padding: 20px;
  }
}

/* When .active is added by JS, modal becomes visible */
.modal-overlay.active {
  display: flex;
  opacity: 1;
}

/* The white box inside the overlay */
.modal-box {
  background: var(--white);
  border-radius: 16px 16px 0 0;  /* Rounded top corners on mobile */
  padding: 36px 28px;
  width: 100%;
  max-height: 90vh;       /* Never taller than 90% screen height */
  overflow-y: auto;       /* Scroll inside if content is long */
  transform: translateY(60px);  /* Starts 60px below (slide-up animation) */
  transition: transform 0.3s ease;
}

@media (min-width: 640px) {
  .modal-box {
    border-radius: 16px;   /* Fully rounded on desktop */
    max-width: 500px;
    transform: scale(0.92); /* Starts slightly smaller (zoom animation) */
  }
}

/* Animation: modal slides/scales into position when active */
.modal-overlay.active .modal-box {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal-overlay.active .modal-box {
    transform: scale(1);
  }
}

/* =====================================================
   [EXISTING] CONFIRMATION MODAL ELEMENTS
   ===================================================== */
.modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.modal-title {
  font-family: var(--font-h);
  font-size: 2rem;
  font-weight: 800;
  color: var(--txt-black);
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--txt-light);
  margin-bottom: 24px;
}

.modal-items {
  background: var(--bg);
  border-radius: 10px 10px 0 0;
  padding: 8px 16px;
}

.modal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-lt);
}
.modal-item:last-child { border-bottom: none; }

.modal-item-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #f0e8e4;
}

.modal-item-info { flex: 1; min-width: 0; }
.modal-item-name { font-size: 13px; font-weight: 700; color: var(--txt-dark); margin-bottom: 4px; }
.modal-item-meta { display: flex; gap: 8px; align-items: center; }
.modal-item-qty { font-size: 13px; font-weight: 700; color: var(--red); }
.modal-item-price { font-size: 12px; color: var(--txt-light); }
.modal-item-total { font-size: 14px; font-weight: 700; color: var(--txt-dark); flex-shrink: 0; }

.modal-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg);
  border-radius: 0 0 10px 10px;
  margin-bottom: 24px;
}

.modal-total-row span { font-size: 13px; color: var(--txt-dark); }

.modal-total-row strong {
  font-family: var(--font-h);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--txt-black);
}

.modal-close-btn {
  width: 100%;
  padding: 16px;
  background: var(--red);
  color: var(--white);
  border-radius: 50px;
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
  transition: background 0.2s;
}

.modal-close-btn:hover { background: var(--red-dark); }


/* =====================================================
   [NEW] PAYMENT MODAL SPECIFIC STYLES
   ===================================================== */

/*
  .payment-modal-box overrides the base .modal-box
  to allow a wider max-width since payment forms need space.
*/
.payment-modal-box {
  max-width: 560px !important;
}

/*
  ORDER SUMMARY STRIP at top of payment modal.
  Shows amount due so user sees what they're paying.
  Background matches cart section for visual consistency.
*/
.payment-order-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 24px;
  border: 1px solid var(--border-lt);
}

.payment-summary-label {
  font-size: 13px;
  color: var(--txt-brown);
  font-weight: 500;
}

.payment-summary-amount {
  font-family: var(--font-h);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--txt-black);
}

/*
  TAB ROW
  Two side-by-side buttons to toggle between
  Bank Transfer and Card Payment views.
*/
.payment-tabs {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;          /* Clips children so no border bleeds outside */
  margin-bottom: 24px;
}

/*
  Each tab button takes equal space (flex: 1).
  The inactive tab is light gray.
  The active tab turns red to show selection.
*/
.payment-tab {
  flex: 1;
  padding: 12px 16px;
  font-family: var(--font-h);
  font-size: 14px;
  font-weight: 700;
  color: var(--txt-brown);
  background: var(--bg);
  border: none;
  transition: all 0.2s;
}

/* Adds a divider line between the two tab buttons */
.payment-tab:first-child {
  border-right: 1.5px solid var(--border);
}

/* Active tab: red background + white text */
.payment-tab.active {
  background: var(--red);
  color: var(--white);
}

.payment-tab:not(.active):hover {
  background: var(--border-lt);
}

/*
  BANK DETAILS CARD
  A styled box that displays the 3 bank account fields.
  Uses a light background to separate it from the modal.
*/
.bank-details-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border-lt);
  margin-bottom: 16px;
}

.bank-details-title {
  font-family: var(--font-h);
  font-size: 13px;
  font-weight: 700;
  color: var(--txt-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/*
  Each row inside the bank card:
  Label on left, value on right.
*/
.bank-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-lt);
}

.bank-detail-row:last-child { border-bottom: none; }

.bank-detail-label {
  font-size: 13px;
  color: var(--txt-light);
  font-weight: 500;
}

.bank-detail-value {
  font-size: 14px;
  color: var(--txt-dark);
  font-weight: 600;
  text-align: right;
}

/*
  Account number gets larger, red font for emphasis.
  This makes it stand out so users don't mistype it.
*/
.bank-acct-number {
  font-family: var(--font-h);
  font-size: 1.3rem;
  color: var(--red);
  letter-spacing: 0.08em;
}

.bank-instructions {
  font-size: 13px;
  color: var(--txt-light);
  line-height: 1.6;
  margin-bottom: 20px;
}

/*
  FORM STYLES for Card Payment
*/

/* Each label + input pair is wrapped in .form-group */
.form-group {
  display: flex;
  flex-direction: column;  /* Label above input */
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-dark);
}

/*
  Form inputs: full width, bordered, with padding.
  The border changes color when focused (outline removed,
  we replace it with a box-shadow for cleaner look).
*/
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-b);
  font-size: 14px;
  color: var(--txt-black);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Focused state: red border + soft red glow */
.form-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(199, 59, 15, 0.1);
}

/*
  Error state: red border to indicate invalid input.
  Applied by JavaScript when validation fails.
*/
.form-input.error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

/* Error message text below each input */
.form-error {
  font-size: 12px;
  color: #e53e3e;
  min-height: 16px;  /* Reserve space so layout doesn't jump */
  font-weight: 500;
}

/*
  SPLIT ROW: Expiry + CVV side by side on one row.
*/
.form-row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/*
  PRIMARY ACTION BUTTON (Bank "I Have Made Payment" + Card "Pay Now")
  Full width, red, pill-shaped — matches the confirm button style.
*/
.payment-action-btn {
  width: 100%;
  padding: 16px;
  background: var(--red);
  color: var(--white);
  border-radius: 50px;
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}

.payment-action-btn:hover { background: var(--red-dark); }

/* Small press effect on click */
.payment-action-btn:active { transform: scale(0.98); }

/* Cancel / back button — subtle text style */
.payment-cancel-btn {
  width: 100%;
  padding: 12px;
  color: var(--txt-light);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-top: 8px;
  transition: color 0.2s;
  background: none;
  border: none;
}

.payment-cancel-btn:hover { color: var(--txt-dark); }


/* =====================================================
   [NEW] SUCCESS MODAL SPECIFIC STYLES
   ===================================================== */
.success-modal-box {
  max-width: 480px !important;
  text-align: center;    /* Centers heading and subtitle */
}

/*
  Animated wrapper for the checkmark icon.
  The @keyframes "popIn" makes it scale from 0 to 1
  with a slight bounce, creating a satisfying "success" feel.
*/
.success-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;

  /*
    animation: name duration timing-function delay fill-mode;
    popIn = our custom keyframe defined below.
    0.5s = plays over half a second.
    cubic-bezier = custom bounce easing curve.
    both = applies start AND end state.
  */
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes popIn {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/*
  Success title inherits .modal-title but we center it.
  The text-align: center on .success-modal-box covers this.
*/
.success-title {
  font-size: 2.2rem;
}

/*
  Payment method confirmation line.
  Shows "Paid via Bank Transfer" or "Paid via Card".
  Styled as a badge/pill to make it scannable.
*/
.success-payment-method {
  display: inline-block;
  background: #e6f6ed;
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 50px;
  margin: 0 auto 20px auto;
}

/*
  Inside success modal, the items list and total row
  inherit all the existing .modal-items / .modal-total-row
  styles — no duplication needed.
  We just fix text-align for items inside the centered modal.
*/
.success-modal-box .modal-item {
  text-align: left;
}

.success-modal-box .modal-total-row {
  text-align: left;
}
