/* checkout.css - Shared PayPal modal and checkout styles */

/* 
 * PayPal Modal Management:
 * - Product page modals: Defined in HTML (product.html, index.html) for direct product checkout
 * - Cart drawer modals: Defined in HTML within cart drawer component scope for proper Alpine.js binding
 * - All modals share the same CSS classes (.modal, .pp-modal, .sheet, etc.)
 * 
 * Note: Cart modals must be in HTML (not JS-created) because Alpine.js needs to process
 * the x-show, x-transition, and @click directives at initialization time.
 */

/* =============================================================================
   MODAL OVERLAY SYSTEM
   ============================================================================= */

/* Main modal backdrop - creates dark overlay covering entire screen */
.modal {
  position: fixed;        /* Fixed positioning to cover entire viewport */
  inset: 0;              /* Shorthand for top: 0, right: 0, bottom: 0, left: 0 */
  background: rgba(0, 0, 0, 0.35);  /* Semi-transparent dark background */
  display: flex;          /* Flexbox for centering content */
  align-items: center;    /* Center vertically */
  justify-content: center; /* Center horizontally */
  padding: 18px;         /* Padding around modal content */
  z-index: 50;           /* High z-index to appear above other content */
}

/* Modal content container - the white box that appears in center */
.sheet {
  background: #fff;              /* White background for modal content */
  border-radius: 18px;           /* Rounded corners */
  max-width: 520px;             /* Maximum width constraint */
  width: 100%;                  /* Take full available width up to max-width */
  box-shadow: var(--shadow);     /* Drop shadow effect (defined in shared-styles.css) */
  border: 1px solid var(--border); /* Border color (defined in shared-styles.css) */
}

/* Modal header section */
.sheet .hd {
  padding: 18px 18px 0;         /* Padding: top/sides 18px, bottom 0 */
}

/* Modal body section - main content area */
.sheet .bd {
  padding: 18px;                /* Equal padding on all sides */
}

/* Modal footer section */
.sheet .ft {
  padding: 0 18px 18px;         /* Padding: top 0, sides/bottom 18px */
}

/* PayPal specific modal sizing - slightly narrower than default */
.pp-modal .sheet {
  max-width: 480px;             /* Smaller max-width for PayPal checkout */
}

/* =============================================================================
   CART DRAWER (RIGHT SIDE)
   ============================================================================= */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 90vw;
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
}

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

/* Background overlay for click-outside-to-close */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 55; /* Below drawer but above page content */
}

.drawer .hd { padding: 16px; border-bottom: 1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.drawer .bd { padding: 16px; overflow: auto; flex: 1; }
.drawer .ft { padding: 16px; border-top: 1px solid var(--border); }

.cart-line { display:grid; grid-template-columns: 1fr auto; gap: 8px; align-items:center; padding: 10px 0; border-bottom:1px solid #f3f4f6; }
.cart-line h4 { margin:0; font-size:14px; }
.cart-line .qty { display:flex; gap:8px; align-items:center; }
.cart-line button { padding:6px 8px; border-radius:8px; }

.cart-summary { display:grid; gap:8px; margin: 12px 0; }
.cart-summary .row { display:flex; justify-content:space-between; }

/* ======================
   CHECKOUT REVIEW (DRAWER)
   ====================== */
.checkout-review { background:#f9fafb; border:1px solid #e9ecef; border-radius:12px; padding:12px; }
.checkout-review .review-items { display:grid; gap:8px; }
.checkout-review .review-line { display:flex; justify-content:space-between; align-items:center; border-bottom:1px dashed #eceff3; padding-bottom:6px; }
.checkout-review .review-line:last-child { border-bottom:none; padding-bottom:0; }
.checkout-review .review-name { font-size:14px; color:#2c3e50; }
.checkout-review .review-meta { display:flex; gap:10px; align-items:center; color:#6c757d; }

/* =============================================================================
   PRODUCT DETAILS DISPLAY
   ============================================================================= */

/* Container for product information in checkout modal */
.checkout-product-details {
  background: #f8f9fa;          /* Light gray background */
  border-radius: 12px;          /* Rounded corners */
  padding: 16px;               /* Internal spacing */
  margin-bottom: 20px;         /* Space below this section */
  border: 1px solid #e9ecef;   /* Light border */
}

/* Product details section heading */
.checkout-product-details h4 {
  margin: 0 0 12px 0;          /* Remove default margins, add bottom margin */
  font-size: 16px;             /* Slightly larger text */
  font-weight: 600;            /* Semi-bold weight */
  color: #2c3e50;              /* Dark blue-gray color */
}

/* Individual product detail rows (label: value pairs) */
.product-detail-row {
  display: flex;                /* Flexbox for label-value layout */
  justify-content: space-between; /* Push label left, value right */
  align-items: center;          /* Vertically center content */
  margin-bottom: 8px;          /* Space between rows */
  font-size: 14px;             /* Slightly smaller text */
}

/* Remove margin from last detail row */
.product-detail-row:last-child {
  margin-bottom: 0;            /* No margin on last row */
}

/* Labels for product details (left side) */
.product-detail-label {
  color: #6c757d;              /* Medium gray color */
  font-weight: 500;            /* Medium weight */
}

/* Values for product details (right side) */
.product-detail-value {
  color: #2c3e50;              /* Dark blue-gray color */
  font-weight: 600;            /* Semi-bold weight */
}

/* Special styling for product name - larger than other details */
.product-name-value {
  font-size: 16px;             /* Larger text for product name */
  font-weight: 700;            /* Bold weight for emphasis */
}

/* Special styling for custom text on hats - larger than hat color but smaller than product name */
.fun-text-value {
  font-family: 'Arial Black', Arial, sans-serif; /* Bold font family */
  font-weight: bold;           /* Extra bold weight */
  text-transform: uppercase;   /* Convert to uppercase */
  color: #000000;              /* Black color for standard text */
  font-size: 15px;             /* Larger than default but smaller than product name */
}

/* =============================================================================
   PRICING BREAKDOWN SECTION
   ============================================================================= */

/* Container for price calculation details */
.checkout-pricing {
  border-top: 1px solid #e9ecef;  /* Top border to separate from product details */
  padding-top: 16px;              /* Space above pricing content */
  margin-top: 16px;               /* Space above the border */
}

/* Individual pricing rows (subtotal, shipping, etc.) */
.pricing-row {
  display: flex;                   /* Flexbox for label-value layout */
  justify-content: space-between;  /* Push label left, value right */
  align-items: center;             /* Vertically center content */
  margin-bottom: 8px;             /* Space between pricing rows */
  font-size: 14px;                /* Standard text size */
}

/* Final total row - styled differently for emphasis */
.pricing-row:last-child {
  margin-bottom: 0;               /* No margin on final row */
  padding-top: 8px;               /* Extra space above total */
  padding-bottom: 16px;           /* Space below total line for checkout page separation */
  border-top: 1px solid #e9ecef;  /* Border above total line */
  font-weight: 700;               /* Bold text for total */
  font-size: 16px;                /* Larger text for total */
}

/* Labels for pricing rows (left side) */
.pricing-label {
  color: #6c757d;                 /* Medium gray color */
}

/* Values for pricing rows (right side) */
.pricing-value {
  color: #2c3e50;                 /* Dark blue-gray color */
  font-weight: 600;               /* Semi-bold weight */
}

/* Total row text styling - both label and value */
.pricing-row:last-child .pricing-label,
.pricing-row:last-child .pricing-value {
  color: #2c3e50;                 /* Dark color for total row */
}

/* Free shipping text - green color to highlight the deal */
.free-shipping {
  color: #28a745 !important;      /* Green color (important overrides other styles) */
  font-weight: 600;               /* Semi-bold weight */
}

/* =============================================================================
   LOADING ANIMATIONS & INTERACTIVE ELEMENTS
   ============================================================================= */

/* Spinning loading indicator */
.loading-spinner {
  display: inline-block;          /* Inline block for positioning */
  width: 20px;                   /* Fixed width */
  height: 20px;                  /* Fixed height */
  border: 3px solid #f3f3f3;     /* Light gray border */
  border-top: 3px solid var(--blue); /* Blue top border creates spinning effect */
  border-radius: 50%;            /* Perfect circle */
  animation: checkout-spin 1s linear infinite; /* Continuous rotation */
}

/* Keyframe animation for spinner rotation */
@keyframes checkout-spin {
  0% { transform: rotate(0deg); }    /* Start position */
  100% { transform: rotate(360deg); } /* Full rotation */
}

/* =============================================================================
   BUTTON STATES & INTERACTIONS
   ============================================================================= */

/* Hover effect for buttons - subtle lift animation */
.btn:hover {
  transform: translateY(-1px);    /* Move button up slightly on hover */
}

/* Disabled button state */
.btn:disabled {
  opacity: 0.5;                   /* Make button semi-transparent */
  cursor: not-allowed;            /* Show "not allowed" cursor */
}

/* =============================================================================
   PAYPAL INTEGRATION STYLING
   ============================================================================= */

/* Container for PayPal button - ensures minimum height */
#paypal-button-container {
  min-height: 45px;              /* Minimum height to prevent layout shifts */
}

/* Loading state for PayPal modal */
.paypal-loading {
  text-align: center;            /* Center align loading content */
  padding: 20px;                 /* Padding around loading content */
}

/* Loading message text styling */
.paypal-loading p {
  margin-top: 10px;              /* Space above loading message */
  color: var(--muted);           /* Muted text color (defined in shared-styles.css) */
}
