/* Ensure html and body take the full viewport height */
html, body {
  height: 100%;
}

/* --- CSS Variables for theme adjustments --- */
:root {
  --primary-color: #1565c0;
  --primary-color-light: #64b5f6;
  --danger-color: #e53935;
  --success-color: #4caf50;
  --reset-color: #9e9e9e;
  --background-light: #f0f2f5;
  --medication-color: #ffb71d;  /* Yellow/Orange for medications */
  --hstts-color: #add8e6;       /* Light blue for Hs & Ts button */
  --modal-background: #fff;
  --modal-overlay-bg: rgba(0, 0, 0, 0.5);
}

/* --- Reusable Button Classes --- */
.btn {
  padding: 10px 15px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-start {
  background: var(--success-color); /* Green */
  color: #fff;
}
.btn-danger {
  background: var(--danger-color); /* Red */
  color: #fff;
}
.btn-reset {
  background: var(--reset-color); /* Grey */
  color: #fff;
}
.btn-medication {
  background: var(--medication-color); /* Yellow/Orange */
  color: #fff;
}
.btn-hstts {
  background: var(--hstts-color); /* Light Blue */
  color: #000;
}
.dark-blue-button {
  background: #1565c0;  /* dark blue */
  color: #fff;
  padding: 10px 15px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#auth-container {
  margin: 10px;
  padding: 0;
  font-family: 'Roboto', Arial, sans-serif;
  background: var(--background-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

#auth-container button {
  font-size: 12px;
  padding: 4px 8px;
  height: auto;
  min-height: unset;
  background: #fff;
  border: 1px solid #ddd;
  color: #333;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#user-info {
  font-size: 12px;
  color: #666;
}
/* Global Styles */
body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', Arial, sans-serif;
  background: var(--background-light);
}

/* MOBILE-FIRST: Base layout for app container */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--background-light);
}
@media (min-width: 769px) {
  #app-container {
    flex-direction: row;
  }
  #left-panel {
    width: 65%;
  }
  #right-panel {
    width: 35%;
  }
}

/* Left Panel: Timers & Log */
#left-panel {
  background: #fff;
  padding: 20px;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* Center the timer boxes in the left panel */
@media (max-width: 768px) {
  #left-panel, #right-panel {
    width: 100%;
  }
  .top-row {
    flex-direction: column;
    align-items: center;
  }
  .info-panel {
    width: 100%;
  }
}

#cpr-cycle-timer-box {
  margin: 0 auto;
  width: 100%;
  max-width: 600px;
  padding: 10px;
  box-sizing: border-box;
}

@media (max-width: 1200px) {
  #cpr-cycle-timer-box {
    max-width: 100%;
  }
}
/* Custom Timer Box Styles - OPTIMIZED */
#custom-timer-box {
  width: auto;
  max-width: 300px;
  margin: 0 auto;
  padding: 10px;
  background: #dfdfdf;
  min-height: 90px;  /* Changed from fixed height to min-height */
  overflow: visible; /* Changed from hidden to visible */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 5px;
}

#custom-timer-box h3 {
  margin: 0;
  padding: 0;
  line-height: 1;
  font-size: 1.2em;
}

#custom-timer-display {
  margin: 2px 0;
  height: 30px !important;
  font-size: 24px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#custom-timer-box .button-group {
  margin: 0;
  padding: 0;
  gap: 5px;
  line-height: 1;
  }
  #custom-timer-box .button-group button i {
    margin-right: 5px; /* Add space between icon and text */
  }
#custom-timer-box .button-group button {
  margin: 0;
  padding: 5px 10px;
  line-height: 1;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Timer Boxes */
.timer-box {
  background: #e3f2fd;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  flex: 0 0 auto;
  position: relative;
  font-size: 0.9em;
}

/* Make sure timer box has relative positioning for absolute button placement */
.timer-display-container {
  position: relative;
  width: 100%;
  height: 80px;
  margin-bottom: 15px;
}
#cpr-cycle-timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px !important;  /* Increased from 40px */
  font-weight: bold;
  color: var(--primary-color);
  margin: 0;
  z-index: 999;
}
/* Ensure the cycle label stays above the progress bar */
#cpr-cycle-label {
  position: relative;
  z-index: 11;
}
/* Make button label smaller */
#reset-cpr-cycle-zero .btn-label {
  font-size: 10px;
}
/* CPR Cycle End Overlay (Popup) */
.cycle-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.cycle-overlay.hidden {
  display: none !important;
}
.cycle-overlay-content {
  background: #fff;
  padding: 20px;
  border: 1px solid #ccc;
  border-radius: 8px;
  text-align: center;
  max-width: 90%;
}

/* Button Groups */
.button-group {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
#reset-cpr-cycle-zero,
#reset-adrenaline-timer {
  background: transparent;
  border: none;
  color: #666;
  font-size: 10px;
  padding: 2px 5px;
  margin: 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

#reset-cpr-cycle-zero:hover,
#reset-adrenaline-timer:hover {
  opacity: 1;
  color: #333;
}
@media (max-width: 480px) {
  /* Button Base Styles */
  #app-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;  /* Prevents horizontal scroll */
  }
  .btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: calc(33% - 10px);
    height: 60px;
    padding: 5px;
    font-size: 14px;
    min-width: 90px;  /* Ensures minimum button width */
    max-width: none;  /* Removes max-width constraint */
  }

  .btn i {
    font-size: 24px;
    margin-right: 5px;
  }

  .btn-label {
    text-align: left;
    font-size: 13px;
    line-height: 1.2;
    padding: 0 2px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  #reset-cpr-cycle-zero,
  #reset-adrenaline-timer {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 8px;
    padding: 0;
    margin: 0;
    z-index: 10;
    opacity: 0.6;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #reset-cpr-cycle-zero {
    margin-top: 0px;
    width: 40px !important;
  }
  
  #reset-adrenaline-timer {
    margin-top: 5px;
    width: 30px !important;
  }
  
  #reset-cpr-cycle-zero i,
  #reset-adrenaline-timer i {
    font-size: 8px !important;
    line-height: 1;
    margin: 0 !important;
    padding: 0 !important;
  }

  #reset-cpr-cycle-zero .btn-label,
  #reset-adrenaline-timer .btn-label {
    font-size: 8px !important;
    line-height: 1;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Timer Box Adjustments */
  #cpr-cycle-timer-box .button-group,
  #custom-timer-box .button-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
  }

  #cpr-cycle-timer-box .btn,
  #custom-timer-box .btn {
    max-width: 110px;
  }

  #custom-timer-box {
    width: 100%;
    max-width: none;
    margin: 10px auto;
    box-sizing: border-box;
    padding: 15px;
    height: auto;
  }

  #custom-timer-display {
    font-size: 28px !important;
    margin-bottom: 10px;
  }

  /* Specific Button Groups */
  .info-button {
    width: calc(33% - 10px);
    height: 70px;
    font-size: 14px;
  }

  .intervention-group {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }

  .intervention-group button {
    flex: 0 0 auto;
    max-width: 45%;
    width: calc(50% - 8px);
    height: 70px;
    font-size: 14px;
    padding: 5px;
  }

  /* General Mobile Adjustments */
  #resus-timer-display {
    font-size: 28px;
  }
  .adrenaline-container button {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    font-size: 10px;
    padding: 2px 5px;
    width: 100px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }
  .timer-display-container {
    height: 50px;
  }

  #cpr-cycle-timer-display,
  #custom-timer-display {
    font-size: 28px !important;
  }

  .modal {
    width: 95%;
    max-width: none;
  }

  .sticky-header {
    font-size: 16px;
    padding: 8px;
  }

  /* Ensure log area doesn't interfere */
  #left-panel {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: visible;
  }

  .log-box {
    max-height: 300px;
    overflow-y: auto;
  }
}

/* Progress Bar */
.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(212, 237, 218, 0.5);
  border-radius: 8px;
  z-index: 1;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--success-color);
  border-radius: 8px;
  transition: width 1s linear, background 0.5s ease;
  z-index: 2;
}
#reset-cpr-cycle-zero {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  font-size: 12px;
  padding: 2px 5px;
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
}

#reset-cpr-cycle-zero:hover {
  color: #333;
}

#reset-cpr-cycle-zero i {
  font-size: 10px;
}



/* -------------------- ADRENALINE TIMER STYLES -------------------- */
.adrenaline-container {
  position: relative;
  width: 100%;
  height: 20px;
  margin-top: 2px;
}
.adrenaline-container button {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  font-size: 12px;
  padding: 2px 5px;
  background: transparent;
}
#adrenaline-timer-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 12px;
  z-index: 2;
  line-height: 20px;
  color: #333;
}
#adrenaline-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ddd;
  border-radius: 5px;
  z-index: 1;
  overflow: hidden;
}
#adrenaline-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--medication-color);
  border-radius: 5px;
  transition: width 1s linear, background 0.5s ease;
}
.adrenaline-container button {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  font-size: 12px;
  padding: 2px 5px;
}

/* Cycle Ticker Text */
.cycle-ticker {
  font-size: 14px;
  color: #555;
  margin-bottom: 5px;
}

/* Info Panel Layout: Three Rows */
.info-panel {
  margin-top: 20px;
}
.info-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* Log Entry Controls */
.log-controls {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 10;
}
.log-controls button {
  padding: 2px 5px;
  margin-left: 4px;
  font-size: 12px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
}

/* Log Title and Box */
.log-title {
  margin: 10px 0;
  font-size: 18px;
  text-align: center;
  color: var(--primary-color);
}
.log-box {
  flex-grow: 1;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 10px;
  overflow-y: auto;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.1);
}
.log-entry {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 80px 4px 4px; /* Increased right padding to make room for buttons */
  margin-bottom: 4px;
  position: relative;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  min-height: 20px; /* Ensure minimum height for log entries */
  display: flex;
  align-items: center; /* Center content vertically */
}
.log-entry:hover {
  background: #e0e0e0;
}
.log-adrenaline {
  color: var(--medication-color);
}
.log-defib {
  color: var(--danger-color);
}

/* Right Panel */
#right-panel {
  background: #fff;
  padding: 20px;
  overflow-y: auto;
}
.sticky-header {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 10px;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 2px solid var(--primary-color);
  margin-bottom: 20px;
}

/* Top-Right Container */
.top-right-container {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}
.top-right-container .patient-details,
.top-right-container .vital-signs {
  flex: 1;
  background: #f9f9f9;
  padding: 8px;
  margin: 5px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.top-right-container h3 {
  margin-top: 0;
}
.top-right-container .patient-details input,
.top-right-container .vital-signs input {
  width: calc(50% - 10px);
  margin: 5px;
  padding: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

/* Form Inputs */
input[type="text"],
input[type="number"] {
  width: 90%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

/* Export, Clear Log & Reset Buttons */
.export-button {
  background: var(--success-color);
  color: #fff;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.clear-log-button {
  background: #525252;
  color: #fff;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.reset-btn {
  background: var(--danger-color);
}
.action-buttons {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 20px;
}
.action-buttons button {
  margin: 0 5px;
}
  
/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 100vh;
  background: var(--modal-overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  overflow-y: auto;
}
.modal-overlay.hidden {
  display: none;
}
.modal {
  background: var(--modal-background);
  border-radius: 8px;
  width: auto;
  min-width: 300px;
  max-width: 600px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  margin: 0 auto;
}
.modal-header {
  background: var(--primary-color);
  color: #fff;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.modal-body {
  padding: 15px;
}
/* Standard modal form (non–Hs & Ts) */
.modal:not(.hstts-modal) .modal-body label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}
.modal:not(.hstts-modal) .modal-body input,
.modal:not(.hstts-modal) .modal-body select {
  width: 90%;
  max-width: 300px;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}
.modal-footer {
  padding: 10px;
  text-align: right;
  background: #f5f5f5;
}
.modal-button {
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 10px;
}
#modal-submit {
  background: var(--success-color);
  color: #fff;
}
#modal-cancel {
  background: var(--danger-color);
  color: #fff;
}

/* Hs & Ts Modal Specific Formatting */
.modal-body .hstts-container {
  text-align: left;
  width: 100%;
  padding: 10px;
}
.modal-body .hstts-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 0;
  width: 100%;
  text-align: left;
}
.modal-body .hstts-row input[type="checkbox"] {
  margin: 0 10px 0 0;
  width: auto;
  flex: 0 0 auto;
  position: relative;
  left: 0;
}
.modal-body .hstts-row label {
  display: inline;
  margin: 0;
  padding: 0;
  font-weight: normal;
  text-align: left;
  width: auto;
  flex: 1;
}
/*HELP BUTTON*/
#help-button {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--primary-color);
  color: white;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border: none;
}
/* ALS Algorithm Image Styles */
#alg-image-container {
  position: relative;
  width: 300px;  /* Smaller default size */
  margin: 0 auto;
  cursor: pointer;
}

#alg-image-container img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.expand-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.3);  /* More transparent background */
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.expand-indicator i {
  font-size: 16px;
}
.expand-text-show {
  display: inline;
}

.expand-text-hide {
  display: none;
}

#alg-image-container.enlarged .expand-text-show {
  display: none;
}

#alg-image-container.enlarged .expand-text-hide {
  display: inline;
}
/* Fullscreen styles - no transition */
#alg-image-container.enlarged {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 9999;
  background: rgba(0,0,0,0.9);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

#alg-image-container.enlarged img {
  max-width: 95%;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* When enlarged, move indicator back to corner */
#alg-image-container.enlarged .expand-indicator {
  top: 20px;
  right: 20px;
  left: auto;
  transform: none;
  background: rgba(255,255,255,0.6);
  color: black;
}
.guidelines {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
}

.guidelines a {
  display: block;
  margin: 10px auto;
}
/* RESPONSIVE Adjustments */
@media (max-width: 768px) {
  #left-panel,
  #right-panel {
    width: 100%;
    padding: 10px;
  }
  .timers-row {
    flex-wrap: wrap;
  }
  #resus-timer-display {
    font-size: 36px;
  }
  .timer-display-container {
    height: 60px;
  }
  #cpr-cycle-timer-display,
  #custom-timer-display {
    font-size: 28px !important;
  }
  .button-group {
    flex-direction: column;
    align-items: stretch;
  }
  input[type="text"],
  input[type="number"] {
    width: 100%;
  }
  .guidelines img {
    width: 100%;
  }
}

@media (max-width: 768px) {
  #alg-image-container {
    width: 250px;  /* Even smaller on mobile */
  }
}