:root {
  --bg: #f7fbfc;
  --card: #ffffff;
  --muted: #6b7280;
  --accent: #0ea5a4; /* teal */
  --accent-2: #06b6d4; /* cyan */
  --success: #10b981;
  --danger: #ef4444;
  --glass: rgba(255, 255, 255, 0.6);
  --radius: 12px;
  --shadow: 0 6px 18px rgba(12, 16, 20, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial;
}

.patient-banner {
  background: #e0f9ff;
  border-left: 4px solid #06b6d4;
  padding: 16px;
  margin-bottom: 10px;
  border-radius: 8px;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%);
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Container */
.container {
  width: clamp(300px, 92%, 1000px);
  margin: 0 auto;
  padding: 20px;
}

/* Topbar */
.topbar {
  padding: 16px 0;
  margin-inline: auto;
  width: min(92vw, 1100px);
  border-bottom: 1px solid rgba(2, 6, 23, 0.04);
  background: linear-gradient(
    90deg,
    rgba(6, 182, 212, 0.06),
    rgba(16, 185, 129, 0.03)
  );
}
.logo {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent-2);
  letter-spacing: 0.6px;
}
.tag {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Controls */
.controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 22px 0;
}
.btn {
  background: transparent;
  border: 1px solid rgba(2, 6, 23, 0.06);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.btn:hover {
  transform: translateY(-2px);
}
.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
}
.btn.success {
  background: var(--success);
  color: white;
  border: none;
}
.btn.danger {
  background: var(--danger);
  color: white;
  border: none;
}

.toggles {
  display: flex;
  gap: 10px;
  align-items: center;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}
.toggle input {
  width: 16px;
  height: 16px;
}

/* Reminders grid */
.reminders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.12s ease;
}
.card:hover {
  transform: translateY(-4px);
}
.card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.medicine {
  font-weight: 700;
  font-size: 1.05rem;
  color: #04263a;
}
.meta {
  color: var(--muted);
  font-size: 0.92rem;
}
.time {
  font-weight: 700;
  color: #0f172a;
  background: linear-gradient(90deg, #ecfeff, #f0fff4);
  padding: 6px 10px;
  border-radius: 8px;
}
.status {
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
}
.status.pending {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-2);
}
.status.taken {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.status.missed {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.card-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 6px;
}
.small-actions {
  display: flex;
  gap: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.35);
  z-index: 50;
}
.modal.hidden {
  display: none;
}
.modal-content {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.18);
  position: relative;
}
.modal-content.small {
  max-width: 420px;
}
.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}

/* Form */
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  color: #0f172a;
}
.form input[type="text"],
.form input[type="time"] {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(2, 6, 23, 0.06);
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

/* Footer */
.footer {
  margin: 28px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .toggles {
    justify-content: space-between;
  }
}

.days-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 10px;
}

.days-checkboxes label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  background-color: #f5f5f5;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.days-checkboxes input {
  accent-color: #00b8d4; /* Matches the save button color */
}

.dose-fields {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dose-fields label {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* === Mobile centering & overflow fix (iOS-friendly) === */
html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
}
*,
*::before,
*::after {
  box-sizing: inherit;
}

/* Prevent any accidental sideways scroll */
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Use dynamic viewport height on iOS; avoid 100vh jumpiness */
body {
  min-height: 100dvh; /* iOS 16+ */
  background-color: var(--bg, #f0fbff);
}

/* Respect iPhone notch safe areas */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Make primary wrappers truly centered */
.wrap,
.container,
.form-card,
.auth-card {
  margin-left: auto;
  margin-right: auto;
  max-width: 600px; /* tweak if you want wider/narrower */
  width: min(92vw, 600px); /* keeps it nicely centered on small screens */
}

/* Images/SVGs never overflow */
img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* If you used body-centered layouts elsewhere, force blocks instead */
@media (max-width: 768px) {
  /* Remove conflicting body centering if present */
  body {
    display: block !important;
  }
}
