/* PK/INR Diary - Custom Styles */

:root {
  --primary: #1474A7;
  --primary-hover: #0f5a82;
  --primary-focus: rgba(20, 116, 167, 0.125);
  --success: #2d8659;
  --warning: #d97706;
  --danger: #dc2626;
}

[data-theme="dark"] {
  --primary: #4A9FCC;
  --primary-hover: #1474A7;
  --primary-focus: rgba(74, 159, 204, 0.125);
}

/* Hero section on landing page */
.hero {
  max-width: 800px;
  margin: 2rem auto;
}

.hero header {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* Disclaimer box */
.disclaimer {
  background: var(--primary-focus);
  border-left: 4px solid var(--primary);
  padding: 1rem;
  margin: 2rem 0;
  border-radius: 0.25rem;
}

.disclaimer strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

/* Messages */
.message {
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0.25rem;
  transition: opacity 0.5s ease;
}

.message.success {
  background: rgba(45, 134, 89, 0.1);
  border-left: 4px solid var(--success);
  color: var(--success);
}

.message.error {
  background: rgba(220, 38, 38, 0.1);
  border-left: 4px solid var(--danger);
  color: var(--danger);
}

.message.info {
  background: rgba(20, 116, 167, 0.1);
  border-left: 4px solid var(--primary);
  color: var(--primary);
}

.message.warning {
  background: rgba(217, 119, 6, 0.1);
  border-left: 4px solid var(--warning);
  color: var(--warning);
}

[data-theme="dark"] .message.success {
  background: rgba(45, 134, 89, 0.2);
}

[data-theme="dark"] .message.error {
  background: rgba(220, 38, 38, 0.2);
}

[data-theme="dark"] .message.info {
  background: rgba(74, 159, 204, 0.2);
}

[data-theme="dark"] .message.warning {
  background: rgba(217, 119, 6, 0.2);
}

/* Development mode link box */
.dev-link-box {
  background: rgba(255, 193, 7, 0.1);
  border: 2px dashed #ff9800;
  padding: 1.5rem;
  margin: 1rem 0;
  border-radius: 0.5rem;
  text-align: center;
}

.dev-link {
  display: block;
  padding: 1rem;
  background: var(--card-background-color);
  border: 1px solid var(--muted-border-color);
  border-radius: 0.25rem;
  margin: 1rem 0;
  word-break: break-all;
  font-family: monospace;
  font-size: 0.875rem;
}

.dev-link:hover {
  background: var(--primary-focus);
}

/* Features list */
.features {
  margin: 3rem 0;
}

.features h2 {
  margin-bottom: 1.5rem;
}

.features ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.features li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--muted-border-color);
}

.features li:last-child {
  border-bottom: none;
}

/* Login section */
.login-section {
  margin: 3rem 0;
  padding: 2rem;
  background: var(--card-background-color);
  border-radius: 0.5rem;
}

/* Dashboard specific styles */
nav.container-fluid {
  padding: 1rem 2rem;
  background: var(--card-background-color);
  border-bottom: 1px solid var(--muted-border-color);
  margin-bottom: 2rem;
}

/* Weekly plan grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

.week-day {
  text-align: center;
  padding: 1rem;
  background: var(--card-background-color);
  border-radius: 0.25rem;
  border: 1px solid var(--muted-border-color);
}

.day-name {
  font-size: 0.875rem;
  color: var(--muted-color);
  margin-bottom: 0.5rem;
}

.day-dose {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

@media (max-width: 768px) {
  .week-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 480px) {
  .week-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Today's dosage */
.dosage-info {
  padding: 1rem;
  background: var(--primary-focus);
  border-radius: 0.25rem;
  margin: 1rem 0;
}

.dosage-taken {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(45, 134, 89, 0.1);
  border-left: 4px solid var(--success);
  border-radius: 0.25rem;
}

/* Test result */
.test-info {
  padding: 1rem;
  background: var(--card-background-color);
  border-radius: 0.25rem;
  margin: 1rem 0;
}

.inr-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

/* INR value colors based on range */
.inr-in-range {
  color: var(--success);
}

.inr-warning {
  color: var(--warning);
}

.inr-danger {
  color: var(--danger);
}

/* Article header flexbox for button alignment */
article header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

article header h2 {
  margin: 0;
}

.export-buttons {
  display: flex;
  gap: 0.5rem;
}

.export-buttons button {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Text centering utility */
.text-center {
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }
  
  nav.container-fluid ul {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* Print styles for PDF export */
@media print {
  nav,
  button,
  .outline {
    display: none !important;
  }
  
  article {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Accessibility: Focus indicators */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Loading states */
[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.7;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8); /* Much darker backdrop */
  backdrop-filter: blur(3px); /* Stronger blur effect */
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  /* Explicit solid backgrounds for light and dark mode */
  background-color: #fff; /* Light mode: solid white */
  margin: 2rem;
  padding: 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--muted-border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

/* Dark mode: solid dark background */
@media (prefers-color-scheme: dark) {
  .modal-content {
    background-color: #1a1f2e; /* Solid dark blue-grey */
    border-color: #2d3748;
  }
}

/* Force solid background when data-theme is set */
[data-theme="light"] .modal-content {
  background-color: #fff;
}

[data-theme="dark"] .modal-content {
  background-color: #1a1f2e;
  border-color: #2d3748;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--muted-color);
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--color);
  background-color: var(--secondary-hover);
  border-radius: 0.25rem;
}

/* Charts will go here */
.chart-container {
  position: relative;
  height: 300px;
  margin: 1rem 0;
}

canvas {
  max-width: 100%;
}

/* 7-day history grid */
.history-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

.history-day {
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: var(--card-background-color);
  border-radius: 0.25rem;
  border: 1px solid var(--muted-border-color);
  transition: all 0.2s ease;
}

.history-day.clickable {
  cursor: pointer;
}

.history-day.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  border-color: var(--primary);
  background: var(--card-sectionning-background-color);
}

.history-day.today {
  border-color: var(--primary);
  border-width: 2px;
}

.history-day-name {
  font-size: 0.75rem;
  color: var(--muted-color);
  margin-bottom: 0.25rem;
}

.history-day-num {
  font-size: 1.25rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.history-status {
  font-size: 1.5rem;
  margin: 0.5rem 0;
}

.status-logged {
  color: var(--success);
}

.status-missing {
  color: var(--danger);
}

.status-na {
  color: var(--muted-color);
}

.history-dose {
  font-size: 0.875rem;
  color: var(--muted-color);
  margin-top: 0.25rem;
}

@media (max-width: 768px) {
  .history-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 480px) {
  .history-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .history-day-name {
    font-size: 0.7rem;
  }
  
  .history-day-num {
    font-size: 1rem;
  }
}

/* Test list */
.test-list {
  margin-top: 1rem;
  border-top: 1px solid var(--muted-border-color);
}

.test-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--muted-border-color);
  align-items: center;
}

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

.test-date {
  font-size: 0.875rem;
  color: var(--muted-color);
}

.test-value {
  font-size: 1.25rem;
  font-weight: bold;
  text-align: center;
}

.test-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted-color);
  text-align: right;
}

details {
  margin-top: 1rem;
}

details summary {
  cursor: pointer;
  padding: 0.5rem;
  background: var(--card-background-color);
  border-radius: 0.25rem;
  user-select: none;
}

details summary:hover {
  background: var(--primary-focus);
}

details[open] summary {
  margin-bottom: 0.5rem;
}

/* INR Chart */
.chart-wrapper {
  margin: 1rem 0;
  position: relative;
}

#inr-chart {
  display: block;
  max-width: 100%;
  height: auto;
}

.inr-chart-tooltip {
  position: fixed;
  background: var(--card-background-color);
  border: 1px solid var(--muted-border-color);
  padding: 0.75rem;
  border-radius: 0.25rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  pointer-events: none;
  z-index: 1000;
  font-size: 0.875rem;
  line-height: 1.5;
  display: none;
}

[data-theme="dark"] .inr-chart-tooltip {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}