/* =====================================================================
   TDMx Clinical Decision Support — Custom Design System
   ===================================================================== */

/* --- Base Typography --- */
body, .container-fluid, .container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: #2c3e50;
  font-size: 13.5px;
}

/* =====================================================================
   NAVBAR
   ===================================================================== */
.navbar {
  background: linear-gradient(135deg, #1a3a5c 0%, #215d8f 100%) !important;
  border-bottom: 2px solid #1abc9c !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22) !important;
  border-radius: 0 !important;
  min-height: 40px !important;
  margin-bottom: 10px !important;
}

.navbar-default {
  background: linear-gradient(135deg, #1a3a5c 0%, #215d8f 100%) !important;
  border-color: transparent !important;
}

.navbar-brand {
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  letter-spacing: 0.3px;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  height: auto !important;
}

.navbar-default .navbar-nav > li > a {
  color: rgba(255, 255, 255, 0.82) !important;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 16px;
  transition: color 0.2s, background 0.2s;
  border-bottom: 2px solid transparent;
}

.navbar-default .navbar-nav > li > a:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border-bottom: 2px solid rgba(26, 188, 156, 0.6);
}

.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border-bottom: 2px solid #1abc9c;
}

/* =====================================================================
   WELL PANELS / CARDS
   ===================================================================== */
.well {
  background: #ffffff !important;
  border: 1px solid #dce6f0 !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06) !important;
  padding: 16px !important;
}

/* =====================================================================
   TAB PANELS
   ===================================================================== */
.nav-tabs {
  border-bottom: 2px solid #dce6f0;
}

.nav-tabs > li > a {
  color: #546e7a !important;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px 6px 0 0 !important;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent !important;
  margin-right: 3px;
}

.nav-tabs > li > a:hover {
  color: #1a3a5c !important;
  background: #f0f6ff !important;
  border-color: #dce6f0 !important;
}

.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
  color: #1a3a5c !important;
  font-weight: 600;
  background: #ffffff !important;
  border: 1px solid #dce6f0 !important;
  border-top: 3px solid #215d8f !important;
  border-bottom-color: #ffffff !important;
}

.tabbable > .tab-content {
  border: 1px solid #c3d4e5;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 14px;
  background: #ffffff;
}

.tabbable > .tab-content::after {
  content: "";
  display: table;
  clear: both;
}

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: background 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.btn-primary {
  background: #215d8f !important;
  border-color: #1a4a72 !important;
  color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus {
  background: #1a4a72 !important;
  box-shadow: 0 2px 8px rgba(33, 93, 143, 0.4) !important;
}

.btn-success {
  background: #1abc9c !important;
  border-color: #17a589 !important;
  color: #fff !important;
}
.btn-success:hover, .btn-success:focus {
  background: #17a589 !important;
  box-shadow: 0 2px 8px rgba(26, 188, 156, 0.4) !important;
}

.btn-default {
  background: #f8f9fa !important;
  border-color: #ced4da !important;
  color: #495057 !important;
}
.btn-default:hover {
  background: #e9ecef !important;
  border-color: #adb5bd !important;
}

/* =====================================================================
   FORM CONTROLS
   ===================================================================== */
.form-control {
  border: 1px solid #cdd6e0;
  border-radius: 5px;
  font-size: 13px;
  color: #2c3e50;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  border-color: #215d8f !important;
  box-shadow: 0 0 0 3px rgba(33, 93, 143, 0.12) !important;
  outline: none;
}

label {
  font-size: 12.5px;
  font-weight: 600;
  color: #455a64;
  margin-bottom: 3px;
}

/* Shiny radio / checkbox labels */
.radio label, .checkbox label,
.radio-inline label, .checkbox-inline label {
  font-weight: 400;
  color: #2c3e50;
}

/* Slider labels */
.irs-bar { background: #215d8f !important; border-color: #215d8f !important; }
.irs-bar-edge { background: #215d8f !important; border-color: #215d8f !important; }
.irs-single, .irs-from, .irs-to { background: #215d8f !important; }
.irs-handle > i { background: #215d8f !important; }

/* Select input */
select.form-control {
  padding: 4px 8px;
}

/* =====================================================================
   ABOUT PAGE
   ===================================================================== */
.tdmx-about-hero {
  background: linear-gradient(135deg, #1a3a5c 0%, #215d8f 100%);
  border-radius: 10px;
  padding: 26px 30px;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(26, 58, 92, 0.3);
}

.tdmx-about-hero h3 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: #ffffff !important;
}

.tdmx-about-hero p {
  color: rgba(255, 255, 255, 0.82) !important;
}

.tdmx-version-badges {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.tdmx-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
}

.tdmx-card {
  background: #fff;
  border: 1px solid #dce6f0;
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.tdmx-card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #1a3a5c;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f4f8;
}

.tdmx-disclaimer-card {
  background: #fffbf0;
  border: 1px solid #f0d060;
  border-left: 4px solid #e6a800;
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #5d4037;
  line-height: 1.6;
}

.tdmx-disclaimer-card .disclaimer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
  color: #7d5a00;
  font-size: 13.5px;
}

.tdmx-resource-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #215d8f;
  text-decoration: none;
  padding: 5px 0;
  border-bottom: 1px solid #f0f4f8;
  transition: color 0.15s;
}
.tdmx-resource-link:last-child { border-bottom: none; }
.tdmx-resource-link:hover { color: #1a4a72; text-decoration: none; }
.tdmx-resource-link .fa { width: 16px; text-align: center; color: #1abc9c; }

/* =====================================================================
   PATIENT PANEL — SECTION HEADERS
   ===================================================================== */
.tdmx-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px 0;
  margin-bottom: 12px;
  border-bottom: 2px solid #e8f0f8;
  color: #1a3a5c;
  font-size: 14px;
  font-weight: 700;
}

.tdmx-panel-header .fa {
  color: #215d8f;
  font-size: 15px;
}

.tdmx-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #90a4ae;
  margin: 10px 0 6px 0;
}

/* =====================================================================
   FILE I/O SECTION
   ===================================================================== */
.tdmx-fileio-well {
  background: #f8fafb !important;
  border: 1px solid #dce6f0 !important;
}

.tdmx-fileio-well .btn-file {
  background: #215d8f;
  border-color: #1a4a72;
  color: #fff;
}

.tdmx-fileio-well .btn-file:hover {
  background: #1a4a72;
}

.tdmx-action-row {
  display: flex;
  gap: 7px;
  margin-top: 6px;
}

.tdmx-action-row .btn,
.tdmx-action-row .shiny-download-link {
  flex: 1;
}

/* =====================================================================
   DOSE OPTIMISATION BOX (in Dosing tab)
   ===================================================================== */
.dosopt-box {
  background: #f0f6ff;
  border: 1px solid #bedaf9;
  border-left: 4px solid #215d8f;
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 8px;
}

.dosopt-box .dosopt-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a3a5c;
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.dosopt-box .btn {
  width: 100%;
  margin-bottom: 6px;
  text-align: left;
}

/* =====================================================================
   SETTINGS PAGE
   ===================================================================== */
.tdmx-settings-container {
  max-width: 680px;
  padding: 16px 6px;
}

.tdmx-settings-card {
  background: #fff;
  border: 1px solid #dce6f0;
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.tdmx-settings-card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: #546e7a;
  margin: 0 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f4f8;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tdmx-settings-card-title .fa {
  color: #215d8f;
}

/* =====================================================================
   MODALS
   ===================================================================== */
.modal-header {
  background: linear-gradient(to right, #1a3a5c, #215d8f);
  color: #fff !important;
  border-radius: 5px 5px 0 0;
  padding: 14px 18px;
}

.modal-header .modal-title {
  color: #fff !important;
  font-weight: 600;
  font-size: 15px;
}

.modal-header .close {
  color: rgba(255, 255, 255, 0.75) !important;
  opacity: 1;
  text-shadow: none;
  font-size: 22px;
}

.modal-header .close:hover {
  color: #fff !important;
}

.modal-content {
  border-radius: 8px;
  border: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal-footer {
  background: #f8fafb;
  border-top: 1px solid #e9ecef;
  border-radius: 0 0 8px 8px;
}

/* =====================================================================
   DATA TABLES
   ===================================================================== */
.dataTables_wrapper {
  font-size: 12.5px;
}

table.dataTable thead th {
  background: #1a3a5c !important;
  color: #fff !important;
  font-size: 12px;
  font-weight: 600;
  border-color: #215d8f !important;
}

table.dataTable tbody tr:hover {
  background: #f0f6ff !important;
}

table.dataTable.stripe tbody tr.odd {
  background: #f8fafb;
}

/* =====================================================================
   NOTIFICATIONS / ALERTS
   ===================================================================== */
.shiny-notification {
  border-radius: 7px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border: none;
  padding: 12px 16px;
}

.shiny-notification-warning {
  background: #fff8e1;
  color: #5d4037;
  border-left: 4px solid #f0a500;
}

.shiny-notification-error {
  background: #fdecea;
  color: #b71c1c;
  border-left: 4px solid #e53935;
}

.shiny-notification-message {
  background: #e8f5e9;
  color: #1b5e20;
  border-left: 4px solid #43a047;
}

/* =====================================================================
   SCROLLBAR (WebKit)
   ===================================================================== */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #f5f7f9; }
::-webkit-scrollbar-thumb { background: #b0bec5; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #78909c; }

/* =====================================================================
   BUSY SPINNER
   ===================================================================== */
.shinybusy-overlay {
  background: rgba(255, 255, 255, 0.7) !important;
}

/* =====================================================================
   PATIENT FIELD EMPHASIS
   ===================================================================== */
#PAT.form-control {
  font-weight: 600;
  font-size: 14px;
  border-color: #b0c4de;
}

/* =====================================================================
   MISC
   ===================================================================== */
hr {
  border-top: 1px solid #e8eff6;
  margin: 12px 0;
}

/* share URL verbatim box */
#share_url {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  font-size: 11.5px;
  color: #6c757d;
  word-break: break-all;
}

/* estmap verbose text */
#estmap_verbose {
  font-size: 12px;
  color: #546e7a;
  padding: 6px 0;
}

/* Handsontable tweaks */
.handsontable,
.handsontable td,
.handsontable tr,
.handsontable input,
.handsontable select {
  font-size: 11px !important;
}

.handsontable th {
  background: #eef3f8 !important;
  color: #2c3e50 !important;
  font-weight: 600;
  font-size: 11px !important;
}

/* Checkbox cells (e.g. TDM "Include" column) — restyled as a small toggle
   switch instead of a native checkbox; still a real checkbox input
   underneath, so Handsontable's click/keyboard handling is unaffected. */
.handsontable .htCheckboxRendererInput {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 26px;
  height: 14px;
  margin: 0;
  vertical-align: middle;
  border-radius: 999px;
  background: #c8d2db;
  cursor: pointer;
  outline: none;
  position: relative;
  transition: background-color 0.15s ease;
}

.handsontable .htCheckboxRendererInput::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: left 0.15s ease;
}

.handsontable .htCheckboxRendererInput:checked {
  background: #215d8f;
}

.handsontable .htCheckboxRendererInput:checked::after {
  left: 14px;
}

/* fileInput browse button */
.btn-file {
  border-radius: 5px;
}

/* Download button fix — inherits shiny-download-link class */
.shiny-download-link {
  display: inline-block;
}
