/* ============================================================================
   AKKATT - Sidebar Navigation & User Profile
   SDD: Sidebar primary navigation with history, drawer behavior, profile popover
   ============================================================================ */

.drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 85%;
  max-width: 360px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 30;
}

.drawer.is-open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.drawer__header {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 48px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.brand-logo img {
  display: block;
  width: 168px;
  height: auto;
}

.brand-logo__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 0.5rem;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.9rem;
}

.mobile-close-btn,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-close-btn:hover,
.icon-button:hover {
  background: var(--bg-main);
  border-color: var(--border);
}

.app-header .mobile-toggle,
.app-header .cart-toggle-btn {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.2rem;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-new-chat:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  color: #ffffff;
}

.btn-new-chat__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1;
}

.search-chat-box {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 0.9rem;
}

.search-chat-box input {
  width: 100%;
  height: 2.7rem;
  padding: 0.7rem 0.8rem 0.7rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 0.92rem;
}

.search-chat-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
  outline: none;
}

.search-chat-box__icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--text-muted);
}

.drawer__content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 1rem;
}

.history-group {
  margin-bottom: 1rem;
}

.history-group__label,
.history-group-title {
  padding: 0.3rem 0.4rem 0.45rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: var(--font-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  width: 100%;
  padding: 0.72rem 0.7rem 0.72rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item__menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.history-item__menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.1rem;
  letter-spacing: 0;
}

.history-item__menu-button:hover,
.history-item__menu-wrap.is-open .history-item__menu-button {
  background: var(--surface);
  color: var(--primary);
}

.history-item__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 8;
  display: none;
  min-width: 9rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.history-item__menu-wrap.is-open .history-item__menu {
  display: block;
}

.history-item__menu-action {
  display: block;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 7px;
  color: var(--text-main);
  text-align: left;
}

.history-item__menu-action:hover {
  background: var(--bg-main);
}

.history-item__menu-action--danger {
  color: #b91c1c;
}

.chat-rename-modal,
.chat-delete-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.chat-rename-modal.is-open,
.chat-delete-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.chat-rename-modal__panel,
.chat-delete-modal__panel {
  width: min(100%, 26rem);
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.chat-rename-modal__panel h2,
.chat-delete-modal__panel h2 {
  margin-bottom: 0.55rem;
  color: var(--text-main);
  font-size: 1.1rem;
}

.chat-delete-modal__panel p {
  color: var(--text-muted);
}

.chat-rename-modal__panel label {
  display: block;
  margin-top: 1rem;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: var(--font-semibold);
}

.chat-rename-modal__panel input {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-main);
}

.chat-rename-modal__panel input:focus {
  border-color: var(--primary);
  outline: none;
}

.chat-rename-modal__error {
  margin-top: 0.55rem;
  color: #b91c1c;
  font-size: 0.85rem;
}

.chat-rename-modal__actions,
.chat-delete-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.2rem;
}

.chat-rename-modal__cancel,
.chat-rename-modal__confirm,
.chat-delete-modal__cancel,
.chat-delete-modal__confirm {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-weight: var(--font-semibold);
}

.chat-rename-modal__cancel,
.chat-delete-modal__cancel {
  border: 1px solid var(--border);
  color: var(--text-main);
}

.chat-rename-modal__confirm {
  background: var(--primary);
  color: #ffffff;
}

.chat-delete-modal__confirm {
  background: #b91c1c;
  color: #ffffff;
}

.history-item:hover {
  background: var(--bg-main);
}

.history-item.active {
  background: #f1f5f9;
  font-weight: 600;
  border-left: 3px solid var(--primary);
  border-radius: 0 10px 10px 0;
  padding-left: 0.45rem;
}

.history-item__content {
  min-width: 0;
  flex: 1;
}

.history-item__title {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.92rem;
  font-weight: var(--font-medium);
}

.history-item-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.18rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.cart-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  margin-left: auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-indicator.has-items {
  background: var(--accent-green);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.14);
}

.drawer__footer {
  position: relative;
  padding: 0.9rem 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.profile-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.profile-button:hover {
  background: var(--bg-main);
}

.profile-button[aria-expanded="true"] {
  border-color: var(--primary);
  background: rgba(15, 118, 110, 0.05);
}

.profile-button__identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

.profile-meta {
  min-width: 0;
  text-align: left;
}

.profile-meta__name {
  display: block;
  font-size: 0.9rem;
  font-weight: var(--font-semibold);
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-meta__role {
  display: block;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.profile-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-muted);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.profile-button[aria-expanded="true"] .profile-caret {
  transform: rotate(180deg);
}

.profile-popover {
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: calc(100% + 0.55rem);
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
}

.profile-popover.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.profile-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  padding: 0.75rem 0.7rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-main);
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.profile-menu__item:hover {
  background: var(--bg-main);
}

.profile-menu__item--danger {
  color: var(--accent-red);
}

.app-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
}

.app-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cart-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
}

.cart-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 64px;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__left,
.cart-button-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header__brand {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.app-header__brand img {
  display: block;
  width: 42px;
  height: 42px;
}

.app-header__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  min-width: 0;
}

.app-header__eyebrow {
  display: block;
  color: var(--text-muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header__title strong {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.94rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-button-wrapper {
  position: relative;
}

.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.22rem;
  border-radius: 999px;
  background: var(--accent-red);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: var(--font-bold);
  border: 2px solid var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.drawer-right {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
}

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

.cart-drawer__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cart-drawer__header-row h2 {
  margin: 0;
  font-size: 1.2rem;
}

.cart-tabs-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.cart-tab-btn {
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: var(--font-semibold);
  cursor: pointer;
}

.cart-tab-btn.active {
  background: rgba(15, 118, 110, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.cart-drawer__content {
  padding: 0.85rem;
}

.cart-items-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cart-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.cart-item__media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 0.7rem;
  background: var(--bg-main);
  font-size: 1.2rem;
}

.cart-item__body {
  flex: 1;
  min-width: 0;
}

.cart-item__header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.cart-item__header-row h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.35;
}

.cart-item__remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.cart-item__origin {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.cart-item__footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.quantity-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-main);
}

.qty-btn {
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
}

.qty-value {
  min-width: 1rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: var(--font-semibold);
}

.cart-item__price {
  font-size: 0.9rem;
  font-weight: var(--font-bold);
  color: var(--text-main);
}

.empty-cart-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 220px;
  gap: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-main);
  padding: 1.25rem;
}

.empty-cart-state__icon {
  font-size: 2rem;
}

.empty-cart-state h3 {
  margin: 0;
  font-size: 1.05rem;
}

.empty-cart-state p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.cart-drawer__footer {
  padding: 0.85rem 1rem 1rem;
}

.input-area {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
  padding: 12px 24px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* L'angolo del gradiente deve essere registrato come <angle> per poter essere interpolato:
   una custom property non tipizzata non sarebbe animabile. */
@property --gradient-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.input-box-container {
  position: relative;
  width: min(100%, 700px);
  margin: 0 auto;
  padding: 0;
  border-radius: 20px;
  transition: padding 0.2s ease;
}

.input-box-container.is-selective {
  padding: 2px;
  border-radius: 26px;
}

.input-box-container.is-selective::before,
.input-box-container.is-selective::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(
    from var(--gradient-angle),
    #0f766e,
    #10b981,
    #3b82f6,
    #8b5cf6,
    #10b981,
    #0f766e
  );
  animation: selective-gradient-spin 4s linear infinite;
}

.input-box-container.is-selective::after {
  filter: blur(18px);
  opacity: 0.32;
  transform: scale(1.02);
}

.input-controls {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.75rem 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(248, 250, 252, 0.9);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.input-box-container.is-selective .input-controls {
  border-color: transparent;
  border-radius: 24px;
  background: #ffffff;
}

@keyframes selective-gradient-spin {
  to {
    --gradient-angle: 360deg;
  }
}

.selective-mode-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: -0.2rem;
  /* #7c3aed su bianco = 5.9:1, sopra il minimo AA anche a peso bold. */
  color: #7c3aed;
  font-size: 0.82rem;
  font-weight: var(--font-bold, 700);
}

.selective-mode-header[hidden] {
  display: none;
}

.selective-mode-header__spark {
  animation: selective-dot-pulse 1.8s ease-in-out infinite;
}

@keyframes selective-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.86); }
}

@media (prefers-reduced-motion: reduce) {
  .input-box-container.is-selective::before,
  .input-box-container.is-selective::after,
  .selective-mode-header__spark {
    animation: none;
  }
}

.input-disclaimer {
  width: min(100%, 700px);
  margin: 0 auto;
  text-align: center;
  /* #64748b su superficie chiara = 4.76:1, sopra il minimo AA. */
  color: var(--text-muted);
  font-size: var(--font-xs);
  line-height: 1.4;
}

.input-controls.is-focused {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.chat-input {
  width: 100%;
  min-height: 28px;
  max-height: 160px;
  border: none;
  background: transparent;
  color: var(--text-main);
  resize: none;
  outline: none;
  font: inherit;
  line-height: 1.45;
  overflow-y: auto;
}

.chat-input:focus-visible {
  outline: none;
}

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

.input-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.quick-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.selective-search-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.2rem;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: var(--font-semibold, 600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.selective-search-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.selective-search-toggle.is-active {
  /* Estremi scelti per tenere il testo bianco sopra 4.5:1 lungo tutto il gradiente. */
  background: linear-gradient(90deg, #6d28d9, #0f766e);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25);
}

.selective-search-toggle__close {
  display: none;
  margin-left: 0.15rem;
  font-size: 1.05rem;
  line-height: 1;
}

.selective-search-toggle.is-active .selective-search-toggle__close {
  display: inline;
}

.input-box-container.is-selective .btn-send {
  background: linear-gradient(135deg, #6d28d9, #0f766e);
}

.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 2.8rem;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: var(--font-bold);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-send.is-stop {
  background: #6b7280;
  color: #ffffff;
}

.btn-send.is-stop:hover {
  background: #4b5563;
}

.loading-dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 1.5rem;
}

.loading-dots span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--primary);
  animation: loading-dot-bounce 0.9s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loading-dot-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-0.55rem);
  }
}

.app-main.chat-layout {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0;
}

.app-main.chat-layout > .app-header {
  order: 0 !important;
  flex-shrink: 0;
}

.app-main.chat-layout > .chat-stream {
  order: 1 !important;
  flex: 1;
}

.app-main.chat-layout > .input-area {
  order: 2 !important;
  flex-shrink: 0;
}

.chat-stream {
  width: min(100%, 900px);
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .app-main.chat-layout {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .app-header {
    grid-row: 1 / 2;
    order: unset;
  }

  .chat-stream {
    width: min(100%, 900px);
    margin: 0 auto;
    grid-row: 2 / 3;
  }

  .input-area {
    grid-row: 3 / 4;
  }
}

.cart-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.cart-total-row strong {
  color: var(--text-main);
  font-size: 1.2rem;
}

.cart-checkout-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: #ffffff;
  padding: 0.85rem 1rem;
  font-weight: var(--font-bold);
  cursor: pointer;
}

.chat-stream {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(248,250,252,0.92));
  scroll-behavior: smooth;
}

.gemini-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 340px;
  gap: 1rem;
  color: var(--text-main);
}

.gemini-empty-state.is-hidden {
  display: none;
}

.sparkle-logo {
  position: relative;
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, rgba(13,148,136,0.18), rgba(34,211,238,0.18));
  clip-path: polygon(50% 0%, 61% 34%, 100% 50%, 61% 66%, 50% 100%, 39% 66%, 0% 50%, 39% 34%);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,0.18);
  animation: pulseSparkle 2.5s ease-in-out infinite;
}

.sparkle-core {
  position: absolute;
  inset: 18px;
  background: linear-gradient(135deg, var(--primary), #22d3ee);
  clip-path: polygon(50% 0%, 61% 34%, 100% 50%, 61% 66%, 50% 100%, 39% 66%, 0% 50%, 39% 34%);
}

.gemini-empty-state h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.gemini-empty-state p {
  max-width: 560px;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: 100%;
}

.msg {
  width: fit-content;
  max-width: 85%;
  min-height: auto;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.msg-user--selective {
  background: linear-gradient(120deg, #0f766e, #3b82f6 55%, #6d28d9);
  box-shadow: 0 6px 18px rgba(109, 40, 217, 0.22);
}

.msg-user__badge {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.68rem;
  font-weight: var(--font-bold, 700);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.95;
}

.msg-ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 4px;
}

.msg-ai--products {
  position: relative;
  width: min(100%, 760px);
  max-width: 100%;
}

.msg-ai__header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  font-size: 0.76rem;
  font-weight: var(--font-bold);
  color: var(--primary);
}

.msg-ai__spark {
  font-size: 0.8rem;
}

.msg-ai__text {
  color: var(--text-main);
}

.product-results {
  position: static;
  margin-top: 12px;
}

.product-results-carousel {
  display: flex;
  gap: 12px;
  padding-bottom: 4px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.product-results-carousel::-webkit-scrollbar {
  display: none;
}

.product-results-carousel__item {
  flex: 0 0 calc(100% - 64px);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  min-width: 0;
}

.product-results-carousel__item .product-card {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  height: 100%;
}

.product-results__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
  cursor: pointer;
  font-size: 2.75rem;
  line-height: 1;
}

.product-results__nav:hover,
.product-results__nav:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

.product-results__nav[hidden] {
  display: none;
}

.product-results__nav--previous {
  left: -27px;
}

.product-results__nav--next {
  right: -27px;
}

.product-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  background: transparent;
  outline: none;
}

.product-card__carousel {
  position: relative;
  height: 260px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  overflow: hidden;
  order: 1;
  margin-top: 0;
}

.carousel-track {
  display: block;
  width: 100%;
  height: 100%;
}

.carousel-slide {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
}

.carousel-slide.active {
  display: flex;
}

.carousel-slide__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.75rem;
}

/* Fallback logo: smaller and centred so it reads as a placeholder, not as product art. */
.carousel-slide--placeholder {
  background: #f8fafc;
}

.carousel-slide--placeholder .carousel-slide__img {
  width: auto;
  max-width: 55%;
  height: auto;
  max-height: 55%;
  opacity: 0.75;
  padding: 0;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-main);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.carousel-btn.prev {
  left: 0.65rem;
}

.carousel-btn.next {
  right: 0.65rem;
}

.carousel-dots {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(4px);
}

.carousel-dot {
  width: 0.6rem;
  height: 0.6rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.carousel-dot.active {
  background: var(--primary);
}

.product-card__content {
  padding-top: 0.9rem;
  order: 2;
}

.product-card__title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-main);
}

.product-card__format {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.product-card__codes {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.65rem;
  margin-top: 0.8rem;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.code-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  padding: 0.38rem 0.7rem;
  border-radius: 0.75rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
}

.brand-badge {
  flex: 0 1 auto;
  max-width: min(100%, 12.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card__description {
  margin: 0.8rem 0 0;
  color: var(--text-main);
  font-size: 1.04rem;
  line-height: 1.55;
}

.price-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #cfead8;
  border-radius: 14px;
  background: #f0fdf4;
}

.price-box__topline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
}

.price-box__list {
  color: var(--text-muted);
  text-decoration: line-through;
  font-size: 1.1rem;
  font-weight: 500;
}

.discount-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 0.55rem;
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  font-size: 0.95rem;
  font-weight: 800;
}

.price-box__current {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0;
  min-width: 160px;
}

.price-box__label {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-bottom: 0.18rem;
}

.price-box__current strong {
  color: var(--primary);
  font-size: 2.1rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.05em;
}

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

.product-card__qty-picker {
  flex: 0 0 165px;
  justify-content: space-between;
  height: 56px;
  padding: 0 0.65rem;
  border: 1px solid var(--primary);
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.06);
}

.qty-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: transparent;
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 700;
}

.qty-value {
  min-width: 1.2rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-add-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex: 1 1 auto;
  min-width: 230px;
  height: 56px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 14px;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: var(--font-bold);
  cursor: pointer;
}

.btn-add-cart span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  filter: brightness(0) invert(1);
}

@media (min-width: 1024px) {
  .product-card__carousel {
    height: 200px;
  }
}

@keyframes pulseSparkle {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.82;
  }
}

@media (min-width: 1024px) {
  .chat-stream {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    padding: 32px 10%;
  }

  .msg {
    max-width: 70%;
  }
}

@media (min-width: 1440px) {
  .chat-stream {
    padding: 32px 15%;
  }
}

.product-card {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  box-sizing: border-box;
  overflow: hidden;
}

.product-card__media {
  display: none;
}

.product-card__body {
  display: block;
}

.product-card__title {
  margin: 0;
  font-size: clamp(1.32rem, 1.8vw, 2.2rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-main);
  word-break: break-word;
}

.product-card__meta {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.product-card__price {
  color: var(--primary);
  font-weight: var(--font-bold);
}

.product-card__content {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.product-card__codes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.code-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.72rem;
  border-radius: 0.8rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
}

.product-card__description {
  margin-top: 0.8rem;
  font-size: 1.08rem;
  line-height: 1.5;
  color: var(--text-main);
  word-break: break-word;
}

.price-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  width: 100%;
  margin-top: 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid #cfead8;
  border-radius: 14px;
  background: #f0fdf4;
  box-sizing: border-box;
}

.price-box__topline {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 1 auto;
  min-width: 0;
}

.price-box__list {
  color: var(--text-muted);
  font-size: 1.1rem;
  text-decoration: line-through;
  white-space: nowrap;
}

.discount-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.52rem;
  border-radius: 0.52rem;
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  font-size: 0.92rem;
  font-weight: 800;
}

.price-box__current {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 165px;
  margin-left: auto;
}

.price-box__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.price-box__current strong {
  color: var(--primary);
  font-size: clamp(1.6rem, 2vw, 2.25rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.discount-pill {
  flex-shrink: 0;
  white-space: nowrap;
}

.product-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  width: 100%;
  margin-top: 1rem;
}

.product-card__qty-picker {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 136px;
  height: 48px;
  padding: 0 0.6rem;
  border: 1px solid rgba(15, 118, 110, 0.7);
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.04);
  box-sizing: border-box;
}

.qty-btn {
  width: 1.8rem;
  height: 1.8rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.qty-value {
  min-width: 1.2rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}

.btn-add-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  height: 52px;
  padding: 0.7rem 0.9rem;
  border: none;
  border-radius: 14px;
  background: var(--primary);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-sizing: border-box;
}

.btn-add-cart span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  filter: brightness(0) invert(1);
}

@media (min-width: 1024px) {
  .drawer {
    position: static;
    width: 100%;
    max-width: none;
    transform: none;
    box-shadow: none;
    border-right: 1px solid var(--border);
    grid-column: 1 / 2;
    grid-row: 1 / 5;
  }

  .drawer-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    display: flex;
    width: min(360px, 85vw);
    max-width: none;
    transform: translateX(100%);
    border-right: none;
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 40;
  }

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

  .drawer-right .cart-close-btn {
    display: inline-flex;
  }

  .mobile-close-btn {
    display: none;
  }

  .app-backdrop,
  .cart-backdrop {
    display: none;
  }

  .app-header {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border);
  }

  .app-main.chat-layout {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }

  .app-header .mobile-toggle {
    display: none;
  }
}
