/**
 * Cart Page Styles - Flavor Starter
 * React-inspired modern design with BEM structure
 *
 * @package Flavor_Starter
 * @version 1.0.0
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

.ta_cart {
  --cart-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --border-light: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --primary: var(--primary-color, #1e3a68);
  --primary-dark: #152a4d;
  --success: #10b981;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius: 0.5rem;
  --radius-sm: 0.25rem;
}

/* ==========================================================================
   Hide Flatsome Default Breadcrumbs
   ========================================================================== */

.woocommerce-cart .checkout-page-title,
.woocommerce-cart .checkout-breadcrumbs {
  display: none !important;
}

/* ==========================================================================
   Cart Container
   ========================================================================== */

.ta_cart {
  background-color: var(--cart-bg);
  padding: 1rem 0 4rem;
  min-height: 60vh;
}

/* ==========================================================================
   Page Title (Centered)
   ========================================================================== */

.ta_cart__page-title {
  text-align: center;
  padding: 1rem 0 1.5rem;
  margin-bottom: 1.5rem;
}

.ta_cart__page-title .ta_cart__title {
  justify-content: center;
  margin: 0;
}

@media (max-width: 640px) {
  .ta_cart__page-title {
    padding: 1.5rem 0 1rem;
    margin-bottom: 1rem;
  }

  .ta_cart__page-title .ta_cart__title {
    font-size: 1.5rem;
  }
}

/* ==========================================================================
   Cart Header
   ========================================================================== */

.ta_cart__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.ta_cart__title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.ta_cart__title svg {
  color: var(--primary);
}

.ta_cart__count {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  margin: 0;
}

.ta_cart__continue-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
}

.ta_cart__continue-link:hover {
  color: var(--primary);
}

@media (max-width: 640px) {
  .ta_cart__header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .ta_cart__continue-link {
    display: none;
  }
}

/* ==========================================================================
   Cart Layout (Grid)
   ========================================================================== */

.ta_cart__layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .ta_cart__layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .ta_cart__sidebar {
    order: -1;
  }
}

/* ==========================================================================
   Cart Main (Product List)
   ========================================================================== */

.ta_cart__main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Table Header (Desktop) */
.ta_cart__table-header {
  display: none;
  grid-template-columns: 1fr 100px 130px 120px;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

@media (min-width: 768px) {
  .ta_cart__table-header {
    display: grid;
  }
}

.ta_cart__col-price,
.ta_cart__col-quantity {
  text-align: center;
}

.ta_cart__col-subtotal {
  text-align: right;
}

/* ==========================================================================
   Cart Items Container
   ========================================================================== */

.ta_cart__items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ==========================================================================
   Cart Item
   ========================================================================== */

.ta_cart__item {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ta_cart__item:hover {
  border-color: #d1d5db;
  box-shadow: var(--shadow-md);
}

/* Mobile Layout */
.ta_cart__item-mobile {
  display: block;
  padding: 1rem;
}

@media (min-width: 768px) {
  .ta_cart__item-mobile {
    display: none;
  }
}

.ta_cart__item-top {
  display: flex;
  gap: 1rem;
}

.ta_cart__item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* Desktop Layout */
.ta_cart__item-desktop {
  display: none;
  grid-template-columns: 1fr 100px 130px 120px;
  gap: 1.5rem;
  padding: 1rem;
  align-items: center;
}

@media (min-width: 768px) {
  .ta_cart__item-desktop {
    display: grid;
  }
}

/* Product Column */
.ta_cart__item-product {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.ta_cart__item-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border-light);
}

.ta_cart__item-image img,
.ta_cart__item-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.ta_cart__item-image img {
  object-fit: cover;
}

.ta_cart__item-info,
.ta_cart__item-details {
  flex: 1;
  min-width: 0;
}

.ta_cart__item-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
}

.ta_cart__item-name a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Variation data */
.ta_cart__item .variation {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.25rem 0;
}

.ta_cart__item .variation dt,
.ta_cart__item .variation dd {
  display: inline;
  margin: 0;
}

.ta_cart__item .variation dt::after {
  content: ": ";
}

.ta_cart__item .variation p {
  margin: 0;
}

.ta_cart__backorder {
  font-size: 0.75rem;
  color: var(--danger);
  margin: 0.25rem 0 0;
}

/* Remove Button (Mobile) */
.ta_cart__item-remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.ta_cart__item-remove:hover {
  background: #fef2f2;
  color: var(--danger);
}

/* Remove Link (Desktop) */
.ta_cart__item-remove-link {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.ta_cart__item-remove-link:hover {
  color: var(--danger);
}

/* Price (Mobile) */
.ta_cart__item-price-mobile {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Price Column (Desktop) */
.ta_cart__item-price {
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Quantity Column */
.ta_cart__item-qty,
.ta_cart__item-quantity {
  display: flex;
  justify-content: center;
}

/* Subtotal Column */
.ta_cart__item-total,
.ta_cart__item-subtotal {
  text-align: right;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

/* ==========================================================================
   Quantity Input (WooCommerce Override)
   ========================================================================== */

/* Hide Flatsome's default quantity buttons */
.ta_cart .quantity .plus,
.ta_cart .quantity .minus,
.ta_cart .quantity .button:not(.ta_cart__qty-btn) {
  display: none !important;
}

.ta_cart .quantity {
  display: inline-flex;
  align-items: stretch;
  border: none;
  border-radius: var(--radius-sm);
  overflow: visible;
}

.ta_cart .quantity .qty {
  width: 48px;
  height: 38px;
  border: none;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--card-bg);
  -moz-appearance: textfield;
}

.ta_cart .quantity .qty::-webkit-outer-spin-button,
.ta_cart .quantity .qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ta_cart .quantity .qty:focus {
  outline: none;
  background: #f0f9ff;
}

.ta_cart .quantity .button {
  width: 32px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border-light);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.ta_cart .quantity .button:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.ta_cart .quantity .minus {
  border-right: 1px solid var(--border-color);
}

.ta_cart .quantity .plus {
  border-left: 1px solid var(--border-color);
}

/* ==========================================================================
   Cart Actions
   ========================================================================== */

.ta_cart__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
}

@media (max-width: 640px) {
  .ta_cart__actions {
    flex-direction: column;
  }

  .ta_cart__actions .ta_button {
    width: 100%;
  }
}

/* ==========================================================================
   Shared Button Styles
   ========================================================================== */

.ta_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  height: 44px;
  text-transform: uppercase;
  line-height: normal;
}

.ta_button--primary {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.ta_button--primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 104, 0.3);
  color: #ffffff;
}

.ta_button--secondary {
  background-color: var(--text-secondary);
  color: #ffffff;
  border-color: var(--text-secondary);
  margin: 0;
}

.ta_button--secondary:hover {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
  color: #ffffff;
}

.ta_button--outline {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.ta_button--outline:hover {
  background-color: var(--border-light);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.ta_button--full {
  width: 100%;
}

.ta_button--lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

/* ==========================================================================
   Cart Sidebar (Summary)
   ========================================================================== */

.ta_cart__summary {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.ta_cart__summary-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border-color);
}

.ta_cart__summary-title svg {
  color: var(--primary);
}

.ta_cart__summary-content {
  padding: 1.5rem;
}

/* Summary Rows */
.ta_cart__summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

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

.ta_cart__summary-label {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.ta_cart__summary-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.ta_cart__summary-value--pending {
  font-style: italic;
  color: var(--text-muted);
  font-weight: 400;
}

/* Shipping Row */
.ta_cart__summary-row--shipping {
  flex-direction: column;
  gap: 0.75rem;
}

.ta_cart__summary-row--shipping .ta_cart__summary-value {
  width: 100%;
}

/* WooCommerce shipping methods override */
.ta_cart__summary-row--shipping .woocommerce-shipping-methods {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ta_cart__summary-row--shipping .woocommerce-shipping-methods li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.ta_cart__summary-row--shipping .woocommerce-shipping-methods li:last-child {
  margin-bottom: 0;
}

.ta_cart__summary-row--shipping
  .woocommerce-shipping-methods
  input[type="radio"] {
  accent-color: var(--primary);
}

/* Coupon Row */
.ta_cart__summary-row--coupon .ta_cart__summary-value {
  color: var(--success);
}

/* Total Row */
.ta_cart__summary-row--total {
  margin-top: 0.75rem;
  padding-top: 1rem;
  border-top: 2px solid var(--primary);
  border-bottom: none;
}

.ta_cart__summary-row--total .ta_cart__summary-label {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ta_cart__summary-row--total .ta_cart__summary-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--primary);
}

/* ==========================================================================
   Coupon Section
   ========================================================================== */

.ta_cart__coupon {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--border-light);
}

.ta_cart__coupon-input-group {
  display: flex;
  gap: 0.5rem;
}

.ta_cart__coupon-input {
  flex: 1;
  padding: 0.625rem 0.875rem !important;
  font-size: 0.875rem !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--card-bg) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
  margin-bottom: 0px;
  height: 44px !important;
  box-shadow: none !important;
}

.ta_cart__coupon-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 104, 0.1);
}

.ta_cart__coupon-input::placeholder {
  color: var(--text-muted);
}

.ta_cart__coupon-btn {
  all: unset;
  flex-shrink: 0;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--card-bg);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: normal;
}

.ta_cart__coupon-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

/* ==========================================================================
   Checkout Button
   ========================================================================== */

.ta_cart__checkout {
  padding: 1rem;
}

.ta_cart__checkout .ta_button {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: normal;
}

/* ==========================================================================
   Cart Collaterals (Cross-sells)
   ========================================================================== */

.ta_cart__collaterals {
  margin-top: 3rem;
}

/* Hide default WooCommerce cart totals */
.ta_cart .cart_totals {
  display: none;
}

/* ==========================================================================
   Empty Cart Page
   ========================================================================== */

.ta_empty-cart {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 0;
  background-color: var(--cart-bg);
}

.ta_empty-cart__content {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  padding: 0 1rem;
}

.ta_empty-cart__icon {
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
}

.ta_empty-cart__icon svg {
  color: #d1d5db;
  opacity: 0.8;
}

.ta_empty-cart__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.ta_empty-cart__description {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.ta_empty-cart__action {
  margin-top: 2rem;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
  .ta_cart {
    padding: 1rem 0 2rem;
  }

  .ta_cart__summary-content {
    padding: 1rem;
  }

  .ta_cart__coupon,
  .ta_cart__checkout {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .ta_empty-cart {
    padding: 2rem 0;
    min-height: 50vh;
  }

  .ta_empty-cart__icon svg {
    width: 80px;
    height: 80px;
  }

  .ta_empty-cart__title {
    font-size: 1.25rem;
  }
}

/* ==========================================================================
   WooCommerce Notice Overrides
   ========================================================================== */

.ta_cart .woocommerce-message,
.ta_cart .woocommerce-info,
.ta_cart .woocommerce-error {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.ta_cart .woocommerce-message {
  background-color: #ecfdf5;
  border-left: 4px solid var(--success);
  color: #065f46;
}

.ta_cart .woocommerce-error {
  background-color: #fef2f2;
  border-left: 4px solid var(--danger);
  color: #991b1b;
}

.ta_cart .woocommerce-info {
  background-color: #eff6ff;
  border-left: 4px solid #3b82f6;
  color: #1e40af;
}

/* ==========================================================================
   Loading State (for AJAX updates)
   ========================================================================== */

.ta_cart.processing {
  opacity: 0.6;
  pointer-events: none;
}

.ta_cart.processing::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ta-spin 0.8s linear infinite;
}

@keyframes ta-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Enhanced Quantity Controls (from cart.js)
   ========================================================================== */

.ta_cart__qty-wrapper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
}

.ta_cart__qty-wrapper input {
  all: unset;
  box-shadow: none !important;
  border: none !important;
}

.ta_cart__qty-btn {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.ta_cart__qty-btn:active {
  background-color: var(--border-color);
}

.ta_cart__qty-btn svg {
  width: 14px;
  height: 14px;
}

.ta_cart__qty-wrapper .qty {
  width: 50px !important;
  height: 36px !important;
  padding: 0 !important;
  text-align: center;
  border: none !important;
  border-left: 1px solid var(--border-color) !important;
  border-right: 1px solid var(--border-color) !important;
  border-radius: 0 !important;
  font-size: 0.9375rem;
  font-weight: 500;
  background: transparent;
  -moz-appearance: textfield;
}

.ta_cart__qty-wrapper .qty::-webkit-outer-spin-button,
.ta_cart__qty-wrapper .qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ==========================================================================
   Loading & Update States
   ========================================================================== */

.ta_cart--loading {
  pointer-events: none;
}

.ta_cart--loading::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ta-spin 0.8s linear infinite;
  z-index: 9999;
}

.ta_cart__item--updating {
  opacity: 0.6;
}

.ta_cart__item--removing {
  opacity: 0.4;
  pointer-events: none;
  transition: all 0.3s ease;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.ta_cart__notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.ta_cart__notification--visible {
  opacity: 1;
  transform: translateY(0);
}

.ta_cart__notification--success {
  border-left: 4px solid var(--success);
}

.ta_cart__notification--success .ta_cart__notification-icon {
  color: var(--success);
}

.ta_cart__notification--error {
  border-left: 4px solid var(--danger);
}

.ta_cart__notification--error .ta_cart__notification-icon {
  color: var(--danger);
}

.ta_cart__notification-icon {
  flex-shrink: 0;
  display: flex;
}

.ta_cart__notification-message {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .ta_cart__notification {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}

.woocommerce-remove-coupon {
  font-size: 0.875rem;
  color: var(--text-muted);
}
