/* ============================================================================
   Varuna Portal Theme (standalone)
   Every rule is scoped under .portal-shell so nothing leaks into the public
   homepage (Classic or SiteBuilder mode) or other layouts. Plain CSS by
   design: this project has no CI sass step (main.css is a committed Web
   Compiler artifact), so hand-written CSS is the only pipeline-safe option.
   The per-tenant accent is injected by PortalLayout as --portal-accent.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------ */
.portal-shell {
  --portal-accent: #1a73e8;
  --portal-accent-strong: color-mix(in srgb, var(--portal-accent) 80%, #0b1e3a);
  --portal-accent-soft: color-mix(in srgb, var(--portal-accent) 10%, #fff);
  --portal-accent-softer: color-mix(in srgb, var(--portal-accent) 5%, #fff);
  --portal-accent-border: color-mix(in srgb, var(--portal-accent) 28%, #fff);
  --portal-bg: #f6f8fa;
  --portal-surface: #ffffff;
  --portal-surface-muted: #f1f4f8;
  --portal-border: #e4e9f0;
  --portal-text: #1f2937;
  --portal-text-muted: #64748b;
  --portal-radius: 12px;
  --portal-radius-sm: 8px;
  --portal-radius-pill: 999px;
  --portal-shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06);
  --portal-shadow-md: 0 4px 16px rgb(16 24 40 / 0.10);
  --portal-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--portal-bg);
  color: var(--portal-text);
  font-family: var(--portal-font);
}

/* ---- Shell: topbar / main / footer -------------------------------------- */
.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--portal-border);
}

.portal-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  text-decoration: none;
  color: var(--portal-text);
}

.portal-topbar__brand img {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}

.portal-topbar__title {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-topbar__tenant {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--portal-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.portal-topbar__actions a,
.portal-topbar__website {
  color: var(--portal-text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
}

.portal-topbar__actions a:hover,
.portal-topbar__website:hover {
  color: var(--portal-accent);
}

.portal-main {
  flex: 1;
  padding: 1.25rem 0 2.5rem;
}

.portal-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1rem;
}

.portal-footer {
  border-top: 1px solid var(--portal-border);
  background: var(--portal-surface);
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 1.25rem;
  font-size: 0.8rem;
  color: var(--portal-text-muted);
}

.portal-footer a {
  color: var(--portal-text-muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.portal-footer a:hover {
  color: var(--portal-accent);
}

/* ---- Layer A: generic component restyle inside the shell ---------------- */

/* Cards */
.portal-shell .card {
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  box-shadow: var(--portal-shadow-sm);
  background: var(--portal-surface);
}

.portal-shell .card .card-header {
  border-top-left-radius: calc(var(--portal-radius) - 1px);
  border-top-right-radius: calc(var(--portal-radius) - 1px);
  border-bottom: 1px solid var(--portal-border);
  background: var(--portal-surface);
  font-weight: 600;
}

/* Colored Blazorise headers (Background.Primary/… emit bg-* with !important):
   flatten them to a soft semantic tint with dark, readable titles. */
.portal-shell .card > .card-header.bg-primary {
  background: rgba(var(--bs-primary-rgb), 0.12) !important;
}
.portal-shell .card > .card-header.bg-success {
  background: rgba(var(--bs-success-rgb), 0.12) !important;
}
.portal-shell .card > .card-header.bg-info {
  background: rgba(var(--bs-info-rgb), 0.12) !important;
}
.portal-shell .card > .card-header.bg-warning {
  background: rgba(var(--bs-warning-rgb), 0.16) !important;
}
.portal-shell .card > .card-header.bg-danger {
  background: rgba(var(--bs-danger-rgb), 0.12) !important;
}
.portal-shell .card > .card-header.bg-secondary,
.portal-shell .card > .card-header.bg-dark,
.portal-shell .card > .card-header.bg-light {
  background: var(--portal-surface-muted) !important;
}

.portal-shell .card > .card-header[class*="bg-"] .card-title,
.portal-shell .card > .card-header[class*="bg-"] {
  color: var(--portal-text) !important;
}

.portal-shell .card > .card-header[class*="bg-"] .text-white {
  color: var(--portal-text) !important;
}

.portal-shell .card .card-footer {
  background: var(--portal-surface);
  border-top: 1px solid var(--portal-border);
  border-bottom-left-radius: calc(var(--portal-radius) - 1px);
  border-bottom-right-radius: calc(var(--portal-radius) - 1px);
}

/* Buttons */
.portal-shell .btn {
  border-radius: var(--portal-radius-sm);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 500;
}

.portal-shell .btn-sm {
  min-height: 36px;
}

.portal-shell .btn-primary {
  --bs-btn-bg: var(--portal-accent);
  --bs-btn-border-color: var(--portal-accent);
  --bs-btn-hover-bg: var(--portal-accent-strong);
  --bs-btn-hover-border-color: var(--portal-accent-strong);
  --bs-btn-active-bg: var(--portal-accent-strong);
  --bs-btn-active-border-color: var(--portal-accent-strong);
  --bs-btn-disabled-bg: var(--portal-accent);
  --bs-btn-disabled-border-color: var(--portal-accent);
}

.portal-shell .btn-outline-primary {
  --bs-btn-color: var(--portal-accent);
  --bs-btn-border-color: var(--portal-accent-border);
  --bs-btn-hover-bg: var(--portal-accent-soft);
  --bs-btn-hover-color: var(--portal-accent-strong);
  --bs-btn-hover-border-color: var(--portal-accent);
  --bs-btn-active-bg: var(--portal-accent-soft);
  --bs-btn-active-color: var(--portal-accent-strong);
  --bs-btn-active-border-color: var(--portal-accent);
}

/* Alerts: borderless, semantic left bar, soft tint */
.portal-shell .alert {
  border: 0;
  border-left: 4px solid transparent;
  border-radius: var(--portal-radius-sm);
}

.portal-shell .alert-primary {
  border-left-color: rgba(var(--bs-primary-rgb), 0.9);
  background: rgba(var(--bs-primary-rgb), 0.08);
}
.portal-shell .alert-info {
  border-left-color: rgba(var(--bs-info-rgb), 0.9);
  background: rgba(var(--bs-info-rgb), 0.08);
}
.portal-shell .alert-success {
  border-left-color: rgba(var(--bs-success-rgb), 0.9);
  background: rgba(var(--bs-success-rgb), 0.08);
}
.portal-shell .alert-warning {
  border-left-color: rgba(var(--bs-warning-rgb), 0.9);
  background: rgba(var(--bs-warning-rgb), 0.10);
}
.portal-shell .alert-danger {
  border-left-color: rgba(var(--bs-danger-rgb), 0.9);
  background: rgba(var(--bs-danger-rgb), 0.08);
}
.portal-shell .alert-secondary,
.portal-shell .alert-light {
  border-left-color: var(--portal-border);
  background: var(--portal-surface-muted);
}

/* Badges as pills */
.portal-shell .badge {
  border-radius: var(--portal-radius-pill);
  padding: 0.4em 0.85em;
  font-weight: 600;
}

/* Tables: hairlines, comfortable touch rows, sticky header, phone scroll */
.portal-shell .table {
  --bs-table-border-color: var(--portal-border);
}

.portal-shell .table > :not(caption) > * > * {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.portal-shell .table thead th {
  position: sticky;
  top: 0;
  background: var(--portal-surface-muted);
  color: var(--portal-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--portal-border);
  z-index: 1;
}

/* Form controls */
.portal-shell .form-control,
.portal-shell .form-select {
  border-radius: var(--portal-radius-sm);
  border-color: var(--portal-border);
  min-height: 44px;
}

.portal-shell textarea.form-control {
  min-height: unset;
}

.portal-shell .form-control:focus,
.portal-shell .form-select:focus {
  border-color: var(--portal-accent);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--portal-accent) 20%, transparent);
}

/* Tabs as pill segmented control */
.portal-shell .nav-tabs {
  border-bottom: 0;
  gap: 0.35rem;
  padding: 0.25rem;
  background: var(--portal-surface-muted);
  border-radius: var(--portal-radius-pill);
  width: fit-content;
  max-width: 100%;
}

.portal-shell .nav-tabs .nav-link {
  border: 0;
  border-radius: var(--portal-radius-pill);
  color: var(--portal-text-muted);
  font-weight: 500;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

.portal-shell .nav-tabs .nav-link.active {
  background: var(--portal-surface);
  color: var(--portal-accent-strong);
  box-shadow: var(--portal-shadow-sm);
}

/* ---- Layer B: explicit portal components --------------------------------- */

/* Hero / welcome panel (PortalEntry) */
.portal-shell .portal-hero {
  background: linear-gradient(135deg, var(--portal-accent-soft), var(--portal-accent-softer) 60%, var(--portal-surface));
  border: 1px solid var(--portal-accent-border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.portal-shell .portal-hero img {
  max-height: 64px;
  margin-bottom: 0.75rem;
}

.portal-shell .portal-hero h1,
.portal-shell .portal-hero h2,
.portal-shell .portal-hero .h2 {
  font-weight: 700;
  color: var(--portal-text);
}

.portal-shell .portal-hero p {
  color: var(--portal-text-muted);
  max-width: 46rem;
  margin: 0.25rem auto 0;
}

/* Feature tiles (FeatureGrid) */
.portal-shell .portal-tile {
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.portal-shell .portal-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--portal-shadow-md);
  border-color: var(--portal-accent-border);
}

.portal-shell .portal-tile .card-body {
  flex: 1;
  color: var(--portal-text-muted);
}

.portal-shell .portal-tile .card-footer a {
  color: var(--portal-accent);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
}

.portal-shell .portal-tile .card-footer a:hover {
  color: var(--portal-accent-strong);
}

/* Contact strip */
.portal-shell .portal-contact-card {
  box-shadow: none;
  background: var(--portal-surface-muted);
}

.portal-shell .portal-contact-card .card-body {
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
}

/* Document viewer */
.portal-shell .portal-doc-card > .card-header[class*="bg-"] {
  background: var(--portal-surface) !important;
}

.portal-shell .portal-doc-card .portal-doc-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--portal-radius-sm);
  background: var(--portal-accent-soft);
  color: var(--portal-accent-strong);
  margin-right: 0.5rem;
}

.portal-shell .portal-doc-card .tab-content {
  padding-top: 0.75rem;
}

.portal-shell .portal-doc-pdf-area {
  background: var(--portal-surface-muted);
  border-radius: var(--portal-radius-sm);
}

/* Status banner (offer/invoice summary) */
.portal-shell .portal-status-banner {
  border-left: 4px solid var(--portal-accent);
  border-radius: var(--portal-radius-sm);
}

.portal-shell .portal-status-banner--success { border-left-color: rgba(var(--bs-success-rgb), 0.9); }
.portal-shell .portal-status-banner--warning { border-left-color: rgba(var(--bs-warning-rgb), 0.9); }
.portal-shell .portal-status-banner--danger { border-left-color: rgba(var(--bs-danger-rgb), 0.9); }
.portal-shell .portal-status-banner--info { border-left-color: rgba(var(--bs-info-rgb), 0.9); }

/* Document list cards (invoices/offers/orders): status border instead of
   heavy colored header. The Blazorise Background still emits bg-*; the
   generic tint from Layer A applies; we add the status top border. */
.portal-shell .portal-list-card {
  border-top: 3px solid var(--portal-border);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.portal-shell .portal-list-card--success { border-top-color: rgba(var(--bs-success-rgb), 0.9); }
.portal-shell .portal-list-card--warning { border-top-color: rgba(var(--bs-warning-rgb), 0.9); }
.portal-shell .portal-list-card--danger { border-top-color: rgba(var(--bs-danger-rgb), 0.9); }
.portal-shell .portal-list-card--info { border-top-color: rgba(var(--bs-info-rgb), 0.9); }
.portal-shell .portal-list-card--primary { border-top-color: var(--portal-accent); }

.portal-shell .portal-list-card .card-body {
  flex: 1;
}

/* ZIP verification card (magic link) */
.portal-shell .portal-zip-card {
  max-width: 30rem;
  margin: 0 auto;
}

.portal-shell .portal-zip-card input[type="text"] {
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  text-align: center;
}

.portal-shell .portal-zip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--portal-accent-soft);
  color: var(--portal-accent-strong);
  font-size: 1.4rem;
}

/* Identity gate option cards */
.portal-shell .portal-option-card {
  height: 100%;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.portal-shell .portal-option-card:hover,
.portal-shell .portal-option-card--selected {
  border-color: var(--portal-accent) !important;
  background: var(--portal-accent-softer);
  box-shadow: var(--portal-shadow-md);
  transform: translateY(-2px);
}

/* Back link */
.portal-shell .portal-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  color: var(--portal-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.portal-shell .portal-back-link:hover {
  color: var(--portal-accent);
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 575.98px) {
  .portal-topbar {
    padding: 0 0.75rem;
  }

  .portal-topbar__brand img {
    height: 28px;
  }

  .portal-topbar__tenant {
    display: none;
  }

  .portal-topbar__website .portal-topbar__website-text {
    display: none;
  }

  .portal-main {
    padding-top: 0.75rem;
  }

  .portal-shell .portal-hero {
    padding: 1.25rem 1rem;
  }

  .portal-shell .portal-status-banner .row > [class*="col"] {
    text-align: start !important;
  }
}
