/* Mini Cart Button Module Styles */

/* Wrapper and Button */
.mcb-wrapper {
  position: relative;
  display: inline-block;
}

.mcb-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background-color: transparent;
  color: #333;
  border: none;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  box-sizing: border-box;
  min-width: 40px;
  min-height: 40px;
}

.mcb-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
  transform: none;
  box-shadow: none;
}

.mcb-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
  border-radius: 4px;
}

.mcb-button:active {
  transform: none;
  box-shadow: none;
  background-color: rgba(0, 0, 0, 0.1);
}

.mcb-cart-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mcb-cart-svg {
  width: 24px;
  height: 24px;
  color: inherit;
}

.mcb-cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #e74c3c;
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Popout Panel - Dropdown Card Style */
.mcb-popout {
  position: absolute;
  top: 100%;
  z-index: 9999;
  display: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.mcb-popout.mcb-active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.mcb-popout-overlay {
  display: none;
}

.mcb-popout-panel {
  position: relative;
  background-color: #ffffff;
  color: #333333;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 400px;
  max-height: 500px;
}

.mcb-popout.mcb-position-left {
  right: 0;
}

.mcb-popout.mcb-position-right {
  left: 0;
}

/* Arrow pointing to button */
.mcb-popout-panel::before {
  content: "";
  position: absolute;
  top: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #e0e0e0;
}

.mcb-popout-panel::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #ffffff;
}

.mcb-popout-panel.mcb-position-left::before,
.mcb-popout-panel.mcb-position-left::after {
  right: 20px;
}

.mcb-popout-panel.mcb-position-right::before,
.mcb-popout-panel.mcb-position-right::after {
  left: 20px;
}

/* Header */
.mcb-popout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #eee;
  background-color: #f8f9fa;
}

.mcb-popout-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: inherit;
}

.mcb-close-button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.mcb-close-button:hover {
  background-color: #e9ecef;
  color: #333;
}

.mcb-close-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

/* Content */
.mcb-popout-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mcb-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.mcb-empty-cart {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

.mcb-empty-cart p {
  margin: 0;
  font-style: italic;
}

/* Cart Items List */
.mcb-cart-items-list {
  padding: 0;
  margin: 0;
}

.mcb-cart-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  transition: all 0.3s ease;
  position: relative;
}

.mcb-cart-item:hover {
  background-color: #f8f9fa;
}

.mcb-cart-item.mcb-removing {
  opacity: 0.5;
  transform: translateX(-10px);
}

.mcb-item-thumbnail {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  overflow: hidden;
  border-radius: 4px;
  background-color: #f8f9fa;
}

.mcb-item-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
}

.mcb-item-thumbnail a {
  display: block;
  width: 100%;
  height: 100%;
}

.mcb-item-details {
  flex: 1;
  min-width: 0;
}

.mcb-item-name {
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.3;
}

.mcb-item-name a {
  color: inherit;
  text-decoration: none;
}

.mcb-item-name a:hover {
  color: #2c3e50;
  text-decoration: underline;
}

.mcb-item-meta {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: #666;
}

.mcb-item-quantity {
  font-weight: 500;
}

.mcb-item-price {
  font-weight: 600;
  color: #2c3e50;
}

.mcb-remove-item {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #dc3545;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  margin-top: 2px;
  position: relative;
  z-index: 999;
  pointer-events: auto !important;
}

.mcb-remove-item:hover {
  background-color: #dc3545;
  color: white;
}

.mcb-remove-item:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.3);
}

.mcb-remove-item.mcb-loading {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Footer */
.mcb-cart-footer {
  padding: 20px;
  border-top: 1px solid #eee;
  background-color: #f8f9fa;
}

.mcb-cart-subtotal {
  margin-bottom: 16px;
  font-size: 16px;
  text-align: right;
}

.mcb-subtotal-amount {
  color: #2c3e50;
}

.mcb-cart-actions {
  display: flex;
  gap: 12px;
}

.mcb-view-cart-btn,
.mcb-checkout-btn {
  flex: 1;
  padding: 12px 16px;
  text-align: center;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.mcb-view-cart-btn {
  background-color: #6c757d;
  color: white;
}

.mcb-view-cart-btn:hover {
  background-color: #5a6268;
  text-decoration: none;
  color: white;
}

.mcb-checkout-btn {
  background-color: #28a745;
  color: white;
}

.mcb-checkout-btn:hover {
  background-color: #218838;
  text-decoration: none;
  color: white;
}

.mcb-view-cart-btn:focus,
.mcb-checkout-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Messages */
.mcb-message {
  padding: 12px 20px;
  margin-bottom: 16px;
  border-radius: 4px;
  font-size: 14px;
  animation: mcb-slide-down 0.3s ease;
}

.mcb-message-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.mcb-message-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes mcb-slide-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation for cart updates */
.mcb-cart-items.mcb-updated {
  animation: mcb-fade-in 0.3s ease;
}

@keyframes mcb-fade-in {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

/* Body scroll prevention */
body.mcb-no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .mcb-popout {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin-top: 0 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999999 !important;
    box-sizing: border-box;
  }

  .mcb-popout.mcb-active {
    display: flex !important;
  }

  .mcb-popout-panel {
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 40px);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin: auto;
    overflow: hidden;
  }

  .mcb-popout.mcb-active .mcb-popout-panel {
    transform: scale(1);
  }

  .mcb-popout-panel::before,
  .mcb-popout-panel::after {
    display: none;
  }

  .mcb-cart-actions {
    flex-direction: column;
  }

  .mcb-item-thumbnail {
    width: 50px;
    height: 50px;
  }

  .mcb-cart-item {
    padding: 12px 16px;
  }

  .mcb-popout-header,
  .mcb-cart-footer {
    padding: 16px;
  }

  /* Ensure cart items area is scrollable on mobile */
  .mcb-cart-items {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .mcb-button {
    padding: 8px 12px;
    font-size: 13px;
  }

  .mcb-cart-count {
    min-width: 18px;
    height: 18px;
    font-size: 11px;
  }

  .mcb-item-meta {
    flex-direction: column;
    gap: 4px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mcb-button {
    border: 2px solid currentColor;
  }

  .mcb-popout-panel {
    border: 2px solid #333;
  }

  .mcb-cart-item {
    border-bottom: 2px solid #333;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .mcb-button,
  .mcb-popout,
  .mcb-popout-panel,
  .mcb-cart-item,
  .mcb-remove-item,
  .mcb-close-button,
  .mcb-view-cart-btn,
  .mcb-checkout-btn {
    transition: none;
  }

  .mcb-message {
    animation: none;
  }

  .mcb-cart-items.mcb-updated {
    animation: none;
  }
}

/* Focus visible support for better accessibility */
.mcb-button:focus-visible,
.mcb-close-button:focus-visible,
.mcb-remove-item:focus-visible,
.mcb-view-cart-btn:focus-visible,
.mcb-checkout-btn:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .mcb-wrapper {
    display: none;
  }
}

/* Theme compatibility - defensive CSS */
.mcb-wrapper,
.mcb-wrapper * {
  box-sizing: border-box;
}

.mcb-wrapper button,
.mcb-wrapper a {
  font-family: inherit;
}

.mcb-popout-panel h3 {
  font-family: inherit;
  line-height: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.mcb-item-name a,
.mcb-view-cart-btn,
.mcb-checkout-btn {
  color: inherit;
}

.mcb-item-name a:visited {
  color: inherit;
}

/* Override common theme conflicts */
.mcb-popout-panel .mcb-cart-item {
  list-style: none;
  margin: 0;
  padding-left: 20px;
  padding-right: 20px;
}

.mcb-popout-panel .mcb-cart-item::before {
  display: none;
}

/* Ensure proper stacking */
.mcb-popout {
  z-index: 999999;
}

/* Loading states */
.mcb-cart-items.mcb-loading {
  opacity: 0.7;
  pointer-events: none;
}

.mcb-cart-items.mcb-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: mcb-spin 1s linear infinite;
}

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