/* Site overrides on top of Bootstrap 5.3 RTL (spec §77.3). */

/* Vazirmatn, self-hosted (spec §77.1). */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn/fonts/webfonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn/fonts/webfonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn/fonts/webfonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Fallback theme; the layout overrides these from Configuration (theme.*, spec §34). */
:root {
  --oriva-primary: #1E3A8A;
  --oriva-secondary: #0EA5E9;
  --oriva-accent: #F59E0B;
  --bs-font-sans-serif: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: var(--bs-font-sans-serif);
  /* Optional theme colors (Phase I.2, Configuration theme.*); Bootstrap's defaults when not set. */
  color: var(--oriva-text, var(--bs-body-color));
  background-color: var(--oriva-bg, var(--bs-body-bg));
}

:root {
  --bs-border-color: var(--oriva-border, #dee2e6);
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--oriva-heading, inherit);
}

.site-logo {
  max-height: 36px;
  max-width: 140px;
  object-fit: contain;
}

a {
  color: var(--site-primary, var(--oriva-primary));
}

.text-primary-theme {
  color: var(--site-primary, var(--oriva-primary)) !important;
}

/* Notifications (Phase H): unread rows, the header bell counter and the copied state of a "copy" button. */
.notification-unread {
  background-color: rgba(30, 58, 138, 0.06);
  border-inline-start: 3px solid var(--site-primary, var(--oriva-primary));
}

.notification-badge {
  position: absolute;
  top: 0.15rem;
  inset-inline-start: 0.1rem;
  font-size: 0.65rem;
}

[data-copy].is-copied {
  color: var(--bs-success) !important;
}

.btn-primary-theme {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--site-primary, var(--oriva-primary));
  --bs-btn-border-color: var(--site-primary, var(--oriva-primary));
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 85%, #000);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 75%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 75%, #000);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--site-primary, var(--oriva-primary));
  --bs-btn-disabled-border-color: var(--site-primary, var(--oriva-primary));
}

.btn-outline-primary-theme {
  --bs-btn-color: var(--site-primary, var(--oriva-primary));
  --bs-btn-border-color: var(--site-primary, var(--oriva-primary));
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--site-primary, var(--oriva-primary));
  --bs-btn-hover-border-color: var(--site-primary, var(--oriva-primary));
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--site-primary, var(--oriva-primary));
  --bs-btn-active-border-color: var(--site-primary, var(--oriva-primary));
}

.btn:focus-visible,
.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 30%, transparent);
}

/* Header / Footer */
.site-header .nav-link.active {
  color: var(--site-primary, var(--oriva-primary));
  font-weight: 500;
}

.site-footer {
  background-color: var(--bs-tertiary-bg);
  border-top: 1px solid var(--bs-border-color);
}

.license-placeholder {
  border: 1px dashed var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
}

/* Home */
.hero {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 10%, #fff),
    color-mix(in srgb, var(--site-secondary, var(--oriva-secondary)) 10%, #fff));
}

.rate-card,
.shipping-card,
.benefit-card,
.deeplink-box {
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
}

.shipping-card {
  border-inline-start: 4px solid var(--oriva-accent);
}

.banner-img {
  max-height: 360px;
  object-fit: cover;
}

.h-scroll {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.store-chip {
  width: 150px;
  scroll-snap-align: start;
}

.stepper-circle {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  background-color: var(--site-primary, var(--oriva-primary));
}

@media (min-width: 768px) {
  .stepper-item {
    position: relative;
  }

  .stepper-item:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 1.75rem;
    inset-inline-start: calc(50% + 2rem);
    width: calc(100% - 4rem);
    border-top: 2px dashed var(--bs-border-color);
  }
}

/* Catalog */
.logo-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.logo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--site-primary, var(--oriva-primary));
  background-color: color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 10%, #fff);
  flex-shrink: 0;
}

.catalog-card {
  transition: box-shadow 0.15s ease-in-out;
}

.catalog-card:hover {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

.catalog-card.is-inactive {
  opacity: 0.6;
}

.category-card img,
.catalog-card .card-img-top {
  height: 140px;
  object-fit: cover;
}

/* Purchase Request (spec §61.4, §61.5, §70.1) */
.request-card {
  max-width: 640px;
}

.drop-zone {
  border: 2px dashed var(--bs-border-color);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--site-primary, var(--oriva-primary));
  background-color: var(--bs-tertiary-bg);
}

.attachment-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumb .attachment-remove {
  position: absolute;
  top: 0.25rem;
  inset-inline-end: 0.25rem;
  padding: 0 0.3rem;
  line-height: 1.4;
}

.attachment-thumb.is-removed img {
  opacity: 0.3;
}

.quantity-stepper {
  max-width: 11rem;
}

.request-step {
  position: relative;
  color: var(--bs-secondary-color);
}

.request-step-dot {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bs-border-color);
  background-color: var(--bs-body-bg);
  position: relative;
  z-index: 1;
}

.request-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 1.125rem;
  inset-inline-start: calc(50% + 1.125rem);
  width: calc(100% - 2.25rem);
  border-top: 2px solid var(--bs-border-color);
}

.request-step.is-done,
.request-step.is-current {
  color: var(--bs-body-color);
}

.request-step.is-done .request-step-dot {
  background-color: var(--site-primary, var(--oriva-primary));
  border-color: var(--site-primary, var(--oriva-primary));
  color: #fff;
}

.request-step.is-done:not(:last-child)::after {
  border-color: var(--site-primary, var(--oriva-primary));
}

.request-step.is-current .request-step-dot {
  border-color: var(--site-primary, var(--oriva-primary));
  color: var(--site-primary, var(--oriva-primary));
  font-weight: 700;
}

/* ---------- Order stepper (spec §70.3): horizontal on desktop, vertical on mobile ---------- */
@media (max-width: 767.98px) {
  .order-stepper {
    flex-direction: column;
    gap: 0.75rem;
  }

  .order-stepper .request-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: start !important;
  }

  .order-stepper .request-step-dot {
    margin: 0 !important;
    flex-shrink: 0;
  }

  .order-stepper .request-step:not(:last-child)::after {
    display: none;
  }
}

/* ---------- Conversation (spec §61.6) ---------- */
.conversation-messages {
  display: flex;
  flex-direction: column;
  height: 60vh;
  min-height: 320px;
  overflow-y: auto;
  padding: 1rem;
  background-color: var(--bs-tertiary-bg);
}

.chat-row {
  display: flex;
}

/* RTL: my messages sit on the left (flex-end), the other side on the right — as in Persian messengers. */
.chat-row.is-mine {
  justify-content: flex-end;
}

.chat-row.is-theirs {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: min(75%, 36rem);
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.chat-row.is-mine .chat-bubble {
  background-color: color-mix(in srgb, var(--site-primary, var(--oriva-primary)) 12%, #fff);
  border-end-end-radius: 0.25rem;
}

.chat-row.is-theirs .chat-bubble {
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-end-start-radius: 0.25rem;
}

.chat-sender {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--site-primary, var(--oriva-primary));
  margin-bottom: 0.15rem;
}

.chat-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.chat-attachments img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--bs-secondary-color);
}

.chat-receipt.is-read {
  color: var(--site-secondary, var(--oriva-secondary));
}

.conversation-dropzone {
  border-radius: 0.5rem;
  transition: outline-color 0.15s;
  outline: 2px dashed transparent;
  outline-offset: 4px;
}

.conversation-dropzone.is-dragover {
  outline-color: var(--site-secondary, var(--oriva-secondary));
}

/* Phase J: utility classes instead of inline style attributes (Content-Security-Policy without 'unsafe-inline'). */
.text-pre-line { white-space: pre-line; }

/* Platform 1-الف.۳: legal pages (text from the safe Markdown renderer). */
.legal-page { max-width: 52rem; }
.legal-content h2, .legal-content h3, .legal-content h4 { margin-top: 1.5rem; font-weight: 700; }
.legal-content a { overflow-wrap: anywhere; }
.img-max-240 { max-height: 240px; }
.media-preview-sm { max-height: 48px; max-width: 120px; }
.media-preview { max-height: 48px; max-width: 160px; }
.mw-360 { max-width: 360px; }
.mw-520 { max-width: 520px; }
.mw-560 { max-width: 560px; }
.minw-150 { min-width: 150px; }
.minw-190 { min-width: 190px; }
.thumb-72 { width: 72px; height: 72px; object-fit: cover; }

/* Pack 4 step 0: the quote form must not widen the admin page on a phone (390px): the fieldset and its table scroll
   inside the pane instead of pushing it 38px wider (E2E pack 3). */
.quote-fields { min-width: 0; max-width: 100%; }
/* The real cause (pack 4 E2E): the absolutely positioned visually-hidden «حذف» header escaped the scroll container (its containing
   block was outside it) and widened the page; the container is now its containing block, so it is clipped with the table. */
.quote-fields .table-responsive { max-width: 100%; position: relative; }
.quote-fields .input-group > .btn { white-space: normal; }
.admin-pane > .d-flex { min-width: 0; }

/* Pack 4: foreign catalog cards and product images (square, no layout shift). */
.catalog-card-img { aspect-ratio: 1 / 1; object-fit: cover; width: 100%; height: auto; }
.catalog-card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.catalog-product-img { aspect-ratio: 1 / 1; object-fit: cover; width: 100%; height: auto; }
.site-page-loading {
    --page-loading-ink: var(--brand-text, #0a1f44);
    position: fixed;
    inset: 0 0 auto;
    z-index: 1100;
    pointer-events: none;
    text-align: center;
}

.site-page-loading-track {
    display: block;
    height: 3px;
    background: #dbeaf6;
    overflow: hidden;
}

.site-page-loading-track > span {
    display: block;
    width: 35%;
    height: 100%;
    margin-inline: auto;
    background: var(--page-loading-ink);
}

.site-page-loading-label {
    display: inline-block;
    padding: .35rem .9rem;
    border-radius: 0 0 .75rem .75rem;
    background: white;
    color: var(--page-loading-ink);
    box-shadow: 0 4px 18px rgb(10 31 68 / 13%);
    font-size: .875rem;
    font-weight: 700;
}

@media (prefers-reduced-motion: no-preference) {
    .site-page-loading-track > span { animation: site-page-loading 1.3s ease-in-out infinite alternate; }
    @keyframes site-page-loading {
        from { transform: translateX(-95%); }
        to { transform: translateX(95%); }
    }
}

.flash-toast {
    position: fixed;
    left: max(1rem, env(safe-area-inset-left));
    top: max(1rem, env(safe-area-inset-top));
    z-index: 1080;
    width: min(25rem, calc(100vw - 2rem));
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    justify-content: space-between;
    border-radius: .85rem;
    box-shadow: 0 .6rem 1.8rem rgb(0 0 0 / 13%);
}
.flash-toast + .flash-toast { top: 7rem; }
.flash-toast .btn-close { flex: 0 0 auto; }
