/*
 * Enhanced Cart Styles for StickerSubs Theme v2.2.0
 * Optimized side-by-side layout with improved accessibility
 * This CSS is designed to work with our custom cart template
 */

/* Cart Page Styles */
.cart-page {
  min-height: 80vh;
  background: var(--white);
}

/* Cart Hero */
.cart-hero {
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
  padding: 4rem 0 3rem;
  text-align: center;
}

.cart-hero .page-title {
  color: var(--darkest);
  margin-bottom: 0.5rem;
  font-size: clamp(2rem, 5vw, 3rem);
}

.cart-subtitle {
  color: var(--dark-accent);
  font-size: 1.2rem;
  margin: 0;
}

/* Cart Content Section */
.cart-content {
  padding: 3rem 0 2rem;
}

.cart-content .container {
  max-width: 1800px;
  width: 95%;
  margin: 0 auto;
  padding: 0 2rem;
  display: block; /* Ensure container doesn't interfere */
}

/* WooCommerce Notices */
.woocommerce-notices-wrapper {
  margin-bottom: 2rem;
  width: 100%;
  clear: both;
}

.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
  padding: 1rem 1.5rem;
  border-radius: 12px;
  margin: 1rem 0;
  font-weight: 500;
  border-left: 4px solid;
}

.woocommerce-message {
  background: #f0fff4;
  color: #27ae60;
  border-left-color: #27ae60;
}

.woocommerce-error {
  background: #fff5f5;
  color: #e74c3c;
  border-left-color: #e74c3c;
}

.woocommerce-info {
  background: #f0f8ff;
  color: #3498db;
  border-left-color: #3498db;
}

/* CUSTOM CART GRID - FORCE Side-by-Side Layout */
.custom-cart-grid {
  display: grid !important;
  grid-template-columns: 2.3fr 1fr !important;
  gap: 3rem;
  align-items: start;
  margin-top: 2rem;
  min-height: 400px;
  width: 100%;
}

/* Ensure consistent alignment with explicit grid areas */
.custom-cart-grid[data-layout="side-by-side"] {
  grid-template-areas: "cart-items cart-totals" !important;
}

.custom-cart-grid .cart-table-section {
  grid-area: cart-items;
  width: 100%;
  min-width: 0; /* Prevents overflow */
}

.custom-cart-grid .cart-totals-section {
  grid-area: cart-totals;
  width: 100%;
  min-width: 300px; /* Minimum width for totals */
}

/* Left Side: Cart Table Section */
.cart-table-section {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  overflow-x: auto;
  display: block; /* Ensure it behaves as block element */
}

/* Right Side: Cart Totals Section */
.cart-totals-section {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  position: sticky;
  top: 120px;
  height: fit-content;
}

/* Cart Form */
.woocommerce-cart-form {
  width: 100%;
}

/* Cart Table - Responsive */
.shop_table {
  width: 100%;
  min-width: 550px; /* Optimized for side-by-side */
  border-collapse: collapse;
  background: var(--white);
  margin: 0;
  table-layout: fixed; /* Fixed for consistent column widths */
}

/* Optimized Column Widths for Side-by-Side Layout */
.shop_table .product-remove {
  width: 50px;
  min-width: 50px;
}

.shop_table .product-thumbnail {
  width: 80px;
  min-width: 80px;
}

.shop_table .product-name {
  width: auto;
  min-width: 200px;
}

.shop_table .product-price {
  width: 80px;
  min-width: 80px;
}

.shop_table .product-quantity {
  width: 100px;
  min-width: 100px;
}

.shop_table .product-subtotal {
  width: 100px;
  min-width: 100px;
}

/* Table Headers */
.shop_table thead {
  background: var(--background-light);
}

.shop_table thead th {
  padding: 1.2rem 0.8rem;
  text-align: left;
  font-weight: 600;
  color: var(--darkest);
  border-bottom: 2px solid var(--accent-color);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Table Body */
.shop_table tbody td {
  padding: 1.5rem 0.8rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--background-light);
}

.shop_table tbody tr:hover {
  background: rgba(168, 218, 220, 0.1);
}

/* Product Thumbnail */
.product-thumbnail img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-medium);
}

.product-thumbnail a:hover img {
  transform: scale(1.05);
}

/* Product Name */
.product-name a {
  font-weight: 600;
  color: var(--darkest);
  text-decoration: none;
  font-size: 1rem;
  transition: color var(--transition-fast);
  display: block;
  line-height: 1.4;
}

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

/* Product Price */
.product-price {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-color);
  text-align: center;
}

/* Quantity Input */
.product-quantity {
  text-align: center;
}

.product-quantity .qty {
  width: 70px;
  padding: 0.6rem;
  border: 2px solid var(--background-light);
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  transition: border-color var(--transition-medium);
}

.product-quantity .qty:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Product Subtotal */
.product-subtotal {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--darkest);
  text-align: right;
}

/* Remove Button */
.product-remove {
  text-align: center;
}

.product-remove .remove {
  background: var(--background-light);
  color: var(--text-secondary);
  border: none;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.2rem;
  transition: all var(--transition-medium);
  cursor: pointer;
  margin: 0 auto;
}

.product-remove .remove:hover {
  background: var(--primary-color);
  color: var(--white);
  transform: scale(1.1);
}

/* Cart Actions */
.actions {
  background: var(--background-light);
  padding: 1.5rem !important;
  border-radius: 0 0 20px 20px;
  margin-top: 1rem;
}

.actions .coupon {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.actions .coupon label {
  font-weight: 600;
  color: var(--darkest);
  white-space: nowrap;
  min-width: 60px;
}

.actions .coupon .input-text {
  padding: 0.7rem 1rem;
  border: 2px solid var(--white);
  border-radius: 6px;
  font-size: 1rem;
  min-width: 180px;
  transition: border-color var(--transition-medium);
}

.actions .coupon .input-text:focus {
  outline: none;
  border-color: var(--primary-color);
}

.actions .button {
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: var(--white);
  border: none;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-medium);
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-block;
}

.actions .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3);
  color: var(--white);
}

/* Cart Totals */
.cart_totals {
  width: 100%;
}

.cart_totals h2 {
  color: var(--darkest);
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
  text-align: center;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--background-light);
}

.cart_totals table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.cart_totals th,
.cart_totals td {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--background-light);
  text-align: left;
}

.cart_totals th {
  font-weight: 500;
  color: var(--text-secondary);
  width: 60%;
  font-size: 0.95rem;
}

.cart_totals td {
  font-weight: 600;
  color: var(--darkest);
  text-align: right;
  font-size: 1rem;
}

.cart_totals .order-total th,
.cart_totals .order-total td {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  border-bottom: none;
  padding-top: 1.2rem;
  border-top: 2px solid var(--background-light);
}

/* Shipping Options */
.cart_totals .shipping ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.cart_totals .shipping li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.cart_totals .shipping input[type="radio"] {
  margin: 0;
}

/* Checkout Button */
.wc-proceed-to-checkout {
  text-align: center;
  margin-top: 1rem;
}

.checkout-button,
.wc-proceed-to-checkout .checkout-button,
.wc-proceed-to-checkout a {
  width: 100%;
  padding: 1.2rem 2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: var(--white);
  border: none;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-medium);
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3);
  text-align: center;
}

.checkout-button:hover,
.wc-proceed-to-checkout .checkout-button:hover,
.wc-proceed-to-checkout a:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(230, 57, 70, 0.4);
  color: var(--white);
}

/* Continue Shopping */
.continue-shopping {
  padding: 4rem 0;
  background: var(--background-light);
  text-align: center;
}

.continue-content h3 {
  color: var(--darkest);
  margin-bottom: 1rem;
  font-size: 1.75rem;
}

.continue-content p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.continue-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 1400px) {
  .cart-content .container {
    max-width: 1400px;
  }
  
  .custom-cart-grid {
    gap: 2rem;
    grid-template-columns: 2fr 1fr !important; /* Maintain side-by-side */
  }
  
  .shop_table {
    min-width: 500px; /* Reduced for better fit */
  }
}

/* Only stack on tablets and below */
@media (max-width: 900px) {
  .custom-cart-grid {
    grid-template-columns: 1fr !important;
    grid-template-areas: 
      "cart-items"
      "cart-totals" !important;
    gap: 2rem;
  }
  
  .cart-totals-section {
    position: static;
    min-width: auto;
  }
}

@media (max-width: 768px) {
  .cart-content .container {
    padding: 0 1rem;
  }
  
  .cart-table-section,
  .cart-totals-section {
    padding: 1.5rem;
  }
  
  /* Mobile table - stacked layout */
  .shop_table {
    min-width: auto;
  }
  
  .shop_table thead {
    display: none;
  }
  
  .shop_table,
  .shop_table tbody,
  .shop_table tr,
  .shop_table td {
    display: block;
    width: 100%;
  }
  
  .shop_table tr {
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    padding: 1rem;
  }
  
  .shop_table td {
    padding: 0.8rem 0;
    border: none;
    position: relative;
    padding-left: 35%;
    min-height: 40px;
    display: flex;
    align-items: center;
  }
  
  .shop_table td:before {
    content: attr(data-title) ": ";
    position: absolute;
    left: 0;
    width: 30%;
    white-space: nowrap;
    font-weight: 600;
    color: var(--darkest);
    font-size: 0.9rem;
  }
  
  .product-thumbnail {
    width: 100%;
    text-align: center;
    padding-left: 0 !important;
  }
  
  .product-thumbnail:before {
    display: none;
  }
  
  .product-thumbnail img {
    width: 60px;
    height: 60px;
    margin: 0 auto;
  }
  
  .product-remove {
    text-align: center;
    padding-left: 0 !important;
  }
  
  .product-remove:before {
    display: none;
  }
  
  .actions .coupon {
    flex-direction: column;
    align-items: stretch;
  }
  
  .actions .coupon .input-text {
    min-width: auto;
    margin-bottom: 1rem;
  }
  
  .continue-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .continue-actions .cta-button,
  .continue-actions .secondary-button {
    width: 250px;
  }
}

@media (max-width: 480px) {
  .cart-hero {
    padding: 3rem 0 2rem;
  }
  
  .cart-hero .page-title {
    font-size: 2rem;
  }
  
  .cart-content {
    padding: 2rem 0;
  }
  
  .cart-table-section,
  .cart-totals-section {
    padding: 1rem;
  }
  
  .continue-actions .cta-button,
  .continue-actions .secondary-button {
    width: 100%;
  }
}

/* Loading States */
.cart-loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.cart-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px solid var(--background-light);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Accessibility */
.screen-reader-text {
  position: absolute !important;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px;
  height: 1px;
  word-wrap: normal !important;
}

/* Debug and Force Grid Layout */
.custom-cart-grid {
  /* Force grid properties to override any conflicting styles */
  display: grid !important;
  grid-template-columns: 2.3fr 1fr !important;
  grid-template-rows: auto !important;
  gap: 3rem !important;
}

/* Force proper positioning */
.cart-table-section {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

.cart-totals-section {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

/* Enhanced Focus States for Accessibility */
.shop_table td:focus,
.qty:focus,
.button:focus,
.checkout-button:focus,
.remove:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .custom-cart-grid {
    border: 1px solid;
  }
  
  .cart-table-section,
  .cart-totals-section {
    border: 2px solid;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}