/* ----------------------------------------------------------------
   Client Portal — layered on top of amnk-theme.css.
   Inherits the same navy/blue/gold brand as the rest of the app
   (matches app/lib/core/app_colors.dart) rather than defining its
   own accent, so the client-facing surface stays visually
   consistent with every other Amnk surface. Only the hero banner
   gets a distinct treatment (deeper navy gradient + gold glow) to
   read as a "welcome" moment, reusing every other token (surfaces,
   shadows, radii, dark mode) unchanged.
   ---------------------------------------------------------------- */

/* Hero header on the client dashboard */
.client-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  padding: 28px 30px;
  margin-bottom: 26px;
  background: linear-gradient(135deg, #1A3A72 0%, #0D1B3E 55%, #00030A 100%);
  box-shadow: var(--shadow-lg);
}
.client-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px circle at 85% -10%, rgba(29,95,170,0.28), transparent 60%),
              radial-gradient(400px circle at 100% 100%, rgba(255,203,49,0.14), transparent 55%);
  pointer-events: none;
}
.client-hero-eyebrow {
  color: #FFCB31;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 6px;
}
.client-hero-title {
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  position: relative;
}
.client-hero-subtitle {
  color: rgba(255,255,255,0.68);
  font-size: 13.5px;
  margin: 0;
  position: relative;
}

/* Read-only data cards used across invoices/reports/safety/visit-request pages */
.client-data-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.client-data-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.client-data-card .card-body { padding: 18px 20px; }
.client-empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
}
.client-empty-state i { font-size: 34px; color: var(--text-4); display: block; margin-bottom: 10px; }

.badge-client-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 700;
}
.badge-client-status.is-active   { background: var(--clr-success-light); color: var(--clr-success); }
.badge-client-status.is-inactive { background: var(--clr-danger-light);  color: var(--clr-danger); }

/* ----------------------------------------------------------------
   Portal pages added with per-client permissions (2026-09).
   All tokens come from amnk-theme.css so dark mode keeps working.
   ---------------------------------------------------------------- */
.client-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.client-page-head h1 { font-size: 20px; font-weight: 800; color: var(--text-1); letter-spacing: -0.02em; margin: 0 0 4px; }
.client-page-head p { color: var(--text-3); font-size: 13px; margin: 0; }
.client-page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.client-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.client-card + .client-card { margin-top: 16px; }
.client-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.client-card-head h2 { font-size: 15px; font-weight: 800; color: var(--text-1); margin: 0; }
.client-card-body { padding: 18px; }

.client-filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; padding: 14px; margin-bottom: 18px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.client-filter-bar label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-3); margin-bottom: 4px; }
.client-filter-bar .form-control, .client-filter-bar .custom-select { min-height: 40px; }
.client-filter-actions { display: flex; gap: 8px; }

.client-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.client-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.client-table th { position: sticky; top: 0; background: var(--bg-surface-2); color: var(--text-3); font-size: 11.5px; font-weight: 800; text-align: start; padding: 10px 14px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.client-table td { padding: 12px 14px; color: var(--text-2); border-bottom: 1px solid var(--border); vertical-align: middle; }
.client-table tr:last-child td { border-bottom: 0; }
.client-table tbody tr:hover td { background: var(--bg-hover); }
.client-table .cell-strong { color: var(--text-1); font-weight: 700; }

.client-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-full); font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--bg-surface-2); color: var(--text-2); }
.client-pill.tone-warning { background: var(--clr-warning-light); color: var(--clr-warning); }
.client-pill.tone-success { background: var(--clr-success-light); color: var(--clr-success); }
.client-pill.tone-danger  { background: var(--clr-danger-light);  color: var(--clr-danger); }
.client-pill.tone-info    { background: var(--clr-info-light);    color: var(--clr-info); }
.client-pill.tone-violet  { background: var(--clr-violet-light);  color: var(--clr-violet); }

.client-quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 24px; }
.client-quick-action { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-1) !important; font-weight: 700; font-size: 13.5px; transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition); }
.client-quick-action:hover { border-color: var(--clr-primary); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.client-quick-action i { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--clr-primary-ultra, rgba(29,95,170,.1)); color: var(--clr-primary); font-size: 19px; flex-shrink: 0; }

.client-section-title { font-size: 14px; font-weight: 800; color: var(--text-1); margin: 4px 0 12px; }

.client-form .form-group label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.client-form .form-control, .client-form .custom-select { min-height: 44px; }
.client-form textarea.form-control { min-height: 110px; }
.client-form .hint { font-size: 12px; color: var(--text-3); }

.client-thread { display: flex; flex-direction: column; gap: 14px; }
.client-msg { max-width: 82%; padding: 12px 14px; border-radius: 16px; background: var(--bg-surface-2); border: 1px solid var(--border); }
.client-msg.is-mine { align-self: flex-end; background: var(--clr-primary-ultra, rgba(29,95,170,.08)); border-color: rgba(29,95,170,.22); }
.client-msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }
.client-msg-meta strong { color: var(--text-1); font-size: 12.5px; }
.client-msg-body { color: var(--text-1); font-size: 13.5px; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.client-msg-attachment { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; font-weight: 700; }

.client-map { height: min(68vh, 560px); border-radius: var(--r-lg); border: 1px solid var(--border); overflow: hidden; z-index: 0; }
.client-map-list { max-height: min(68vh, 560px); overflow-y: auto; }
.client-map-person { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.client-map-person:hover { background: var(--bg-hover); }
.client-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--clr-success); display: inline-block; }
.client-dot.is-stale { background: var(--text-4); }

.client-attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.client-attachments a { display: block; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); background: var(--bg-surface-2); }
.client-attachments img, .client-attachments video { width: 100%; height: 140px; object-fit: cover; display: block; }

.client-forbidden { max-width: 520px; margin: 40px auto; text-align: center; }
.client-forbidden i { font-size: 46px; color: var(--clr-warning); }

.client-perm-list { display: grid; gap: 6px; }
.client-perm-list .perm-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.client-perm-list .perm-item i { color: var(--clr-success); }

@media (max-width: 575.98px) {
  .client-page-head h1 { font-size: 18px; }
  .client-msg { max-width: 100%; }
  .client-filter-bar { grid-template-columns: 1fr 1fr; }
  .client-filter-actions { grid-column: 1 / -1; }
  .client-filter-actions .btn { flex: 1; }
}

/* #wrapper and .content-page are flex containers in the shared layout; their
   default min-width:auto let a wide table stretch the whole page on phones. */
[data-portal="client"] .content-page,
[data-portal="client"] .content { min-width: 0; }

/* ---------- Add / edit actions (client portal permissions *.create / *.edit) ---------- */
.client-row-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.client-row-actions form { margin: 0; }

.client-inline-form > summary { list-style: none; cursor: pointer; }
.client-inline-form > summary::-webkit-details-marker { display: none; }
.client-inline-form[open] > summary { margin-bottom: 8px; }
.client-inline-form form { min-width: 220px; text-align: start; }

.client-criteria { display: flex; flex-direction: column; gap: 8px; }
.client-criteria-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 38px; gap: 8px; align-items: center; }
@media (max-width: 575.98px) {
  .client-criteria-row { grid-template-columns: minmax(0, 1fr) 96px 38px; }
}

.client-attachment-remove { display: block; margin: 0; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); background: var(--bg-surface-2); cursor: pointer; }
.client-attachment-remove img { width: 100%; height: 140px; object-fit: cover; display: block; }
.client-attachment-remove > span:last-child { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--clr-danger); }

.client-alarm-card { border-color: rgba(239, 68, 68, 0.35) !important; }
.client-alarm-card .client-card-head h2 i { color: var(--clr-danger); }
