/* SDH Admin — Demo 4 Shell
   Implements Metronic v9.4.10 Demo 4 layout for Sliding Door Heroes
   Layered on top of Metronic component CSS (kt-btn, kt-card, kt-badge, etc.)
*/

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  --sdh-primary:         #006FFF;
  --sdh-primary-active:  #056EE9;
  --sdh-primary-light:   #EFF6FF;
  --sdh-navy:            #003B6F;
  --sdh-page-bg:         #F6F6F9;
  --sdh-card-bg:         #FFFFFF;
  --sdh-divider:         #F1F1F4;
  --sdh-border:          #DBDFE9;
  --sdh-dark-bg:         #16151E;
  --sdh-text:            #1B1C22;
  --sdh-text-secondary:  #4B5675;
  --sdh-text-tertiary:   #78829D;
  --sdh-text-placeholder:#99A1B7;
  --sdh-success:         #17C653;
  --sdh-success-light:   #DFFFEA;
  --sdh-success-active:  #04B440;
  --sdh-warning:         #F6C000;
  --sdh-warning-light:   #FFF8DD;
  --sdh-danger:          #F8285A;
  --sdh-danger-light:    #FFEEF3;
  --sdh-danger-active:   #D9214E;
  --sdh-radius-lg:       12px;
  --sdh-focus-ring:      0 0 0 3px rgba(0,111,255,0.18);
  --sdh-shadow-sm:       0 3px 4px 0 rgba(0,0,0,0.03);
  --sdh-shadow-md:       0 6px 12px 0 rgba(0,0,0,0.06);

  /* Override Metronic primary to SDH blue */
  --primary: #006FFF;
  --primary-light: #EFF6FF;
}

/* ── Base reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--sdh-page-bg);
  color: var(--sdh-text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── 3-column shell ─────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 70px 220px 1fr;
  min-height: 100vh;
}
.shell.no-sub { grid-template-columns: 70px 1fr; }

/* ── Icon rail ──────────────────────────────────────────────── */
.rail {
  background: #fff;
  border-right: 1px solid var(--sdh-divider);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; gap: 6px;
  position: sticky; top: 0; height: 100vh;
  z-index: 20;
}
.rail .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--sdh-dark-bg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; color: #fff;
  font-weight: 700; font-size: 13px; letter-spacing: 0;
  flex-shrink: 0;
}
.rail .ic {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #99A1B7; transition: background-color .12s, color .12s;
  border: none; background: transparent; cursor: pointer;
}
.rail .ic:hover { background: var(--sdh-page-bg); color: var(--sdh-text); }
.rail .ic.active { background: var(--sdh-primary-light); color: var(--sdh-primary); }
.rail .ic i { font-size: 20px; }
.rail .spacer { flex: 1; }
.rail .ic.ic-danger:hover { background: var(--sdh-danger-light); color: var(--sdh-danger-active); }

/* ── Secondary nav ──────────────────────────────────────────── */
.subnav {
  background: #fff;
  border-right: 1px solid var(--sdh-divider);
  padding: 20px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.subnav .brand {
  font-weight: 700; font-size: 14px; color: var(--sdh-text);
  padding: 0 12px; margin-bottom: 20px;
}
.subnav .sec {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: #99A1B7;
  padding: 12px 12px 4px;
}
.subnav .lk {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--sdh-text-secondary);
  cursor: pointer; transition: background-color .12s, color .12s;
}
.subnav .lk i { font-size: 16px; flex-shrink: 0; }
.subnav .lk:hover { background: var(--sdh-page-bg); color: var(--sdh-text); }
.subnav .lk.active { background: var(--sdh-primary-light); color: var(--sdh-primary); }
.subnav .lk.lk-danger:hover { background: var(--sdh-danger-light); color: var(--sdh-danger-active); }
.subnav-spacer { flex: 1; }

/* ── Content column ─────────────────────────────────────────── */
.sdh-content { display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar ─────────────────────────────────────────────────── */
.sdh-topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--sdh-divider);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; height: 70px;
}
.sdh-topbar .crumbs {
  display: flex; gap: 6px; font-size: 13px;
  color: var(--sdh-text-secondary); align-items: center;
}
.sdh-topbar .crumbs .sep { color: #C4CADA; }
.sdh-topbar .crumbs .here { color: var(--sdh-text); font-weight: 500; }
.sdh-topbar .tb-grow { flex: 1; }

/* ── Page area ──────────────────────────────────────────────── */
.sdh-page { padding: 28px 28px 48px; display: flex; flex-direction: column; gap: 24px; }

/* ── Page header (title + actions) ─────────────────────────── */
.sdh-page-header {
  display: flex; flex-wrap: wrap;
  align-items: flex-start; justify-content: space-between; gap: 16px;
}
.sdh-page-header h1 {
  margin: 0; font-size: 20px; font-weight: 700; color: var(--sdh-text);
}
.sdh-page-header p {
  margin: 4px 0 0; font-size: 13px; color: var(--sdh-text-secondary);
}
.sdh-page-header .actions { display: flex; gap: 8px; align-items: center; }

/* ── Stat cards ─────────────────────────────────────────────── */
.sdh-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .sdh-stats { grid-template-columns: repeat(2, 1fr); } }

.sdh-stat {
  background: #fff;
  border: 1px solid var(--sdh-divider);
  border-radius: var(--sdh-radius-lg);
  padding: 20px;
}
.sdh-stat .stat-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.sdh-stat .stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.sdh-stat .stat-val { font-size: 32px; font-weight: 700; color: var(--sdh-text); line-height: 1; }
.sdh-stat .stat-label { font-size: 13px; color: var(--sdh-text-secondary); margin-top: 6px; }

/* ── SDH card ───────────────────────────────────────────────── */
.sdh-card {
  background: #fff;
  border: 1px solid var(--sdh-divider);
  border-radius: var(--sdh-radius-lg);
}
.sdh-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--sdh-divider);
}
.sdh-card-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--sdh-text); }
.sdh-card-body { padding: 0; }

/* ── Table ──────────────────────────────────────────────────── */
.sdh-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sdh-table thead th {
  text-align: left; font-weight: 600;
  color: var(--sdh-text-tertiary); font-size: 11px;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 12px 24px; border-bottom: 1px solid var(--sdh-divider);
  background: #fff;
}
.sdh-table tbody td { padding: 14px 24px; border-bottom: 1px solid var(--sdh-divider); }
.sdh-table tbody tr:last-child td { border: 0; }
.sdh-table tbody tr:hover td { background: #FAFAFA; }
.sdh-table tbody tr { cursor: pointer; transition: background .1s; }

/* ── Buttons ────────────────────────────────────────────────── */
.sdh-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 9px 16px; border-radius: 6px; border: 1px solid transparent;
  line-height: 1; cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.sdh-btn i { font-size: 14px; }
.sdh-btn-primary { background: var(--sdh-primary); color: #fff; }
.sdh-btn-primary:hover { background: var(--sdh-primary-active); }
.sdh-btn-outline { background: #fff; color: var(--sdh-text); border-color: var(--sdh-border); }
.sdh-btn-outline:hover { background: var(--sdh-page-bg); }
.sdh-btn-danger { background: var(--sdh-danger); color: #fff; }
.sdh-btn-danger:hover { background: var(--sdh-danger-active); }
.sdh-btn-sm { padding: 6px 12px; font-size: 12px; }
.sdh-btn-sm i { font-size: 13px; }

/* ── Badges ─────────────────────────────────────────────────── */
.sdh-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
}
.sdh-badge-success  { background: var(--sdh-success-light);  color: var(--sdh-success-active); }
.sdh-badge-warning  { background: var(--sdh-warning-light);  color: #876D00; }
.sdh-badge-danger   { background: var(--sdh-danger-light);   color: var(--sdh-danger-active); }
.sdh-badge-primary  { background: var(--sdh-primary-light);  color: var(--sdh-primary); }
.sdh-badge-neutral  { background: var(--sdh-divider);        color: var(--sdh-text-secondary); }

/* ── Modal ──────────────────────────────────────────────────── */
.sdh-modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 50;
  align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sdh-modal-bg.open { display: flex; }
.sdh-modal {
  background: #fff;
  border-radius: var(--sdh-radius-lg);
  border: 1px solid var(--sdh-divider);
  width: 100%; max-width: 672px; margin: 16px;
  box-shadow: var(--sdh-shadow-md);
}
.sdh-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--sdh-divider);
}
.sdh-modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.sdh-modal-close {
  width: 32px; height: 32px; border-radius: 6px; border: 0; background: transparent;
  color: var(--sdh-text-secondary); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px;
  transition: background .12s, color .12s;
}
.sdh-modal-close:hover { background: var(--sdh-page-bg); color: var(--sdh-text); }
.sdh-modal-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.sdh-modal-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 24px; border-top: 1px solid var(--sdh-divider);
}

/* ── Form ───────────────────────────────────────────────────── */
.sdh-select {
  padding: 9px 12px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--sdh-border); border-radius: 6px;
  background: #fff; color: var(--sdh-text); outline: none;
  transition: border-color .12s, box-shadow .12s; cursor: pointer;
}
.sdh-select:focus { border-color: var(--sdh-primary); box-shadow: var(--sdh-focus-ring); }

/* ── Toast ──────────────────────────────────────────────────── */
.sdh-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--sdh-shadow-md); animation: toastin .18s ease;
}
.sdh-toast-success { background: var(--sdh-success); color: #fff; }
.sdh-toast-danger  { background: var(--sdh-danger);  color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Detail grid (modal body) ───────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; font-size: 13px; }
.detail-grid .full { grid-column: 1 / -1; }
.detail-grid .dl { display: flex; flex-direction: column; gap: 2px; }
.detail-grid .dl dt { font-size: 11px; font-weight: 600; color: var(--sdh-text-tertiary); text-transform: uppercase; letter-spacing: .04em; }
.detail-grid .dl dd { margin: 0; font-weight: 500; color: var(--sdh-text); }

/* ── Login page ─────────────────────────────────────────────── */
.sdh-login-bg {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--sdh-page-bg);
}
.sdh-login-card {
  background: #fff; border: 1px solid var(--sdh-divider);
  border-radius: var(--sdh-radius-lg);
  padding: 40px 40px; width: 100%; max-width: 400px; margin: 16px;
  box-shadow: var(--sdh-shadow-md);
}
.sdh-input {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--sdh-border); border-radius: 6px;
  background: #fff; color: var(--sdh-text); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.sdh-input:focus { border-color: var(--sdh-primary); box-shadow: var(--sdh-focus-ring); }
.sdh-label { display: block; font-size: 12px; font-weight: 600; color: var(--sdh-text-secondary); margin-bottom: 6px; }

/* ── Mobile nav button ──────────────────────────────────────── */
.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px; border-radius: 6px;
  border: none; background: transparent; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 0; flex-shrink: 0;
}
.mobile-menu-btn .mob-bar {
  display: block; width: 20px; height: 2px;
  background: var(--sdh-text); border-radius: 2px;
  transition: background .12s;
}
.mobile-menu-btn:hover .mob-bar { background: var(--sdh-primary); }

/* ── Sidebar overlay ────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 190;
}
.sidebar-overlay.visible { display: block; }

/* ── Table scroll wrapper ───────────────────────────────────── */
.job-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Mobile breakpoint ──────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }

  .shell, .shell.no-sub { grid-template-columns: 1fr; }

  .rail { display: none; }

  .subnav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px; height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .subnav.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }

  .sdh-content { grid-column: 1; }
  .sdh-topbar { padding: 0 16px; }
  .sdh-page { padding: 16px 16px 40px; }

  .sdh-modal { margin: 8px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .full { grid-column: 1; }

  .job-row { min-width: 440px; }
}

@media (max-width: 480px) {
  .sdh-stats { grid-template-columns: 1fr; }
}

/* ── Call-script floating panel (manager only) ───────────────── */
.csp-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 380px;
  z-index: 9999;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  font-family: Inter, system-ui, sans-serif;
  transition: width .2s ease;
}
.csp-header {
  background: #006fff;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
  gap: 8px;
}
.csp-panel.csp-collapsed .csp-header { border-radius: 8px; }
.csp-panel.csp-collapsed { width: 280px; }
.csp-title { font-size: 13px; font-weight: 600; flex: 1; }
.csp-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.csp-controls button {
  background: none; border: none; color: #fff;
  cursor: pointer; padding: 3px 6px; font-size: 13px; line-height: 1;
  opacity: .8; border-radius: 4px; transition: opacity .15s, background .15s;
}
.csp-controls button:hover { opacity: 1; background: rgba(255,255,255,.15); }
.csp-chevron {
  display: inline-block;
  transition: transform .2s ease;
  font-style: normal;
  font-size: 11px;
}
.csp-panel.csp-collapsed .csp-chevron { transform: rotate(-90deg); }
.csp-body {
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  max-height: 75vh;
  overflow-y: auto;
  display: block;
}
.csp-panel.csp-collapsed .csp-body { display: none; }
.csp-body ol, .csp-body ul {
  padding-left: 20px;
  margin: 6px 0;
}
.csp-body li { margin-bottom: 6px; }
.csp-body p { margin: 6px 0; }
.csp-body strong { font-weight: 600; }
.csp-warn {
  display: block;
  background: #fffbe6;
  border-left: 3px solid #f5a623;
  border-radius: 3px;
  padding: 6px 10px;
  margin: 6px 0;
  font-size: 13px;
}
.csp-reopen {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #006fff;
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  transition: transform .15s ease, box-shadow .15s ease;
}
.csp-reopen:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
@media (max-width: 768px) {
  .csp-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0 !important;
    width: 100% !important;
    border-radius: 12px 12px 0 0;
    max-height: 80vh;
  }
  .csp-header { border-radius: 12px 12px 0 0; cursor: pointer; }
  .csp-panel.csp-collapsed .csp-header { border-radius: 12px 12px 0 0; }
  .csp-body { max-height: 60vh; }
  .csp-reopen { bottom: 80px; }
}
