/* MIDE OS · Portal Cliente · Cotizaciones del CRM (CO-01…09, DO-03). Layout only: components come from ui/components.css and
   every value from ui/tokens.css. The action colour is the tenant's in my.mide.lat (tenant theme), MIDE's otherwise. */
@layer views {
  .crm-quotes { display: grid; gap: var(--mide-space-3); }
  .crm-quotes[aria-busy='true'] { opacity: 0.7; }
  .crm-quote-version { align-items: flex-start; }
  .crm-quote-version[data-current='true'] { border-color: var(--mide-line-strong); }
  .crm-quote-acceptance { display: grid; gap: var(--mide-space-2); padding: var(--mide-space-3); border: 1px solid var(--mide-line); border-radius: var(--mide-radius-sm); background: var(--mide-surface-2); }
  .crm-quote-acceptance p { margin: 0; font-size: var(--mide-text-sm); color: var(--mide-ink); line-height: var(--mide-leading); }
  .crm-quote-evidence { white-space: pre-line; overflow-wrap: anywhere; }

  .crm-quote-editor { display: grid; gap: var(--mide-space-2); justify-items: start; }
  .crm-quote-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--mide-space-2); width: 100%; }
  .crm-quote-line { display: grid; grid-template-columns: minmax(0, 1fr) 6rem 10rem auto; gap: var(--mide-space-2) var(--mide-space-3); align-items: start; padding-bottom: var(--mide-space-3); border-bottom: 1px solid var(--mide-line); }
  .crm-quote-line-service, .crm-quote-field { display: grid; gap: var(--mide-space-1); min-width: 0; }
  .crm-quote-field > :not(.crm-quote-field-label) { width: 100%; min-width: 0; }
  .crm-quote-field-label { font-size: var(--mide-text-sm); font-weight: var(--mide-weight-semibold); color: var(--mide-ink); }
  .crm-quote-catalog-price { margin: 0; font-size: var(--mide-text-sm); color: var(--mide-muted); line-height: var(--mide-leading); }
  .crm-quote-line > .ui-button { margin-top: 1.6rem; }
  .crm-quote-line > * { min-width: 0; }

  .crm-quote-summary { min-height: 2.5rem; }
  .crm-quote-breakdown { display: grid; gap: var(--mide-space-2); }
  /* A long availability chip wraps inside its cell: the amounts column never leaves the dialog at 390 px. */
  .crm-quote-breakdown, .crm-quote-breakdown > * { min-width: 0; }
  .crm-quote-table .ui-chip { white-space: normal; height: auto; text-align: start; }
  .crm-quote-table { width: 100%; border-collapse: collapse; font-size: var(--mide-text-sm); }
  .crm-quote-table th, .crm-quote-table td { padding: var(--mide-space-2); border-bottom: 1px solid var(--mide-line); text-align: start; vertical-align: top; color: var(--mide-ink); }
  .crm-quote-table thead th { color: var(--mide-muted); font-weight: var(--mide-weight-semibold); }
  .crm-quote-table tbody th { font-weight: var(--mide-weight-semibold); }
  .crm-quote-table .is-amount { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .crm-quote-table tfoot th, .crm-quote-table tfoot td { border-bottom: 0; font-weight: var(--mide-weight-bold); font-size: var(--mide-text-md); }
  .crm-quote-concept { display: flex; align-items: center; gap: var(--mide-space-2); }
  .crm-quote-concept .ui-icon { flex: none; color: var(--mide-muted); }
  .crm-quote-acceptance-title { font-size: var(--mide-text-md); color: var(--mide-ink); }

  /* Client documents (CO-04, DO-01): the tenant's brand inside data-brand-zone="tenant" (MIDE_UI.applyTenantBrand sets the colours). */
  .crm-quote-docs { display: grid; gap: var(--mide-space-2); }
  .crm-doc-wrap { display: grid; gap: var(--mide-space-3); min-width: 0; }
  .crm-doc-wrap > *, .crm-doc > * { min-width: 0; }
  .crm-doc { display: grid; gap: var(--mide-space-3); padding: var(--mide-space-5); border: 1px solid var(--mide-line); border-radius: var(--mide-radius); background: var(--mide-surface); color: var(--mide-ink); min-width: 0; overflow-wrap: anywhere; }
  .crm-doc-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--mide-space-4); padding-bottom: var(--mide-space-3); border-bottom: 3px solid var(--tenant-brand-primary, var(--mide-line-strong)); }
  .crm-doc-logo { height: 2.5rem; width: auto; max-width: 12rem; object-fit: contain; }
  .crm-doc-name { font-size: var(--mide-text-lg); font-weight: var(--mide-weight-bold); color: var(--mide-ink); }
  .crm-doc-title { margin: 0; font-size: var(--mide-text-xl); font-weight: var(--mide-weight-bold); color: var(--mide-ink); }
  .crm-doc-meta { margin: 0; font-size: var(--mide-text-sm); color: var(--mide-muted); }
  .crm-doc-text { margin: 0; white-space: pre-line; overflow-wrap: anywhere; line-height: var(--mide-leading); font-size: var(--mide-text-md); }
  .crm-doc-foot { display: grid; gap: var(--mide-space-1); padding-top: var(--mide-space-3); border-top: 1px solid var(--mide-line); }
  .crm-doc-foot p { margin: 0; font-size: var(--mide-text-sm); color: var(--mide-muted); }

  /* «Imprimir o guardar PDF»: only the document is printed. */
  @media print {
    .crm-doc-printing body * { visibility: hidden; }
    .crm-doc-printing .crm-doc, .crm-doc-printing .crm-doc * { visibility: visible; }
    .crm-doc-printing .crm-doc { position: absolute; inset: 0 auto auto 0; width: 100%; border: 0; }
  }

  /* 390 px: each line stacks (service on its own row; quantity, price and «Quitar» below) and the breakdown drops its middle column. */
  @media (max-width: 640px) {
    .crm-quote-line { grid-template-columns: 5rem minmax(0, 1fr) auto; }
    .crm-quote-line > :first-child { grid-column: 1 / -1; }
    .crm-quote-table .is-how { display: none; }
    .crm-doc { padding: var(--mide-space-3); }
    .crm-quote-table .is-amount { white-space: normal; overflow-wrap: normal; }
    .crm-quote-table th, .crm-quote-table td { overflow-wrap: anywhere; }
  }

  /* 390 px (visual review): every field of a line on its own row, full width; touch targets of at least 44 px. */
  @media (max-width: 640px) {
    .crm-quote-line { grid-template-columns: minmax(0, 1fr); }
    .crm-quote-line > :first-child { grid-column: auto; }
    .crm-quote-line > .ui-button { margin-top: 0; justify-self: end; }
    .crm-quotes .ui-button, .crm-quote-line .ui-button { min-height: 44px; min-width: 44px; }
    /* Text-only actions show their 44 px target (outline from tokens), so the size reads on screen too. */
    .crm-quotes .ui-button-ghost:not(.ui-button-icon) { border-color: var(--mide-line); padding-inline: var(--mide-space-3); }
    .crm-quotes .ui-button-icon, .crm-quote-line .ui-button-icon { min-width: 44px; }
  }
}
