/*
 * Muonjaro Planner Styles
 *
 * A clean and professional layout with subtle colour accents for each pen. The
 * design uses a card-based structure to separate functional sections. It
 * adapts gracefully to smaller screens via responsive flexbox and stack
 * behaviours. Colours for pens are assigned via CSS variables on each
 * button, allowing quick adjustments to match official pen colours.
 */

/* Global reset and typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Taskbar Styles */
.taskbar {
  background-color: #2c3e50;
  color: white;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.app-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-left: 1rem;
}

/* Burger Menu Styles */
.burger-menu {
  position: relative;
  display: inline-block;
  z-index: 1001;
}

.burger-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 21px;
  cursor: pointer;
  padding: 5px;
}

.burger-icon span {
  display: block;
  height: 3px;
  width: 100%;
  background-color: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Dropdown Menu */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #fff;
  min-width: 200px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  border-radius: 4px;
  top: 100%;
  left: 0;
  margin-top: 5px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.burger-menu:hover .dropdown-content,
.burger-menu:focus-within .dropdown-content {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.dropdown-content a {
  color: #2c3e50;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  transition: background-color 0.2s;
}

.dropdown-content a:hover {
  background-color: #f1f1f1;
}

/* Body Styles */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.5;
  background: #f7f8fa;
  color: #2c3e50;
  padding: 0 1rem 1rem 1rem;
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #34495e;
}

main {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Card container used for each section */
.card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1rem;
}

/* PEN BUTTONS */
.pen-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pen-btn {
  flex: 1 1 calc(33% - 1rem);
  min-width: 100px;
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  color: #fff;
  transition: transform 0.1s ease-in-out, box-shadow 0.1s;
  background: var(--pen-color, #3498db);
}

.pen-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.pen-btn.selected {
  /* Remove green border and glow for a cleaner selected state. */
  position: relative;
  transform: translateY(-2px); /* Slight lift effect */
}

.pen-btn .selected-text {
  font-size: 0.8em;
  margin-left: 4px;
  font-weight: bold;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* DOSE SELECTION */
.dose-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.dose-btn {
  flex: 1 1 calc(20% - 1rem);
  min-width: 100px;
  padding: 0.6rem;
  border: 1px solid #bdc3c7;
  background: #ecf0f1;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
}

.dose-btn:hover:not([disabled]) {
  background: #dfe6e9;
}

.dose-btn.selected {
  background: var(--selected-pen-color, #3498db);
  color: #fff;
  border: 2px solid #00ff00;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.6);
  transform: translateY(-2px);
  position: relative;
  z-index: 1;
}

.dose-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dose input row */
.dose-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.dose-inputs label {
  font-size: 0.9rem;
  margin-right: 0.25rem;
}

#doseInput {
  flex: 1;
  min-width: 120px;
  padding: 0.4rem;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Toggle switch for advanced precision */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: #3498db;
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.8rem;
  color: #7f8c8d;
  margin-left: 0.25rem;
}

/* RESULTS */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
  align-items: center;
}

.results-grid div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid #ecf0f1;
}

.results-grid div:last-child {
  border-bottom: none;
}

.results-grid span {
  font-weight: 500;
  color: #2c3e50;
}

.results-grid strong {
  font-weight: 600;
  color: #16a085;
}

.hidden {
  display: none;
}

/* REPORT STYLES */
#reportResults {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

#reportDisclaimer {
  border-left: 4px solid #e74c3c;
  background-color: #fdecea;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}
#reportDisclaimer strong {
  color: #c0392b;
}

/* SCHEDULE */
.schedule-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.schedule-controls label {
  margin-right: 0.25rem;
}

.schedule-controls input[type="date"],
.schedule-controls input[type="number"],
.schedule-controls select {
  padding: 0.3rem;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  min-width: 120px;
  font-size: 0.9rem;
}

.info-icon {
  font-size: 1rem;
  margin-left: 0.25rem;
  color: #7f8c8d;
  cursor: help;
}

.schedule-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #ecf0f1;
  border-radius: 4px;
  padding: 0.5rem;
  background: #fafafa;
  font-size: 0.9rem;
}

.schedule-item {
  padding: 0.2rem 0;
  border-bottom: 1px solid #ecf0f1;
}

.schedule-item:last-child {
  border-bottom: none;
}

/* EXPORT */
.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.export-buttons button {
  flex: 1 1 calc(33% - 1rem);
  min-width: 120px;
  padding: 0.6rem;
  border: none;
  background: #95a5a6;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
}

.export-buttons button:hover:not([disabled]) {
  background: #7f8c8d;
}

.export-buttons button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Report styling (hidden by default) */
#report {
  background: #fff;
  color: #2c3e50;
  padding: 1rem;
  margin-top: 1rem;
  border: 1px solid #ecf0f1;
  border-radius: 4px;
  font-size: 0.9rem;
}

#report h2 {
  margin-top: 0;
}

#report ul {
  list-style-type: decimal;
  margin-left: 1.5rem;
}

/* Responsive behaviour */
@media (max-width: 600px) {
  .pen-btn,
  .dose-btn,
  .export-buttons button {
    flex: 1 1 100%;
    min-width: unset;
  }
  .schedule-controls input[type="date"],
  .schedule-controls input[type="number"],
  .schedule-controls select {
    flex: 1 1 100%;
    min-width: unset;
  }
}

/* Chart container to constrain canvas size and prevent vertical overflow */
.chart-container {
  width: 100%;
  max-width: 1000px;
  height: 600px;
  margin: 20px auto;
  overflow: hidden;
  border: 1px solid #ddd;
  background-color: #fafafa;
  padding: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

/* Ensure canvases stretch to fill the container without causing page scroll */
canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 600px;
  display: block;
}

/* ------------------------------------------------------------------- */
/* New dynamic dose selection styles                                  */
/* These classes support the new row of buttons that appear for each   */
/* pen strength. Each button colour is derived from its milligram      */
/* value via CSS variables set in JavaScript.                         */

.dose-buttons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.dose-choice-btn {
  flex: 1 1 calc(33% - 1rem);
  min-width: 100px;
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  background: var(--dose-color, #ecf0f1);
  color: #ffffff;
  transition: background 0.1s ease, transform 0.1s ease;
}

.dose-choice-btn:hover {
  transform: translateY(-2px);
}

.dose-choice-btn.selected {
  /* Remove green outline and glow when a dose is selected */
  transform: translateY(-2px);
}

.custom-dose-row {
  margin-top: 0.5rem;
}

/* Dimmed state for unselected buttons. When a pen or dose is chosen,
   the remaining options are visually de‑emphasised via reduced
   opacity and a slight greyscale. They remain clickable so users can
   change their mind. */
.pen-btn.dimmed,
.dose-choice-btn.dimmed {
  opacity: 0.4;
  filter: grayscale(40%);
}

.custom-dose {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  background: #f0f3f4;
  font-size: 0.9rem;
}

.results-instructions {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-size: 1rem;
  color: #2c3e50;
  line-height: 1.8;
  padding: 0.5rem 0;
}

.results-instructions.refined {
  max-width: 500px;
  margin: 0 auto;
  text-align: left;
  font-size: 1rem;
  line-height: 1.8;
}

#results h2 {
  text-align: left !important;
  padding-left: 0.25rem;
}

/* --- Enhanced Results Display --- */
.results-divider {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid #ddd;
}

.dose-block {
  margin-bottom: 1rem;
}

.dose-block h3 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
  color: #34495e;
  border-left: 4px solid #1abc9c;
  padding-left: 0.5rem;
}
