/* Root */
#myqb-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: inherit;
  --myqb-bg: #fff;
  --myqb-fg: #222;
  --myqb-muted: #6b7280;
  --myqb-brand: #30a4ea; /* primary brand */
  --myqb-brand-strong: #1e88d5;
  --myqb-border: #e5e7eb;
  --myqb-danger: #e11d48;
  --myqb-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  --myqb-radius: 12px;
  --myqb-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.myqb-toggle-button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(48, 164, 234, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 11px;
  line-height: 1.2;
  background: var(--myqb-brand);
  color: #fff;
  position: relative;
  z-index: 10003;
  transition: transform 150ms var(--myqb-ease),
    box-shadow 150ms var(--myqb-ease), background 150ms var(--myqb-ease);
  animation: myqb-pulse 2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0;
}

.myqb-toggle-text {
  display: block;
  text-align: center;
  line-height: 1.1;
}

@keyframes myqb-pulse {
  0%,
  100% {
    box-shadow: 0 8px 20px rgba(48, 164, 234, 0.4),
      0 4px 12px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 8px 25px rgba(48, 164, 234, 0.6),
      0 6px 16px rgba(0, 0, 0, 0.4);
  }
}

.myqb-toggle-button:hover {
  transform: translateY(-2px) scale(1.05);
  background: var(--myqb-brand-strong);
  box-shadow: 0 10px 28px rgba(48, 164, 234, 0.5),
    0 6px 16px rgba(0, 0, 0, 0.35);
  animation: none;
}

.myqb-toggle-button:active {
  transform: translateY(0) scale(1);
}

.myqb-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: none; /* shown when > 0 via JS */
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  border: 2px solid #fff;
}

.myqb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity 200ms var(--myqb-ease);
}

.myqb-widget-open .myqb-overlay {
  opacity: 1;
  pointer-events: auto;
}

.myqb-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 420px;
  max-height: 560px;
  background: var(--myqb-bg);
  color: var(--myqb-fg);
  border-radius: var(--myqb-radius);
  box-shadow: var(--myqb-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  /* border: 1px solid var(--myqb-border); */
  transform: translateY(8px);
  opacity: 0;
  z-index: 10002;
  transition: transform 180ms var(--myqb-ease), opacity 180ms var(--myqb-ease);
}

.myqb-widget-open .myqb-panel {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

.myqb-panel-header {
  padding: 14px 16px;
  background: var(--myqb-brand);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.myqb-panel-header h3 {
  font-size: 16px;
  margin: 0;
  color: white !important;
  text-transform: uppercase;
  font-weight: 700;
}

.myqb-panel-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: background 150ms var(--myqb-ease);
}

.myqb-panel-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.myqb-panel-body {
  padding: 18px 16px;
  overflow-y: auto;
  max-height: 480px;
  min-height: 320px;
}

/* Views */
.myqb-views {
  display: block;
}
.myqb-view {
  display: none;
}
.myqb-view.myqb-view-active {
  display: block;
}

/* Actions (footer buttons inside views) */
.myqb-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 8px;
}

/* Actions alignment at end of forms */
.myqb-actions-end {
  justify-content: flex-end;
}

/* Back button style */
.myqb-back {
  background: transparent !important;
  color: var(--myqb-brand) !important;
  border: 1px solid var(--myqb-brand) !important;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px !important;
  cursor: pointer !important;
}
.myqb-back:hover {
  background: #eaf6fe !important;
}
.myqb-back:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(48, 164, 234, 0.35) !important;
}

/* Next button adheres to submit style */
.myqb-next {
  background: var(--myqb-brand);
  color: #fff;
  border: none;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms var(--myqb-ease), opacity 150ms var(--myqb-ease);
}
.myqb-next:hover {
  background: var(--myqb-brand-strong);
}
.myqb-next[disabled],
.myqb-next[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.myqb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--myqb-border);
  border-radius: 8px;
  transition: background 150ms var(--myqb-ease),
    border-color 150ms var(--myqb-ease);
}

.myqb-item:hover {
  background: #fafafa;
  border-color: #e2e8f0;
}

.myqb-item-media {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0; /* allow name to ellipsis */
  flex: 1 1 auto;
}

.myqb-item-name {
  flex: 1 1 auto;
  min-width: 0; /* critical for ellipsis in flex children */
}

.myqb-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--myqb-border);
  background: #fff;
  flex: 0 0 44px;
}

.myqb-item-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto; /* prevent shrinking so buttons never wrap */
}

.myqb-qty-btn {
  border: 1px solid var(--myqb-border);
  background: #fff;
  color: var(--myqb-fg);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  font-weight: 700;
  transition: background 150ms var(--myqb-ease),
    border-color 150ms var(--myqb-ease);
}
.myqb-qty-btn:hover {
  background: #f8fafc;
  border-color: #dbeafe;
}
.myqb-qty-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(48, 164, 234, 0.35);
}

.myqb-item-name a {
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  display: block; /* ensures width obeys parent flex sizing */
  max-width: 100%;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.myqb-item-qty {
  font-size: 12px;
  color: var(--myqb-muted);
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

.myqb-remove {
  border: 1px solid var(--myqb-border);
  background: #fff;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--myqb-danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms var(--myqb-ease),
    border-color 150ms var(--myqb-ease), color 150ms var(--myqb-ease);
}

.myqb-remove:hover {
  background: #fff1f2;
  border-color: #fecdd3;
}

.myqb-form {
  margin-top: 10px;
  font-size: 14px;
}

.myqb-form-row {
  margin-bottom: 12px;
}

.myqb-form input,
.myqb-form textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 15px;
  border: 1px solid var(--myqb-border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: border-color 150ms var(--myqb-ease),
    box-shadow 150ms var(--myqb-ease);
}

.myqb-form input::placeholder,
.myqb-form textarea::placeholder {
  color: #9ca3af;
  opacity: 1;
}

.myqb-form label {
  display: block;
  width: 100%;
}

.myqb-form input:focus,
.myqb-form textarea:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.35);
}

.myqb-submit {
  width: 100%;
  margin-top: 4px;
  background: var(--myqb-brand);
  border: none;
  color: #fff;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms var(--myqb-ease),
    transform 150ms var(--myqb-ease), box-shadow 150ms var(--myqb-ease);
}

.myqb-submit:hover {
  background: var(--myqb-brand-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.myqb-feedback {
  margin-bottom: 16px;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 500;
  line-height: 1.5;
  display: none;
}

.myqb-feedback.myqb-success,
.myqb-feedback.myqb-error {
  display: block;
}

.myqb-success {
  color: #065f46;
  background: #d1fae5;
  border: 2px solid #10b981;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.myqb-error {
  color: #991b1b;
  background: #fee2e2;
  border: 2px solid #ef4444;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

/* Responsive */
@media (max-width: 480px) {
  .myqb-panel {
    width: calc(100vw - 40px);
    right: 0px;
    bottom: 72px;
    max-height: 70vh;
  }
  .myqb-item-name a {
    max-width: 150px;
  }
}

/* No dark mode variant as requested */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .myqb-toggle-button,
  .myqb-panel,
  .myqb-overlay,
  .myqb-submit {
    transition: none;
    animation: none;
  }
}
