/* CSS Variables for Dark Blue + Electric Blue Theme */
:root {
  --bg: #0b1220;
  --surface: #0f1a2b;
  --primary: #0d47a1;
  --accent: #00b3ff;
  --text: #e6eef8;
  --muted: #9fb3c8;
  --border: #1f2b42;
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-light: rgba(0, 179, 255, 0.1);
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Light mode support (optional) */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-light: rgba(0, 179, 255, 0.2);
  }
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Container and Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-4);
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.025em;
}

.date-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.date-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  justify-content: center;
}

.date-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-base);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.date-picker:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--shadow-light);
}

.weekday-toggles {
  display: flex;
  gap: var(--space-1);
  justify-content: center;
  flex-wrap: nowrap;
  max-width: 100%;
}

.weekday-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Remove default tap highlights on mobile */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  
  /* Ensure round shape is maintained */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.weekday-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.weekday-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.weekday-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--shadow-light);
}

/* Mobile-specific tap styles */
.weekday-btn:active {
  background: var(--accent);
  color: var(--bg);
  transform: scale(0.95);
}

.weekday-btn.active:active {
  background: #0099cc;
  transform: scale(0.95);
}

/* Clear All Button */
.clear-all-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  
  /* Remove default button styles */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.clear-all-btn:hover {
  background: #d32f2f;
  border-color: #d32f2f;
  transform: translateY(-1px);
}

.clear-all-btn:active {
  transform: translateY(0) scale(0.98);
}

.clear-all-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.3);
}

.clear-icon {
  font-size: var(--font-size-base);
}

.clear-text {
  font-weight: 600;
}

/* Clear button visibility by screen size */
.clear-all-desktop {
  display: none; /* Hide desktop button by default */
}

.clear-all-mobile {
  display: flex; /* Show mobile button by default */
  padding: var(--space-3);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  background: #ff4444;
  border-color: #ff4444;
}

.clear-all-mobile:hover {
  background: #ff3333;
  border-color: #ff3333;
}

.clear-all-mobile .clear-icon {
  font-size: 1.1rem;
  filter: brightness(1.2) contrast(1.1);
}

/* Show desktop button on larger screens */
@media (min-width: 768px) {
  .clear-all-desktop {
    display: flex; /* Show desktop button */
  }
  
  .clear-all-mobile {
    display: none; /* Hide mobile button */
  }
}

/* Back to Top Button */
.back-to-top-btn {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  width: 3rem;
  height: 3rem;
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-full);
  color: var(--bg);
  font-size: var(--font-size-lg);
  font-weight: bold;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 179, 255, 0.3);
  opacity: 0;
  visibility: hidden;
  
  /* Remove default button styles */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* Hide by default, only show on mobile */
  display: none;
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top-btn:hover {
  background: #0099cc;
  border-color: #0099cc;
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 179, 255, 0.4);
}

.back-to-top-btn:active {
  transform: translateX(-50%) translateY(0) scale(0.95);
}

.back-to-top-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 179, 255, 0.5);
}

.back-to-top-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Show back to top button only on mobile */
@media (max-width: 767px) {
  .back-to-top-btn {
    display: flex;
  }
}

/* Main Content Layout */
.main-content {
  display: grid;
  gap: var(--space-8);
}

.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Sections */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 2px 8px var(--shadow);
}

.section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Top 3 Section */
.top-three-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.top-three-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: rgba(0, 179, 255, 0.05);
  border: 1px solid rgba(0, 179, 255, 0.2);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
}

.top-three-item:hover {
  background: rgba(0, 179, 255, 0.1);
}

.top-three-item.done {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
}

.top-three-checkbox {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-three-checkbox:hover {
  border-color: #0099cc;
  transform: scale(1.05);
}

.top-three-checkbox:checked {
  background: var(--success);
  border-color: var(--success);
}

.top-three-checkbox:checked::after {
  content: '✓';
  color: white;
  font-size: 0.875rem;
  font-weight: bold;
  line-height: 1;
}

.top-three-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--font-size-base);
  outline: none;
  transition: all var(--transition-fast);
}

.top-three-input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
}

/* Strike-through effect for completed items */
.top-three-item.done .top-three-input {
  text-decoration: line-through;
  opacity: 0.7;
  color: var(--muted);
}

.validation-message {
  font-size: var(--font-size-sm);
  color: var(--warning);
  margin-top: var(--space-2);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.validation-message.show {
  opacity: 1;
}

/* To-Do Section */
.todo-input-container {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.todo-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-base);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.todo-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--shadow-light);
}

.todo-input::placeholder {
  color: var(--muted);
}

.add-btn {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-full);
  color: var(--bg);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-btn:hover {
  background: #0099cc;
  transform: scale(1.05);
}

.add-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--shadow-light);
}

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.todo-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.todo-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

.todo-item.done {
  opacity: 0.6;
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}

.todo-checkbox:checked {
  background: var(--success);
  border-color: var(--success);
}

.todo-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
}

.todo-text {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--font-size-base);
  outline: none;
  resize: none;
}

.todo-text:focus {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
}

.todo-delete {
  width: 1.5rem;
  height: 1.5rem;
  background: var(--error);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.todo-item:hover .todo-delete {
  opacity: 1;
}

.todo-delete:hover {
  background: #d32f2f;
  transform: scale(1.1);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: var(--space-8) var(--space-4);
}

.empty-state.hidden {
  display: none;
}

/* Notes Section */
.notes-textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  padding: var(--space-4);
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--shadow-light);
}

.notes-textarea::placeholder {
  color: var(--muted);
}

/* Schedule Section */
.schedule-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.schedule-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

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

.schedule-time {
  font-weight: 600;
  color: var(--accent);
  min-width: 3rem;
  font-size: var(--font-size-sm);
}

.schedule-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--font-size-base);
  outline: none;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.schedule-input:focus {
  background: rgba(255, 255, 255, 0.05);
}

.schedule-input::placeholder {
  color: var(--muted);
  font-style: italic;
}

/* Meals and Water Section */
.meals-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

.meals-grid {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.meal-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.meal-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meal-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-base);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.meal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--shadow-light);
}

.meal-input::placeholder {
  color: var(--muted);
}

.water-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.water-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.water-dots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.water-dot {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.water-dot:hover {
  background: rgba(0, 179, 255, 0.2);
  transform: scale(1.1);
}

.water-dot.filled {
  background: var(--accent);
}

.water-dot.filled::after {
  content: '💧';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
}

.water-count {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--accent);
}

/* Responsive Design */
@media (min-width: 768px) {
  .container {
    padding: var(--space-6);
  }
  
  .header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .title {
    text-align: left;
  }
  
  .date-controls {
    flex-direction: row;
    align-items: center;
    gap: var(--space-6);
  }
  
  .main-content {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-10);
  }
  
  .meals-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }
  
  .meal-item:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }
  
  .meal-item:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }
  
  .meal-item:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
  }
}

@media (min-width: 1024px) {
  .container {
    padding: var(--space-8);
  }
  
  .section {
    padding: var(--space-8);
  }
  
  .title {
    font-size: var(--font-size-3xl);
  }
  
  .main-content {
    gap: var(--space-12);
  }
}

/* Animation for smooth transitions */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section {
  animation: fadeIn 0.3s ease-out;
}

/* Focus styles for better accessibility */
*:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #ffffff;
    --muted: #ffffff;
  }
}

/* Mobile-specific improvements */
@media (max-width: 767px) {
  .weekday-btn {
    /* Ensure minimum tap target size on mobile */
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Improve touch targets for other interactive elements */
  .water-dot,
  .add-btn,
  .todo-delete {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Smaller checkboxes on mobile but still tappable */
  .top-three-checkbox,
  .todo-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    min-height: 1.25rem;
    
    /* Add padding around checkbox for easier tapping */
    padding: 0.5rem;
    margin: -0.5rem;
  }
  
  .top-three-checkbox:checked::after,
  .todo-checkbox:checked::after {
    font-size: 0.75rem;
  }
  
  /* Ensure checkbox containers have proper spacing */
  .top-three-item,
  .todo-item {
    padding: var(--space-4);
  }
  
  /* Better spacing and sizing for mobile */
  .weekday-toggles {
    gap: var(--space-1);
    padding: 0 var(--space-2);
  }
  
  .weekday-btn {
    width: 2rem;
    height: 2rem;
    font-size: var(--font-size-xs);
    flex-shrink: 0;
  }
}

/* Extra compact for very small screens */
@media (max-width: 375px) {
  .weekday-toggles {
    gap: 0.125rem;
    padding: 0 var(--space-1);
  }
  
  .weekday-btn {
    width: 1.875rem;
    height: 1.875rem;
    font-size: 0.75rem;
  }
}

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