/* CSS Variables for consistent theming */
:root {
  --auth-bg-start: #f6f9fc;
  --auth-bg-end: #e9f0ff;
  --auth-card-radius: 14px;
  --auth-shadow: 0 10px 25px rgba(16, 24, 40, 0.08);
  --focus-ring: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  --scrollbar-track: rgba(16, 24, 40, 0.04);
  --scrollbar-thumb: rgba(16, 24, 40, 0.18);
  --scrollbar-thumb-hover: rgba(16, 24, 40, 0.28);
  --primary-color: #0d6efd;
  --primary-hover: #0a58ca;
  --bg-subtle: #e7f1ff;
  --bg-secondary: #f1f3f5;
}

/* Subtle, friendly background */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8f9fa, #ffffff 80%);
}

/* Main content area */
main {
  flex: 1 0 auto;
}

/* Card polish */
.auth-card {
  border: 1px solid rgba(16, 24, 40, 0.06);
  border-radius: var(--auth-card-radius);
  box-shadow: var(--auth-shadow);
  backdrop-filter: saturate(120%) blur(2px);
}

/* Title styling */
.brand {
  letter-spacing: 0.2px;
}

/* Input focus aesthetic without harming accessibility */
.auth-card .form-control:focus {
  box-shadow: var(--focus-ring);
  border-color: #86b7fe;
}

/* Checkbox alignment tweak */
.auth-card .form-check-input:focus {
  box-shadow: var(--focus-ring);
  border-color: #86b7fe;
}

/* Button hover micro-interaction */
.auth-card .btn-primary {
  transition: transform .06s ease, box-shadow .2s ease;
}
.auth-card .btn-primary:hover {
  transform: translateY(-1px);
}

/* Alerts spacing stack */
.alerts-stack .alert {
  border-radius: 10px;
}

/* Make reCAPTCHA play nice on small screens */
.g-recaptcha {
  transform-origin: left top;
}
@media (max-width: 360px) {
  .g-recaptcha { transform: scale(0.9); }
}
@media (max-width: 320px) {
  .g-recaptcha { transform: scale(0.82); }
}

/* Tiny text helpers */
.text-muted.small { display: inline-block; padding: 0 .25rem; }

/* OTP input polish */
.otp-input {
  text-align: center;
  letter-spacing: 2px;
  font-weight: 600;
}

/* Scrollable cart list to prevent overflow when many items */
.cart-list-scroll {
  max-height: 50vh; /* responsive by default */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px; /* room for scrollbar */
}

@media (min-width: 992px) {
  .cart-list-scroll {
    max-height: 420px; /* comfortable height on desktop */
  }
}

/* Optional: nicer thin scrollbar (WebKit/Blink) */
.cart-list-scroll::-webkit-scrollbar {
  width: 8px;
}
.cart-list-scroll::-webkit-scrollbar-track {
  background: rgba(16, 24, 40, 0.04);
  border-radius: 8px;
}
.cart-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(16, 24, 40, 0.18);
  border-radius: 8px;
}
.cart-list-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 24, 40, 0.28);
}

/* Cart item typography tweaks */
.cart-item-title {
  font-size: 1.075rem;
  line-height: 1.35;
}
.cart-item-meta {
  font-size: 0.95rem !important; /* override Bootstrap .small */
}
.cart-item-total {
  font-size: 1.05rem;
}

@media (min-width: 576px) {
  .cart-item-title { font-size: 1.125rem; }
  .cart-item-meta { font-size: 1rem !important; }
  .cart-item-total { font-size: 1.1rem; }
}


/* Fallbacks for subtle backgrounds if Bootstrap < 5.3 */
.bg-primary-subtle { background-color: #e7f1ff !important; }
.bg-secondary-subtle { background-color: #f1f3f5 !important; }

.chat-messages ul { margin: 0; padding: 0; }

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
}

.bubble {
  max-width: 85%;
  padding: .6rem .75rem;
  border-radius: 12px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
}

.bubble-assistant {
  background: var(--bs-primary-bg-subtle, #e7f1ff);
  border: 1px solid rgba(13,110,253,.12);
}

.bubble-user {
  background: var(--bs-secondary-bg, #f1f3f5);
  border: 1px solid rgba(108,117,125,.18);
}

/* Markdown rendering tweaks */
.message-text p { margin-bottom: .5rem; }
.message-text a {
  color: var(--bs-link-color, #0d6efd);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
  font-weight: 500;
  /* wrap long URLs gracefully */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-text a:hover {
  color: var(--bs-link-hover-color, #0a58ca);
  text-decoration-thickness: 2px;
}
.message-text a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.25);
  border-radius: 4px;
}
.md-code {
  background: rgba(16,24,40,.04);
  border: 1px solid rgba(16,24,40,.08);
  border-radius: 8px;
  padding: .6rem .75rem;
  overflow-x: auto;
}
.md-code-inline {
  background: rgba(16,24,40,.05);
  border-radius: 4px;
  padding: 0 .25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* Sticky composer inside card */
.sticky-composer {
  position: sticky;
  bottom: 0;
  background: var(--bs-body-bg, #ffffff);
  border-top: 1px solid rgba(16,24,40,.06);
  padding-top: .5rem;
}

/* Nicer thin scrollbar for chat list */
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: rgba(16,24,40,.04); border-radius: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(16,24,40,.18); border-radius: 8px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(16,24,40,.28); }

/* Fixed-size images in chat bubbles */
.chat-image {
  width: 200px;
  height: 200px;
  object-fit: cover; /* crop to fill, keep center */
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
}

@media (max-width: 420px) {
  .chat-image {
    width: 150px;
    height: 150px;
  }
}

/* Full-screen Chat page layout */
.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.chat-header {
  position: sticky;
  top: 0;
  background: var(--bs-body-bg, #ffffff);
  z-index: 1030; /* above content */
}
.chat-main {
  flex: 1 1 auto;
  min-height: 0; /* allow children to flex/scroll */
  display: block;
}
/* In full-screen chat, let messages take available height and scroll */
.chat-page .chat-messages {
  max-height: none;
  height: 100%;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

.chat-messages-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 1.5rem;
}

.chat-composer-wrapper {
    flex-shrink: 0;
    background: var(--bs-body-bg, #ffffff);
    border-top: 1px solid rgba(16, 24, 40, 0.08);
    padding: 1rem 1.5rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

/* Custom scrollbar for chat messages */
.chat-messages-wrapper::-webkit-scrollbar {
    width: 8px;
}
.chat-messages-wrapper::-webkit-scrollbar-track {
    background: var(--scrollbar-track, rgba(16, 24, 40, 0.04));
    border-radius: 8px;
}
.chat-messages-wrapper::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, rgba(16, 24, 40, 0.18));
    border-radius: 8px;
}
.chat-messages-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover, rgba(16, 24, 40, 0.28));
}