/* portal-core.css */
/* Global look & feel for portal pages (case list, detail, order, accounting, reports) */

/* ---------- Global box-sizing ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ---------- Base ---------- */

:root {
  --portal-bg: #fafafa;
  --portal-fg: #222222;
  --portal-muted: #666666;
  --portal-border: #e2e2e2;
  --portal-soft-border: #f0f0f0;
  --portal-card: #ffffff;
  --portal-soft-bg: #f6f6f8;
  --portal-accent: #bc4e4e;
  --portal-accent-dark: #a03f3f;

  /* Page width controls */
  --portal-page-max-width: 1200px;      /* detail pages */
  --portal-page-wide-max-width: 1680px; /* index/reports/accounting */
}

/* Default look when using this stylesheet */
body.portal-body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--portal-bg);
  color: var(--portal-fg);
  padding-top: 64px; /* space for the fixed tabs */
}

/* Wrapper for all modern portal pages */
.portal-page {
  width: min(96vw, var(--portal-page-max-width));
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* Wider variant for big tables (cases list, reports, accounting) */
.portal-page.portal-page-wide {
  width: min(96vw, var(--portal-page-wide-max-width));
}

/* ---------- Header / Breadcrumbs ---------- */

.portal-page-header {
  margin-bottom: 16px;
}

.portal-page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.portal-page-header p {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.95rem;
}

.portal-crumbs {
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.portal-crumbs a {
  color: #0b61a4;
  text-decoration: none;
}

.portal-crumbs a:hover {
  text-decoration: underline;
}

/* ---------- Shared Tabs (Reports / Cases / Accounting) ---------- */

/* ---------- Shared Tabs (Reports / Cases / Accounting) ---------- */

.tabs {
  position: fixed;
  top: 0;
  left: 0;
  right: 0; /* full-width bar */
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 24px 12px;
  background: #737373;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.tabs .tabset {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--portal-card);
  border: 1px solid var(--portal-border);
  padding: 6px;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.tabs a {
  text-decoration: none;
  color: inherit;
}

.tabs a.tab {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  background: transparent;
}

.tabs a.tab:hover {
  background: var(--portal-soft-bg);
}

.tabs a.tab[aria-current="page"] {
  background: var(--portal-soft-bg);
  border-color: #d0d0d0;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.04);
}

.tabs .right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Simple top header card (case / order) ---------- */

.portal-header-card {
  background: var(--portal-card);
  border-radius: 12px;
  border: 1px solid var(--portal-border);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.portal-header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.portal-header-label {
  font-size: 12px;
  color: var(--portal-muted);
}

.portal-header-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.portal-header-meta {
  font-size: 0.9rem;
  color: var(--portal-muted);
}

/* Grid for key/value info in header */
.portal-header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.portal-kv {
  min-width: 0;
}

.portal-kv .k {
  font-size: 0.85rem;
  color: var(--portal-muted);
}

.portal-kv .v {
  font-size: 0.95rem;
}

/* ---------- Cards / Sections ---------- */

.portal-card,
.portal-section {
  background: var(--portal-card);
  border-radius: 12px;
  border: 1px solid var(--portal-border);
  padding: 20px 20px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  margin-bottom: 14px;
}

.portal-subcard {
  border-radius: 10px;
  border: 1px solid #ececec;
  background: #fcfcfc;
  padding: 12px 12px 8px;
  margin-top: 6px;
}

/* Sections inside a card */
.portal-form-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.portal-form-section {
  border-top: 1px solid var(--portal-soft-border);
  padding-top: 14px;
}

.portal-form-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.portal-form-section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.portal-form-section h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--portal-accent);
}

/* ---------- Form fields ---------- */

.portal-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.portal-field-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.portal-page label,
.portal-field label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.portal-req {
  color: var(--portal-accent);
  margin-left: 2px;
}

.portal-page input[type="text"],
.portal-page input[type="date"],
.portal-page input[type="email"],
.portal-page input[type="number"],
.portal-page select,
.portal-page textarea {
  border-radius: 8px;
  border: 1px solid #d4d4d4;
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
  background-color: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.portal-page textarea {
  resize: vertical;
  min-height: 60px;
}

.portal-page input:focus,
.portal-page select:focus,
.portal-page textarea:focus {
  border-color: var(--portal-accent);
  box-shadow: 0 0 0 2px rgba(188, 78, 78, 0.15);
}

.portal-help {
  font-size: 0.8rem;
  color: #777777;
  margin-top: 2px;
}

/* Inline input + button (search, pickers) */
.portal-inline-picker {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  background: #ffffff;
  color: #333333;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background-color: #f4f4f4;
}

.btn.primary {
  background-color: var(--portal-accent);
  color: #ffffff;
  border-color: var(--portal-accent);
  box-shadow: 0 8px 16px rgba(188, 78, 78, 0.25);
}

.btn.primary:hover {
  background-color: var(--portal-accent-dark);
  border-color: var(--portal-accent-dark);
}

.btn.ghost {
  background: transparent;
  color: #555555;
  border-color: #d0d0d0;
}

.btn.ghost:hover {
  background-color: #f4f4f4;
}

.btn.small {
  padding: 4px 10px;
  font-size: 0.82rem;
}

/* ---------- Tables (lists, accounting, reports) ---------- */

.portal-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--portal-border);
  font-size: 0.9rem;
}

.portal-table thead th {
  background: var(--portal-soft-bg);
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--portal-border);
  font-weight: 600;
}

.portal-table tbody td {
  padding: 8px;
  border-top: 1px solid #f0f0f0;
  vertical-align: top;
}

/* Soft zebra option */
.portal-table.zebra tbody tr:nth-child(even) td {
  background: #fbfbfb;
}

/* ---------- Status & badges ---------- */

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  background: #eef2ff;
  color: #1f3a8a;
}

.portal-badge.rush {
  background: #fdecec;
  color: #7a1111;
}

.portal-muted {
  color: var(--portal-muted);
}

/* ---------- Shared tiny helpers ---------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.muted {
  color: var(--portal-muted);
  font-size: 0.85rem;
}

/* ---------- Orders list cards (on case detail) ---------- */

.portal-orders {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-order-card {
  background: var(--portal-card);
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.portal-order-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
  border-bottom: 1px solid var(--portal-border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.portal-order-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 6px 0;
}

/* ---------- Layout helpers ---------- */

.portal-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.portal-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Form actions & error ---------- */

.portal-form-actions {
  border-top: 1px solid var(--portal-soft-border);
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.portal-form-error {
  flex: 1 1 100%;
  background: #fff2f2;
  border: 1px solid #f0b3b3;
  color: #8a1f1f;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

/* Highlight the "New Case" button as a red pill */
#newCaseGlobal {
  background-color: #bc4e4e;
  color: #ffffff;
  border-color: #bc4e4e;
  font-weight: 600;
  padding: 8px 18px;
  font-size: 0.95rem;
  box-shadow: 0 6px 16px rgba(188, 78, 78, 0.35);
}

#newCaseGlobal:hover {
  background-color: #a03f3f;
  border-color: #a03f3f;
  box-shadow: 0 8px 20px rgba(160, 63, 63, 0.45);
}


/* ---------- Responsive tweaks ---------- */

@media (min-width: 1024px) {
  .portal-form-grid {
    padding: 4px 8px;
  }

  .portal-form-section {
    padding-top: 18px;
  }
}

#portal-tabs .right .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: var(--portal-accent, #BC4E4E);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

#portal-tabs .right .btn-primary:hover {
  filter: brightness(0.95);
  text-decoration: none;
}

/* ---------- Profile menu in top tabs ---------- */

.tabs .portal-profile {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tabs .portal-profile__button {
  display: inline-flex;
  align-items: center;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 4px 8px;
  color: #ffffff;
}

.tabs .portal-profile__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #5b5b5b;
  margin-right: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.tabs .portal-profile__name {
  font-size: 0.85rem;
}

.tabs .portal-profile__chevron {
  font-size: 0.7rem;
  margin-left: 4px;
}

.tabs .portal-profile__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  border: 1px solid var(--portal-border, #e2e2e2);
  padding: 4px 0;
  z-index: 200;
}

.tabs .portal-profile__summary {
  padding: 8px 12px;
  border-bottom: 1px solid var(--portal-soft-border, #f0f0f0);
}

.tabs .portal-profile__summary-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.tabs .portal-profile__summary-email {
  font-size: 0.8rem;
  color: var(--portal-muted, #666);
}

.tabs .portal-profile__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  color: #222;
}

.tabs .portal-profile__item:hover {
  background: #f5f5f5;
}
