/* HLG Memorial Hospital – Maintenance Portal */
:root {
  --primary:       #651C32;
  --primary-dark:  #4a1323;
  --primary-light: #7d2340;
  --green:         #43B02A;
  --red:           #CE2939;
  --bg:            #f5f0f1;
  --card-shadow:   0 2px 10px rgba(101,28,50,.10);
}

/* ── Item search wrapper – MUST be position:relative so the
      absolute dropdown anchors correctly in Chrome & Safari ── */
.item-name-wrap {
  position: relative;
}

/* ── Item search custom dropdown ──
   position:fixed escapes .table-responsive overflow:auto clipping.
   top/left are set dynamically by JS via getBoundingClientRect().     */
.item-dropdown {
  display: none;
  position: fixed;    /* viewport-layer — bypasses overflow:auto on all ancestors */
  /* top & left set by positionDropdown() in app.js */
  min-width: 380px;
  z-index: 9999;
  background: #fff;
  border: 1.5px solid #651C32;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 24px rgba(101,28,50,.22);
  max-height: 280px;
  overflow-y: auto;
}
.item-opt {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0e4e8;
  transition: background .12s;
}
.item-opt:last-child { border-bottom: none; }
.item-opt:hover,
.item-opt.active    { background: #f9f0f2; }
.item-opt-name {
  font-weight: 600;
  font-size: .88rem;
  color: #2d1a22;
}
.item-opt-meta {
  font-size: .76rem;
  color: #777;
  margin-top: 1px;
}
.item-opt-price { font-weight: 700; color: #651C32; }
.item-opt-unit  { color: #555; margin-left: 3px; }
.item-opt-date  { margin-left: 4px; }
.item-opt-ref   { color: #aaa; margin-left: 2px; }
.item-opt-empty { padding: 10px 12px; color: #999; font-size: .83rem; font-style: italic; }

/* ── Approved / pending badges inside dropdown options ── */
.item-opt-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}
.item-opt-badge.approved { background: #d4edda; color: #155724; }
.item-opt-badge.pending  { background: #fff3cd; color: #856404; }

/* ── Last-price hint bar ── */
.hint-box {
  background: #fff8e1;
  border: 1px solid #ffe082;
  color: #5a4a00;
  font-size: .78rem;
  line-height: 1.5;
}
.hint-box .use-last-price {
  font-weight: 600;
  color: #651C32;
  text-decoration: underline;
  margin-left: 6px;
  cursor: pointer;
}
.hint-box .hint-meta { color: #888; }
.pct-badge { font-weight: 700; margin: 0 4px; }
.pct-up    { color: #CE2939; }
.pct-down  { color: #43B02A; }
.pct-same  { color: #888; }

/* ── Approve page: last-price comparison cell ── */
.last-price-cell { font-size: .82rem; color: #555; white-space: nowrap; }
.last-price-cell .pct-up   { color: #CE2939; font-weight: 700; }
.last-price-cell .pct-down { color: #43B02A; font-weight: 700; }
.last-price-cell .pct-same { color: #888; }
.last-price-cell .pct-new  { color: #888; font-style: italic; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: #333;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar-hlg {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.navbar-hlg .navbar-brand img { height: 44px; }
.navbar-hlg .nav-link         { color: rgba(255,255,255,.85) !important; }
.navbar-hlg .nav-link:hover,
.navbar-hlg .nav-link.active  { color: #fff !important; }
.navbar-hlg .dropdown-menu    { border: none; box-shadow: var(--card-shadow); }
.navbar-hlg .navbar-toggler   { border-color: rgba(255,255,255,.4); }
.navbar-hlg .navbar-toggler-icon { filter: invert(1); }

/* ── Page header ── */
.page-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}
.page-header h2 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.page-header p  { margin: 0; opacity: .8; font-size: .9rem; }

/* ── Cards ── */
.card {
  border: none;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}
.card-header-hlg {
  background: var(--primary);
  color: #fff;
  border-radius: 8px 8px 0 0 !important;
  padding: .75rem 1.25rem;
  font-weight: 600;
}

/* ── Stat cards ── */
.stat-card {
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  background: #fff;
  box-shadow: var(--card-shadow);
}
.stat-card.green { border-left-color: var(--green); }
.stat-card.red   { border-left-color: var(--red); }
.stat-card.warn  { border-left-color: #f0ad4e; }
.stat-card .stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-card.green .stat-num { color: var(--green); }
.stat-card.red   .stat-num { color: var(--red); }
.stat-card .stat-label { font-size: .8rem; color: #888; margin-top: 2px; }

/* ── Buttons ── */
.btn-primary-hlg {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary-hlg:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #369122; border-color: #369122; color: #fff; }

/* ── Tables ── */
.table-hlg thead th {
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: .85rem;
}
.table-hlg tbody tr:hover { background: #f9f0f2; }
.table-hlg td { vertical-align: middle; font-size: .9rem; }

/* ── Estimate item rows ── */
.item-row td { padding: .45rem .5rem; }
.item-row .form-control, .item-row .form-select {
  font-size: .85rem;
  padding: .3rem .5rem;
}
.item-total { font-weight: 600; color: var(--primary); }
tfoot.estimate-foot td { font-weight: 700; background: #f9f0f2; }

/* ── Status timeline ── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: .75rem;
  top: 0; bottom: 0;
  width: 2px;
  background: #e0d0d4;
}
.tl-item { position: relative; padding-bottom: 1.25rem; }
.tl-dot {
  position: absolute;
  left: -1.6rem;
  top: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
}
.tl-dot.green { background: var(--green); }
.tl-dot.red   { background: var(--red); }
.tl-dot.grey  { background: #bbb; }
.tl-date { font-size: .75rem; color: #888; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.login-header {
  background: #fff;
  padding: 2rem;
  text-align: center;
  border-bottom: 3px solid var(--primary);
}
.login-header img { height: 64px; }
.login-body { background: #fff; padding: 1.75rem 2rem 2rem; }

/* ── Escalation warning ── */
.escalation-box {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 12px 16px;
  border-radius: 4px;
  margin: 1rem 0;
}

/* ── File upload zone ── */
.upload-zone {
  border: 2px dashed #c9a0a9;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  background: #fdf7f8;
  cursor: pointer;
  transition: border-color .2s;
}
.upload-zone:hover { border-color: var(--primary); }

/* ── Misc ── */
.badge-role-admin      { background: var(--primary) !important; }
.badge-role-management { background: #6f42c1 !important; }
.badge-role-user       { background: #0d6efd !important; }
.badge-role-finance    { background: #0d9488 !important; }
.ref-no { font-family: monospace; font-weight: 600; color: var(--primary); }

@media (max-width: 576px) {
  .page-header h2 { font-size: 1.1rem; }
  .stat-card .stat-num { font-size: 1.5rem; }
}
