/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  min-height: 100vh;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* App Header */
.app-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 101;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: opacity 0.2s;
}

.app-title:hover {
  opacity: 0.8;
}

/* Navigation */
.nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-link {
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
}

.nav-link:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.nav-link.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.15);
}

.nav-emoji {
  font-size: 24px;
  line-height: 1;
}

/* Container */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

@media (max-width: 768px) {
  #app {
    padding: 16px;
  }
}

/* Common components */
.page-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 24px;
  color: #1e293b;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #1e293b;
}

.card {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.6);
  transition: all 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* Form elements */
.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  transition: border-color 0.2s;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.textarea {
  min-height: 100px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-secondary);
}

/* Radio buttons */
.radio-group {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.radio-option {
  position: relative;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.radio-option label {
  display: block;
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  background: var(--bg-primary);
}

.radio-option input[type="radio"]:checked + label {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.radio-option label:hover {
  border-color: var(--primary);
}

/* Buttons */
.button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.button-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.button-secondary:hover {
  background: var(--primary-light);
}

.button-danger {
  background: var(--danger);
}

.button-danger:hover {
  background: #dc2626;
}

.button-success {
  background: var(--success);
}

.button-success:hover {
  background: #059669;
}

.button-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag {
  padding: 6px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
  background: var(--bg-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.tag.active {
  border-color: currentColor;
  box-shadow: var(--shadow-sm);
}

.tag-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

/* Mood selector */
.mood-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.mood-option {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
}

.mood-option:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.mood-option.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  font-weight: 600;
  transform: scale(1.05);
}

.mood-emoji {
  font-size: 20px;
}

.mood-name {
  font-size: 14px;
  font-weight: 500;
}

/* Suggestions */
.suggestions {
  margin-bottom: 16px;
}

.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-item {
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateX(4px);
}

.suggestion-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Calendar */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 768px) {
  .calendar-header {
    flex-direction: column;
  }

  .calendar-header button {
    width: 100%;
  }
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-day {
  min-height: 100px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calendar-day:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

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

.calendar-day.selected {
  background: rgba(37, 99, 235, 0.15);
  backdrop-filter: blur(10px);
  border-color: var(--primary);
  border-width: 3px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.calendar-day.has-data {
  background: rgba(209, 250, 229, 0.7);
  backdrop-filter: blur(8px);
  border-color: var(--success);
}

.selected-date-section {
  border-left: 4px solid var(--primary);
  padding-left: 12px;
  background: rgba(37, 99, 235, 0.05);
  border-radius: var(--radius-md);
}

.calendar-day.other-month {
  color: var(--text-secondary);
  background: rgba(248, 250, 252, 0.5);
  backdrop-filter: blur(6px);
}

.calendar-day-header {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 4px;
  text-align: center;
}

.calendar-day-meals {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.calendar-meal-item {
  font-size: 9px;
  line-height: 1.2;
  padding: 2px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .calendar-day {
    min-height: 80px;
    padding: 2px;
  }

  .calendar-day-header {
    font-size: 12px;
  }

  .calendar-meal-item {
    font-size: 8px;
  }
}

/* Meal entries */
.meal-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.meal-item {
  padding: 16px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.meal-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(2px);
}

.meal-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.meal-type {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.meal-actions {
  display: flex;
  gap: 8px;
}

.meal-content {
  margin-bottom: 8px;
  line-height: 1.6;
}

.meal-mood {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  margin-top: 8px;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px;
  background: rgba(239, 246, 255, 0.8);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Loading and error states */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.error {
  padding: 16px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid #fecaca;
  font-weight: 500;
}

.success {
  padding: 16px;
  background: #d1fae5;
  color: #065f46;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid #a7f3d0;
  font-weight: 500;
}

/* Grid layouts */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (min-width: 1024px) {
  .grid-2-desktop {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Utilities */
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* Enhanced tag selection feedback */
.tag-selectable {
  cursor: pointer;
  transition: all 0.2s;
}

.tag-selectable.active {
  background: currentColor;
  color: white !important;
  font-weight: 600;
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

/* Floating add button */
.floating-add-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-add-button:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.floating-add-button:active {
  transform: scale(1.05);
}
