/* ================= APOLLO PLATFORM SHELL =================
   Header/navigation shell plus light polish for report and admin views.
   Scoped to .apollo-shell-header / .apollo-nav and existing view IDs so
   embedded widgets (scorecard, vital signs, access report) are unaffected. */

:root{
  --covar-green:#1f3d2f;
  --covar-green-deep:#173024;
  --covar-green-soft:#e8f0eb;
  --apollo-focus:#f4c351;
}

/* Hidden must always win over component display rules (fail closed). */
.apollo-shell-header [hidden],
#reportsView[hidden],
#reportUsersView[hidden],
#performanceView[hidden],
#loadsBookedView[hidden],
#repScorecardView[hidden],
#vitalSignsView[hidden],
#employeeAccessReportView[hidden],
#settingsView[hidden],
#callUsersView[hidden],
#adminHealthView[hidden]{
  display:none !important;
}

/* ---------- Header ---------- */
.apollo-workspace{max-width:1440px;margin:16px auto 0;padding:12px 20px;border:1px solid #cedfd5;border-radius:12px;background:#f2f8f4;color:#254b3b;display:flex;flex-wrap:wrap;gap:5px 16px;font:13px/1.5 system-ui,sans-serif}
.apollo-workspace strong{color:#163e2d;font-size:14px;font-weight:750}
.apollo-workspace>span{color:#425d4f}
.apollo-workspace small{flex-basis:100%;color:#53675c;font-size:12px}.apollo-workspace[hidden]{display:none!important}

header.apollo-shell-header{
  position:sticky;
  top:0;
  z-index:50;
  height:auto;
  min-height:60px;
  padding:8px 20px;
  gap:16px;
  background:linear-gradient(180deg,var(--covar-green) 0%,var(--covar-green-deep) 100%);
  color:#fff;
  box-shadow:0 1px 0 rgba(255,255,255,.06), 0 4px 14px rgba(15,23,42,.12);
}

.apollo-shell-header .header-left{
  flex:0 0 auto;
  gap:12px;
}

.apollo-shell-header .header-center{
  font-size:15px;
  font-weight:700;
  letter-spacing:.2px;
  color:#fff;
  opacity:1;
}

.apollo-shell-header .header-right{
  flex:0 0 auto;
  gap:10px;
  font-size:13px;
}

.apollo-shell-header #userInfo{
  color:rgba(255,255,255,.85);
  max-width:240px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.apollo-role-badge{
  display:inline-flex;
  align-items:center;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.28);
  background:rgba(255,255,255,.1);
  color:#fff;
  font-size:11px;
  font-weight:800;
  letter-spacing:.06em;
  text-transform:uppercase;
  white-space:nowrap;
}

.apollo-shell-header #loginBtn,
.apollo-shell-header #logoutBtn{
  background:transparent;
  border:1px solid rgba(255,255,255,.3);
  padding:6px 12px;
  font-size:13px;
}

.apollo-shell-header #loginBtn:hover,
.apollo-shell-header #logoutBtn:hover{
  background:rgba(255,255,255,.1);
  opacity:1;
}

/* ---------- Grouped navigation ---------- */
.apollo-nav.view-toggle{
  flex:1 1 auto;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:center;
  gap:6px 10px;
  padding:0;
  background:transparent;
  border-radius:0;
  min-width:0;
}

.apollo-nav-group{
  display:inline-flex;
  align-items:center;
  gap:2px;
  padding:3px;
  border-radius:10px;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.08);
}

.apollo-nav-label{
  padding:0 8px 0 6px;
  color:rgba(255,255,255,.78);
  font-size:10px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
  white-space:nowrap;
}

.apollo-nav-admin{
  background:rgba(244,195,81,.1);
  border-color:rgba(244,195,81,.22);
}

.apollo-nav.view-toggle button{
  padding:6px 10px;
  font-size:13px;
  font-weight:700;
  border-radius:7px;
  white-space:nowrap;
  color:#f7faf8;
  transition:background-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.apollo-nav.view-toggle button:hover{
  background:rgba(255,255,255,.14);
  opacity:1;
}

.apollo-nav.view-toggle button.active{
  background:#fff;
  color:var(--covar-green);
  box-shadow:0 2px 5px #071b1426;
}

@media(hover:hover){
  .apollo-nav.view-toggle button:not(:disabled):hover{transform:translateY(-1px)}
}
.apollo-nav.view-toggle button:not(:disabled):active{transform:translateY(0);box-shadow:none}

/* ---------- Accessible focus ---------- */
.apollo-shell-header button:focus-visible,
.apollo-shell-header a:focus-visible{
  outline:2px solid var(--apollo-focus);
  outline-offset:2px;
}

#reportsView :is(button, a, select, input):focus-visible,
#performanceView :is(button, a, select, input):focus-visible,
#loadsBookedView :is(button, a, select, input):focus-visible,
#settingsView :is(button, a, select, input):focus-visible,
#callUsersView :is(button, a, select, input):focus-visible,
#adminHealthView :is(button, a, select, input):focus-visible,
#controls :is(button, select, input):focus-visible,
#savedViewBar button:focus-visible{
  outline:2px solid var(--apollo-primary);
  outline-offset:2px;
}

/* ---------- Report / admin view polish ---------- */
:is(#reportsView, #performanceView, #loadsBookedView, #settingsView, #callUsersView, #adminHealthView) .reports-header{
  flex-wrap:wrap;
  padding-bottom:14px;
  border-bottom:1px solid var(--apollo-border);
}

:is(#reportsView, #performanceView, #loadsBookedView, #settingsView, #callUsersView, #adminHealthView) .reports-title{
  font-size:22px;
  letter-spacing:-.01em;
}

:is(#reportsView, #performanceView, #loadsBookedView, #settingsView, #callUsersView, #adminHealthView) .reports-controls{
  flex-wrap:wrap;
}

:is(#settingsView, #callUsersView, #adminHealthView) .reports-title::before{
  content:none;
  display:inline-block;
  margin-right:10px;
  padding:2px 8px;
  vertical-align:middle;
  border-radius:999px;
  background:#fef3c7;
  color:#92400e;
  font-size:11px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}

:is(#reportsView, #performanceView, #loadsBookedView, #settingsView, #callUsersView) .reports-table tbody tr:hover td{
  background:#f8fafc;
}

:is(#settingsView, #callUsersView) .reports-table td{
  vertical-align:top;
}

:is(#settingsView, #callUsersView) .reports-table input:not([type="checkbox"]),
:is(#settingsView, #callUsersView) .reports-table select{
  width:100%;
  min-width:120px;
}

:is(#settingsView, #callUsersView) .settings-add-user{
  padding:12px;
  border:1px solid var(--apollo-border);
  border-radius:12px;
  background:#fff;
}

#controls{
  flex-wrap:wrap;
}

/* Wide tables scroll inside their card instead of breaking layout. */
@media (max-width: 1100px){
  :is(#reportsView, #performanceView, #loadsBookedView, #settingsView, #callUsersView) .reports-table{
    display:block;
    overflow-x:auto;
  }

  .reports-kpis{
    grid-template-columns:repeat(2, minmax(140px, 1fr));
  }

  .admin-health-grid{
    grid-template-columns:repeat(2, minmax(200px, 1fr));
  }

  .settings-add-user{
    grid-template-columns:1fr 1fr;
  }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 900px){
  body{
    height:auto;
    min-height:100vh;
  }

  header.apollo-shell-header{
    position:static;
    flex-wrap:wrap;
    justify-content:space-between;
    padding:8px 12px;
  }

  .apollo-shell-header .header-center{
    display:none;
  }

  .apollo-nav.view-toggle{
    order:3;
    flex-basis:100%;
    justify-content:flex-start;
    flex-wrap:nowrap;
    overflow-x:auto;
    padding-bottom:2px;
    scrollbar-width:thin;
  }

  .apollo-nav-group{
    flex:0 0 auto;
  }

  #reportsView,
  #performanceView,
  #loadsBookedView,
  #settingsView,
  #callUsersView,
  #adminHealthView{
    height:auto;
    padding:16px 12px 28px;
  }

  #layout{
    grid-template-columns:1fr;
    height:auto;
  }

  #tickets{
    max-height:55vh;
    border-right:0;
    border-bottom:1px solid var(--apollo-border);
  }

  #controls{
    padding:10px 12px;
  }

  #controls #search{
    width:100% !important;
  }

  .settings-toolbar input{
    min-width:0;
    flex:1 1 auto;
  }
}

@media (max-width: 600px){
  .apollo-shell-header #userInfo{
    display:none;
  }

  .reports-kpis,
  .admin-health-grid,
  .settings-add-user{
    grid-template-columns:1fr;
  }

  .settings-toolbar{
    flex-wrap:wrap;
  }
}

@media (prefers-reduced-motion: reduce){
  .apollo-nav.view-toggle button{
    transition:none;
    transform:none!important;
  }
}

@media print{
  header.apollo-shell-header{
    display:none !important;
  }
}

/* Keep troubleshooting IDs available on hover without crowding editable names. */
#settingsUsersRows td:first-child code{display:block;max-width:84px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--apollo-muted)}
#settingsUsersRows input[data-field="display_name"]{min-width:180px}
#settingsUsersRows input[data-field="email"]{min-width:225px}

#reportLoadsBookedHeader[hidden]{display:none!important}
.report-resources{margin:0 0 20px;padding:14px 18px;border:1px solid #d8e4dd;border-radius:12px;background:#f7faf8}
.report-resources summary{cursor:pointer;font-weight:700;color:#214b39}
.report-resources p{color:#607268;font-size:13px}
.report-resource-link{display:flex;align-items:center;gap:14px;max-width:580px;background:white;border:1px solid #d8e4dd;border-radius:10px;padding:14px;color:#173f2c;text-decoration:none}
.report-resource-link:hover{border-color:#2f8358;background:#f3faf6}
.report-resource-link strong,.report-resource-link small{display:block}
.report-resource-link small{color:#61746a;margin-top:4px;line-height:1.5}
.report-resource-link>span:last-child{margin-left:auto}.report-resource-icon{font-size:26px;color:#b59222}

.call-setup-help{padding:18px 20px;background:#eef6f1;border:1px solid #d4e5db;border-radius:14px;margin:20px 0;color:#244b3c}
.call-setup-help p{margin:6px 0 0;max-width:95ch;font-size:14px}
.call-onboarding-form{display:grid;grid-template-columns:1fr 1fr;gap:16px;background:white;border:1px solid var(--apollo-border);padding:20px;border-radius:14px;margin-bottom:22px}
.call-onboarding-form label{display:flex;flex-direction:column;gap:7px;font-size:14px;font-weight:700}
.call-onboarding-form input,.call-onboarding-form select,.call-onboarding-form textarea{width:100%;box-sizing:border-box;border:1px solid var(--apollo-border);border-radius:8px;padding:10px;font:inherit;font-weight:400;background:white;color:var(--apollo-ink)}
.call-onboarding-form small,.call-onboarding-submit span{font-size:12px;color:var(--apollo-muted);font-weight:400}
.call-onboarding-submit{grid-column:1/-1;display:flex;align-items:center;gap:14px}
.call-onboarding-submit button{background:#176744;color:white;border:0;border-radius:8px;padding:11px 18px;font-weight:700}
.call-setup-note{display:block;font-size:12px;line-height:1.5;margin-top:7px;color:var(--apollo-muted)}
.call-setup-state{display:inline-block;border-radius:20px;background:#fff4d7;color:#71510e;font-size:11px;font-weight:700;padding:3px 9px;margin:5px 0}
.call-setup-state.linked{background:#e5f4eb;color:#176744}
#callUsersRows td{vertical-align:top}
#callUsersRows td:first-child input{min-width:175px}
#callUsersRows .call-profile-select{min-width:200px;max-width:245px}
#callUsersRows button:disabled,.call-onboarding-form button:disabled{opacity:.6;cursor:wait}
@media(max-width:650px){.call-onboarding-form{grid-template-columns:1fr}.call-onboarding-submit{align-items:flex-start;flex-direction:column}}
.apollo-shell-header .header-center{display:flex;flex-direction:column;align-items:flex-start;gap:3px;white-space:nowrap}
.apollo-shell-header .header-center strong{font-size:21px;line-height:1.15;letter-spacing:.02em}
.apollo-shell-header .covar-product-subtitle{font-size:10px;font-weight:500;letter-spacing:.04em;line-height:1.3;opacity:.85}
