
/* =========================================================
   MEDICATION REMINDER MODULE
========================================================= */

/* Nav button */
.med-btn {
  margin-left: auto;
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(234, 88, 12, 0.28);
  background: #fed7aa;
  color: #0f172a;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.med-btn:hover { background: #fdba74; }

/* Overlay backdrop */
.med-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  border-radius: 16px;
}
.med-overlay.hidden { display: none; }

/* Card */
.med-card {
  background: #fff;
  border-radius: 16px;
  width: min(92vw, 390px);        /* phone portrait */
  max-height: min(90dvh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* Wider card on desktop / large tablets */
@media (min-width: 600px) {
  .med-card { width: min(88vw, 560px); }
}

/* Panels */
.med-panel {
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 16px;
  gap: 12px;
}

.med-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.med-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.med-close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
  padding: 2px 6px;
}
.med-close-btn:hover { color: #0f172a; }

/* Disclaimer */
.med-disclaimer-text {
  font-size: 13px;
  color: #374151;
  line-height: 1.55;
  background: #fef9c3;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #fde68a;
}

/* OS notification permission prompt */
.med-notif-prompt {
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 8px 12px;
  gap: 10px;
}

.med-notif-text {
  font-size: 13px;
  color: #1d4ed8;
  flex: 1;
}

.med-notif-enable-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.med-notif-enable-btn:hover { background: #1d4ed8; }

/* Persistent note */
.med-persistent-note {
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 6px;
  padding: 6px 10px;
}

/* List */
.med-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.med-empty {
  font-size: 14px;
  color: #94a3b8;
  text-align: center;
  padding: 20px 0;
}

.med-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  gap: 8px;
}

.med-list-info { flex: 1; min-width: 0; }

.med-list-name {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.med-list-sched {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.med-list-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.med-item-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.med-item-edit {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.med-item-edit:hover { background: #bfdbfe; }

.med-item-stop {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}
.med-item-stop:hover { background: #fecaca; }

/* Main actions */
.med-main-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Form panel */
.med-form-panel { gap: 8px; }

.med-form-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.med-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.med-field-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.med-field-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.med-input {
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  width: 100%;
}
.med-input:focus { outline: 2px solid #3b82f6; outline-offset: 1px; border-color: transparent; }

.med-input-short { width: 80px; }
.med-input-date  { width: 160px; }

.med-textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.med-select {
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
}

.med-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: #3b82f6; }

/* Days grid */
.med-days-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.med-day-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}
.med-day-check input { accent-color: #3b82f6; }

/* Times */
.med-times-container { display: flex; flex-direction: column; gap: 4px; }

.med-time-row { display: flex; align-items: center; gap: 6px; }

.med-time-input {
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  width: 120px;
}

.med-time-remove {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.med-time-remove:hover { color: #dc2626; }

/* Toggle switch (correct / change) */
.med-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 8px 12px;
}

.med-toggle-lbl { font-size: 13px; color: #374151; }

.med-toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.med-toggle-switch input { opacity: 0; width: 0; height: 0; }

.med-toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.med-toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.med-toggle-switch input:checked + .med-toggle-slider { background: #3b82f6; }
.med-toggle-switch input:checked + .med-toggle-slider::before { transform: translateX(18px); }

/* Form status */
.med-form-status {
  min-height: 16px;
  font-size: 12px;
  color: #dc2626;
}

/* Form / schedule actions */
.med-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Shared button styles */
.med-primary-btn {
  flex: 1;
  height: 42px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.med-primary-btn:hover { opacity: 0.9; }
.med-primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.med-secondary-btn {
  flex: 1;
  height: 42px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  color: #111827;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.med-secondary-btn:hover { background: #e5e7eb; }

.med-link-btn {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 2px;
}
.med-link-btn:hover { color: #1d4ed8; }

/* Schedule panel */
.med-schedule-panel { gap: 10px; }

.med-schedule-content {
  flex: 1;
  overflow-y: auto;
  font-size: 13px;
}

.med-schedule-header { margin-bottom: 10px; }

.med-schedule-user { font-weight: 700; font-size: 18px; color: #0f172a; }
.med-schedule-meta { font-size: 12px; color: #64748b; margin-top: 2px; }

/* Scroll wrapper — portrait: both axes; landscape phone: none */
.med-schedule-table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.med-schedule-table {
  width: 100%;
  min-width: 560px;   /* portrait: triggers horizontal scroll */
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

/* Column widths (sum = 100%) */
.med-schedule-table th:nth-child(1) { width: 18%; }  /* Medication */
.med-schedule-table th:nth-child(2) { width:  11%; }  /* Dose */
.med-schedule-table th:nth-child(3) { width: 14%; }  /* Schedule */
.med-schedule-table th:nth-child(4) { width: 14%; }  /* Directions */
.med-schedule-table th:nth-child(5) { width: 10%; }  /* Start */
.med-schedule-table th:nth-child(6) { width: 17%; }  /* Until */
.med-schedule-table th:nth-child(7) { width: 16%; }  /* Notes */

.med-schedule-table th,
.med-schedule-table td {
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: break-word;
}

.med-schedule-table th {
  background: #f1f5f9;
  font-weight: 600;
  color: #374151;
  font-size: 11px;
  text-transform: uppercase;
}

/* Landscape phone: table fills card, no horizontal scroll needed */
@media (orientation: landscape) and (max-height: 500px) {
  .med-schedule-table { min-width: 0; }
}

.med-schedule-footer {
  margin-top: 10px;
  font-size: 11px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 6px;
  padding: 6px 10px;
}

/* Pills */
.med-pill {
  display: inline-block;
  border-radius: 9999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.med-pill-green { background: #dcfce7; color: #16a34a; }
.med-pill-amber { background: #fef3c7; color: #92400e; }

/* Schedule panel — wider in smartphone landscape */
@media (orientation: landscape) and (max-height: 480px) {
  .med-card--schedule {
    width: min(96vw, 760px);
    max-height: 90dvh;
  }
}

