/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  color: #fff !important;
}

.btn-outline-primary {
  &:hover, &:focus-visible, &:active {
    color: #fff !important;
  }
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
.study-name {
  padding-right: 20px;
  margin-right: 10px;
}

@media (min-width: 1200px) {
  .study-name {
    border-right: 1px solid rgba(0, 0, 0, 0.5);
  }
}

.navbar {
  background-color: #fff;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-fixed > table:nth-of-type(1) > thead {
  position: sticky;
  top: 73px;
}

.table-sm {
  font-size: 0.875rem;
}

/* ── Loading spinners ─────────────────────────────────────────────────────── */
@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.circle-loading {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.circle-loading-large {
  width: 60px;
  height: 60px;
  border: 6px solid #f3f3f3;
  border-top: 6px solid #007bff;
}

.circle-loading-small {
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #007bff;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.loading-container .loading-text {
  margin-top: 15px;
  color: #6c757d;
  font-size: 14px;
}

/* ── Table loading overlays ───────────────────────────────────────────────── */
.table-loading-overlay {
  position: relative;
}

.table-loading-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 10;
  pointer-events: none;
}

.table-loading-overlay .loading-spinner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  pointer-events: none;
}

.table-overlay-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.table-container-wrapper {
  position: relative;
}

.overlay-spinner {
  text-align: center;
}

.overlay-spinner .spinner-border {
  color: #26E3CA !important;
}

.overlay-spinner .mt-2 {
  margin-top: 0.5rem;
}

/* ── No-data overlay ──────────────────────────────────────────────────────── */
.chart-no-data-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 243, 205, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  border-radius: 4px;
  border: 2px solid #ffecb5;
}

.no-data-content {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  color: #664d03;
  font-weight: 600;
}

.no-data-icon {
  font-size: 24px;
  margin-bottom: 10px;
  color: #664d03;
}

.no-data-text {
  font-size: 14px;
  color: #664d03;
  font-weight: 500;
  text-shadow: none;
}

/* ── Alarm badges ─────────────────────────────────────────────────────────── */
.alarm-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.alarm-badge:hover {
  opacity: 0.8;
}

.alarm-badge-high   { background-color: #DB4456; }
.alarm-badge-medium { background-color: #EE8449; }
.alarm-badge-low    { background-color: #F3AC20; }

.alarm-badge .alarm-icon {
  filter: brightness(0) invert(1);
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-content {
  max-height: 95vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-body {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}

.modal-body::-webkit-scrollbar              { width: 8px; }
.modal-body::-webkit-scrollbar-track        { background: #f1f1f1; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb        { background: #888; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover  { background: #555; }

/* Disable modal animation to prevent janky resizing */
.modal.fade,
.modal.fade .modal-dialog {
  transition: none !important;
  transform: none !important;
}

.modal-dialog {
  margin: 1.75rem auto !important;
}

/* ── Charts ───────────────────────────────────────────────────────────────── */

/* Fix legend-tooltip overlay dimensions. */
.legend-tooltip-overlay {
  width: 100px !important;
  height: 22px !important;
}

/* overflow: visible lets Bootstrap legend-tooltip overlays extend outside the div */
.chart-container {
  position: relative;
  overflow: visible !important;
  margin-bottom: 1rem;
}

.chart-container:last-child {
  margin-bottom: 0;
}

/* width: 100% forces every chart canvas to fill its container regardless of
   data density.  max-width is kept as a safety net for very narrow viewports.
   Height is set as an inline style / HTML attribute by Chart.js. */
.chart-container canvas {
  width: 100% !important;
  max-width: 100%;
}

.device-timeline-container {
  position: relative;
  margin-bottom: 1rem;
  min-height: 60px;
}

.device-timeline-container:last-child {
  margin-bottom: 0;
}

/* Chart loading overlay */
.chart-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(248, 249, 250, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.loading-content {
  text-align: center;
  color: #00AE99;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e9ecef;
  border-top: 2px solid #00AE99;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 8px;
}

.loading-text {
  font-size: 12px;
  font-weight: 500;
  color: #00AE99;
}

/* ── Button groups ────────────────────────────────────────────────────────── */
.btn-group .btn                                      { margin-right: 0 !important; }
.btn-group > .btn:not(:first-child)                  { margin-left: -1px; }
.btn-group > .btn:first-child                        { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.btn-group > .btn:not(:first-child):not(:last-child) { border-radius: 0 !important; }
.btn-group > .btn:last-child                         { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
.btn-group > .btn:hover                              { color: #000 !important; }
