/* ============================================================
   WAR ROOM P4 — Theme Override
   ============================================================ */

/* ─── 1. TOKENS ─────────────────────────────────────────── */
:root {
  --wr-navy:      #0d1b4b;
  --wr-navy-mid:  #1a2f6b;
  --wr-blue:      #1a2f6b;
  --wr-blue-lt:   #2a4a9b;
  --wr-gold:      #c8960c;
  --wr-gold-lt:   #f5c842;
  --wr-red:       #dc143c;
  --wr-bg:        #eef1f8;
  --wr-card-bg:   #ffffff;
  --wr-border:    #dde3ed;
  --wr-text:      #1e293b;
  --wr-muted:     #64748b;
  --wr-radius:    14px;
  --wr-shadow:    0 2px 12px rgba(13,27,75,.10);
  --wr-shadow-lg: 0 8px 32px rgba(13,27,75,.16);
  --wr-font:      'Sarabun', 'Thonburi', -apple-system, sans-serif;
}

/* ─── 2. BASE ────────────────────────────────────────────── */
body {
  background: var(--wr-bg) !important;
  font-family: var(--wr-font) !important;
  font-size: 0.94rem;
  color: var(--wr-text);
  padding-top: 64px;    /* topbar height */
  padding-left: 220px;  /* sidebar width — fallback for pages without .wr-main-content */
}

/* ─── 3. SIDEBAR ─────────────────────────────────────────── */
.wr-sidebar {
  position: fixed;
  top: 64px;
  left: 0;
  bottom: 0;
  width: 220px;
  background: linear-gradient(180deg, var(--wr-navy) 0%, #0b1e3d 100%);
  z-index: 1030 !important;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0 0;
  box-shadow: 2px 0 12px rgba(0,0,0,.18);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge */
}
.wr-sidebar::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.wr-sidebar-nav { flex: 1; }

/* Main content area — offset by sidebar width */
.wr-main-content {
  margin-left: 220px;
  padding-top: 64px;
  min-height: 100vh;
  padding-left: 2rem;
  padding-right: 2rem;
  padding-bottom: 1rem;
}

.wr-sidebar-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.28);
  padding: 0.7rem 1rem 0.3rem;
  margin-top: 0.25rem;
}
.wr-sidebar-section-label:first-child {
  margin-top: 0;
}

.wr-sidebar-menu {
  list-style: none;
  margin: 0 0 0.25rem 0;
  padding: 0;
}

.wr-sidebar-item {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: rgba(255,255,255,.6);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
  font-family: var(--wr-font);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wr-sidebar-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wr-sidebar-item:hover {
  color: #fff;
  background: rgba(255,255,255,.09);
  border-left-color: rgba(255,255,255,.28);
}
.wr-sidebar-item.active {
  color: #fff;
  background: rgba(200,151,42,.15);
  border-left-color: var(--wr-gold-lt);
  font-weight: 700;
}
.wr-sidebar-item i {
  font-size: 0.95rem;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

.wr-sidebar-item--danger { color: #fca5a5; }
.wr-sidebar-item--danger:hover {
  background: rgba(220,38,38,.13) !important;
  border-left-color: #f87171 !important;
  color: #fca5a5 !important;
}
.wr-sidebar-item--danger.active {
  background: rgba(220,38,38,.2) !important;
  border-left-color: #ef4444 !important;
  color: #fff !important;
}

/* Topbar actions — notify bell */
.wr-topbar-actions {
  display: flex; align-items: center; gap: 0.75rem;
}
.wr-notify-btn {
  position: relative; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 0.2s; font-size: 1.1rem;
}
.wr-notify-btn:hover { background: rgba(200,150,12,0.2); color: #f5c842; border-color: rgba(200,150,12,0.4); }
.wr-notify-badge {
  position: absolute; top: -2px; right: -2px; background: #dc2626; color: #fff;
  font-size: 0.65rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  border: 2px solid #0d1b4b;
}

/* Sidebar footer — user info + logout */
.wr-sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 0.75rem;
}
.wr-sidebar-user {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem;
  border-radius: 8px; transition: background 0.2s; margin-bottom: 0.5rem;
  text-decoration: none;
}
.wr-sidebar-user:hover { background: rgba(255,255,255,0.06); }
.wr-sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 2px solid #c8960c; flex-shrink: 0;
}
.wr-sidebar-user-fallback {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(200,150,12,0.2);
  color: #f5c842; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; flex-shrink: 0; border: 2px solid rgba(200,150,12,0.3);
}
.wr-sidebar-user-info { flex: 1; min-width: 0; }
.wr-sidebar-user-name {
  display: block; color: #fff; font-weight: 600; font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wr-sidebar-user-role {
  display: block; color: rgba(255,255,255,0.45); font-size: 0.7rem;
}
.wr-sidebar-logout-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.45rem; border-radius: 6px; border: 1px solid rgba(255,100,100,0.2);
  cursor: pointer; font-size: 0.78rem; font-weight: 600; transition: all 0.2s;
  background: rgba(220,38,38,0.08); color: rgba(255,150,150,0.8); font-family: inherit;
}
.wr-sidebar-logout-btn:hover { background: rgba(220,38,38,0.2); color: #fca5a5; }

/* Mobile: hamburger toggle button in topbar */
.wr-sidebar-toggle {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: none;           /* hidden on desktop */
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}
.wr-sidebar-toggle:hover { background: rgba(255,255,255,.2); }

/* Dark overlay behind sidebar on mobile */
.wr-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1025;
}
.wr-sidebar-overlay.active { display: block; }

/* ─── 4. TOPBAR ──────────────────────────────────────────── */
.wr-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: linear-gradient(135deg, var(--wr-navy) 0%, var(--wr-navy-mid) 100%);
  border-bottom: 2px solid var(--wr-gold);
  box-shadow: 0 2px 20px rgba(0,0,0,.35), 0 0 0 1px rgba(200,150,12,.2);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1040 !important;
  gap: 1rem;
}

.wr-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.wr-topbar-brand img {
  height: 40px;
  width: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.wr-topbar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.wr-topbar-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.wr-topbar-title span {
  color: var(--wr-gold-lt);
}

.wr-topbar-subtitle {
  font-size: 0.7rem;
  color: rgba(255,255,255,.65);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* profile button inside topbar */
.wr-topbar .profile-btn {
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  color: #fff !important;
  border-radius: 999px !important;
  padding: 0.35rem 0.85rem !important;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background .2s;
  flex-shrink: 0;
}
.wr-topbar .profile-btn:hover {
  background: rgba(255,255,255,.22) !important;
}
.wr-topbar .profile-avatar-placeholder {
  background: rgba(255,255,255,.2);
  color: #fff;
}
.wr-topbar .dropdown-menu {
  border-radius: 12px;
  border: 1px solid var(--wr-border);
  box-shadow: var(--wr-shadow-lg);
  padding: 0.4rem;
  min-width: 180px;
}
.wr-topbar .dropdown-item {
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.wr-topbar .dropdown-item:hover { background: #f1f5fb; }

/* ─── 4. SEARCH VIEW ─────────────────────────────────────── */
#search-view {
  max-width: 860px !important;
  margin: 2rem auto 2.5rem !important;
}

#search-view .search-card {
  background: var(--wr-card-bg) !important;
  border-radius: var(--wr-radius) !important;
  border: 1px solid var(--wr-border) !important;
  box-shadow: var(--wr-shadow-lg) !important;
  padding: 2rem 2.25rem 1.75rem !important;
}

/* hero */
#search-view .search-hero {
  margin-bottom: 1.75rem !important;
  gap: 1rem;
}

.app-logo {
  max-width: 72px !important;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.35));
}

.main-title {
  font-size: 2rem !important;
  font-weight: 800 !important;
  color: var(--wr-navy) !important;
  letter-spacing: .02em;
  line-height: 1.1;
  text-shadow: none !important;
}
.sub-title {
  font-size: 0.8rem !important;
  color: var(--wr-muted) !important;
  font-weight: 500 !important;
  margin-top: 0.2rem !important;
  text-shadow: none !important;
  margin-left: 0 !important;
}

/* search input */
#search-view .search-input-row .form-control-lg {
  border: 2px solid var(--wr-border) !important;
  border-radius: 12px 0 0 12px !important;
  font-size: 0.98rem !important;
  padding: 0.7rem 1rem !important;
  background: #f8fafc !important;
  transition: border-color .2s, box-shadow .2s;
}
#search-view .search-input-row .form-control-lg:focus {
  border-color: var(--wr-blue) !important;
  box-shadow: 0 0 0 3px rgba(29,78,216,.12) !important;
  background: #fff !important;
}
#search-btn {
  background: linear-gradient(135deg, var(--wr-blue), var(--wr-blue-lt)) !important;
  border: none !important;
  border-radius: 0 12px 12px 0 !important;
  padding: 0.7rem 1.4rem !important;
  font-size: 0.98rem !important;
  font-weight: 700 !important;
  letter-spacing: .02em;
  box-shadow: none !important;
  transition: opacity .2s;
}
#search-btn:hover { opacity: .9 !important; }


/* results title */
#search-view .search-results-title {
  font-size: 0.875rem !important;
  font-weight: 700 !important;
  color: var(--wr-muted) !important;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 0.6rem !important;
}

/* ─── 5. SEARCH RESULT ITEMS ─────────────────────────────── */
#search-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#search-results .list-group-item {
  background: var(--wr-card-bg) !important;
  border: 1px solid var(--wr-border) !important;
  border-radius: 12px !important;
  padding: 0.85rem 1.1rem !important;
  text-align: left;
  transition: box-shadow .18s, transform .18s, border-color .18s;
  box-shadow: 0 1px 4px rgba(13,34,72,.06);
  font-size: 0.95rem !important;
}
#search-results .list-group-item:hover {
  border-color: var(--wr-blue-lt) !important;
  box-shadow: 0 4px 14px rgba(29,78,216,.12) !important;
  transform: translateY(-1px);
}
#search-results .list-group-item strong {
  color: var(--wr-navy);
  font-size: 1rem;
  font-weight: 700;
}
#search-results .list-group-item small {
  color: var(--wr-muted);
  font-size: 0.82rem;
}

/* ─── 6. FORM VIEW ───────────────────────────────────────── */
#form-view {
  padding-bottom: 2rem;
}

/* section cards */
#form-view .form-section-card {
  background: var(--wr-card-bg) !important;
  border: 1px solid var(--wr-border) !important;
  border-radius: var(--wr-radius) !important;
  box-shadow: var(--wr-shadow) !important;
  margin-bottom: 1.25rem !important;
  overflow: hidden;
}

#form-view .card-header {
  background: #f8fafd !important;
  border-bottom: 1px solid var(--wr-border) !important;
  padding: 0.9rem 1.5rem !important;
}

#form-view .card-header h3 {
  font-size: 1rem !important;
  font-weight: 700 !important;
  color: var(--wr-text) !important;
}

/* section color accents */
#form-view .form-section-card.section-1 .card-header { border-left: 4px solid #c8960c; background: #f0f7ff !important; }
#form-view .form-section-card.section-2 .card-header { border-left: 4px solid #10b981; background: #f0fdf8 !important; }
#form-view .form-section-card.section-3 .card-header { border-left: 4px solid #f97316; background: #fff8f0 !important; }
#form-view .form-section-card.section-4 .card-header { border-left: 4px solid #6366f1; background: #f5f3ff !important; }
#form-view .form-section-card.section-5 .card-header { border-left: 4px solid #ef4444; background: #fff5f5 !important; }
#form-view .form-section-card.section-6 .card-header { border-left: 4px solid #059669; background: #f0fdf4 !important; }

#form-view .card-body {
  padding: 1.25rem 1.5rem !important;
}

/* inputs */
#form-view .form-control,
#form-view .form-select {
  border: 1.5px solid #dde3ed;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color .2s, box-shadow .2s;
}
#form-view .form-control:focus,
#form-view .form-select:focus {
  border-color: var(--wr-blue) !important;
  box-shadow: 0 0 0 3px rgba(29,78,216,.1) !important;
}
#form-view label.form-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

/* form title card */
.form-title-card {
  background: linear-gradient(135deg, var(--wr-navy) 0%, var(--wr-navy-mid) 100%) !important;
  border-radius: var(--wr-radius) !important;
  box-shadow: var(--wr-shadow-lg) !important;
}

/* ─── 7. FORM ACTION BUTTONS ─────────────────────────────── */
.form-action-bar {
  background: var(--wr-card-bg);
  border: 1px solid var(--wr-border);
  border-radius: var(--wr-radius);
  box-shadow: var(--wr-shadow);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0 2rem;
}

#save-new-btn {
  background: linear-gradient(135deg, var(--wr-blue), var(--wr-blue-lt)) !important;
  border: none !important;
  border-radius: 10px !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  padding: 0.65rem 1.75rem !important;
  box-shadow: 0 3px 12px rgba(29,78,216,.3) !important;
  transition: box-shadow .2s, transform .15s;
}
#save-new-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(29,78,216,.4) !important; }

#update-btn {
  background: linear-gradient(135deg, #d97706, #f59e0b) !important;
  border: none !important;
  border-radius: 10px !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  padding: 0.65rem 1.75rem !important;
  box-shadow: 0 3px 12px rgba(217,119,6,.3) !important;
  color: #fff !important;
  transition: box-shadow .2s, transform .15s;
}
#update-btn:hover { transform: translateY(-1px); }

#delete-btn {
  background: #fff !important;
  border: 1.5px solid #fca5a5 !important;
  color: #dc2626 !important;
  border-radius: 10px !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  padding: 0.65rem 1.75rem !important;
  transition: background .2s, border-color .2s;
}
#delete-btn:hover { background: #fff5f5 !important; border-color: #dc2626 !important; }

/* remove old bg-light style from button area */
.text-center.p-3.my-4.bg-light.rounded {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* ─── 8. BACK BUTTONS ────────────────────────────────────── */
.back-btn {
  background: var(--wr-card-bg) !important;
  border: 1.5px solid var(--wr-border) !important;
  color: var(--wr-text) !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  font-size: 0.88rem !important;
  padding: 0.5rem 1.1rem !important;
  transition: background .2s, border-color .2s;
}
.back-btn:hover { background: #f1f5fb !important; border-color: #9ca3af !important; }

/* ─── 9. FORM PAGE HEADER ────────────────────────────────── */
.form-page-header {
  background: linear-gradient(135deg, var(--wr-navy) 0%, var(--wr-navy-mid) 100%) !important;
  border-radius: var(--wr-radius) !important;
  box-shadow: var(--wr-shadow-lg) !important;
  padding: 1.5rem 1.75rem !important;
  margin-bottom: 1.5rem;
}

.form-page-header .title {
  color: #ffffff !important;
  font-size: 1.35rem !important;
  font-weight: 800 !important;
}

.form-page-header .subtitle {
  color: rgba(255,255,255,.7) !important;
  font-size: 0.85rem !important;
}

.war-room-badge {
  background: rgba(255,255,255,.15) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.3) !important;
  border-radius: 8px !important;
  font-size: 0.78rem !important;
}

/* ─── 10. LOADER ─────────────────────────────────────────── */
#loader-overlay {
  background: rgba(13,34,72,.55) !important;
  backdrop-filter: blur(4px);
}
.full-page-loader { background: rgba(13,34,72,.55) !important; }

/* ─── 11. SUMMARY / COL-C VIEW HEADER ───────────────────── */
#back-to-search-btn-from-summary {
  background: linear-gradient(135deg, var(--wr-blue), var(--wr-blue-lt)) !important;
  border: none !important;
  border-radius: 10px !important;
  font-weight: 700 !important;
  padding: 0.6rem 1.25rem !important;
  box-shadow: 0 3px 10px rgba(29,78,216,.25) !important;
}

/* ─── 12. INLINE FORM INPUTS (Section 6 sub-form) ───────── */

/* flex row containing a radio/checkbox + label text + optional inline inputs */
.wr-inline-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

/* a line of mixed label-text + inputs */
.wr-inline-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  margin-top: 0.3rem;
  line-height: 1.6;
}

/* group that wraps around a hospital sub-field */
.wr-inline-field-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
}

/* plain label text inside an inline row */
.wr-inline-label {
  font-size: 0.88rem;
  color: #065f46;
  white-space: nowrap;
  flex-shrink: 0;
}

/* underline-style text input */
.wr-inline-input {
  display: inline-block;
  min-width: 120px;
  width: auto;
  flex: 1;
  border: none;
  border-bottom: 1.5px solid #6ee7b7;
  border-radius: 0;
  background: transparent;
  padding: 1px 4px;
  font-size: 0.88rem;
  color: var(--wr-text);
  line-height: 1.5;
  transition: border-color .2s;
  font-family: var(--wr-font);
}
.wr-inline-input:focus {
  outline: none;
  border-bottom-color: #059669;
  background: rgba(5,150,105,.04);
}
.wr-inline-input::placeholder {
  color: #a7d9c4;
  font-size: 0.82rem;
}

/* ─── 13. RESPONSIVE ─────────────────────────────────────── */

/* Tablet + mobile: sidebar collapses */
@media (max-width: 991px) {
  body { padding-left: 0; }
  .wr-main-content { margin-left: 0; }
  .wr-sidebar {
    transform: translateX(-100%);
    z-index: 1035;
  }
  .wr-sidebar.open {
    transform: translateX(0);
  }
  .wr-sidebar-toggle { display: flex; }
}

@media (max-width: 768px) {
  body { padding-top: 56px; }
  .wr-sidebar { top: 56px; }
  .wr-topbar { height: 56px; padding: 0 1rem; }
  .wr-topbar-subtitle { display: none; }
  .wr-topbar-title { font-size: 1rem; }
  .app-logo { max-width: 50px !important; height: 50px; }
  .main-title { font-size: 1.5rem !important; }
  .sub-title { font-size: 0.75rem !important; }
  #search-view .search-card { padding: 1.25rem 1rem 1.25rem !important; }
  .form-action-bar { gap: 0.5rem; padding: 1rem; }
  #save-new-btn, #update-btn, #delete-btn {
    padding: 0.6rem 1.1rem !important;
    font-size: 0.88rem !important;
  }
}
