* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header .subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
}

main {
  max-width: 1400px;
  margin: 0 auto;
}

.controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
}

.btn-secondary {
  background: white;
  color: #764ba2;
}

.btn-secondary:hover {
  background: #f0f0f0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.last-update {
  color: white;
  font-size: 0.9rem;
  opacity: 0.8;
}

.loading {
  text-align: center;
  padding: 60px;
  color: white;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  background: #ff6b6b;
  color: white;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.week-planner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.day-card {
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.day-card h2 {
  color: #764ba2;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #eee;
  display: flex;
  align-items: center;
  gap: 10px;
}

.day-card h2 .day-icon {
  font-size: 1.5rem;
}

.meal-slot {
  margin-bottom: 15px;
}

.meal-slot label {
  display: block;
  font-weight: 600;
  color: #555;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

.meal-slot select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s;
}

.meal-slot select:focus {
  outline: none;
  border-color: #764ba2;
}

.meal-slot select:hover {
  border-color: #aaa;
}

.meal-slot select optgroup {
  font-weight: 700;
  font-style: normal;
  color: #764ba2;
  background: #f8f9fa;
  padding: 8px 0;
}

.meal-slot select option {
  font-weight: 400;
  color: #333;
  padding: 8px 12px;
  background: white;
}

.meal-slot select option:hover {
  background: #f0f0f0;
}

.day-totals {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px;
  border-radius: 10px;
  margin-top: 15px;
}

.day-totals h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  opacity: 0.9;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.total-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.total-item .label {
  opacity: 0.8;
}

.total-item .value {
  font-weight: 700;
}

.total-item.calories {
  grid-column: 1 / -1;
  font-size: 1.1rem;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.3);
  margin-top: 5px;
}

.summary {
  background: white;
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.summary h2 {
  color: #764ba2;
  margin-bottom: 20px;
  text-align: center;
}

.summary-content {
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.summary-table th,
.summary-table td {
  padding: 12px 15px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.summary-table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
}

.summary-table th:first-child {
  border-radius: 10px 0 0 0;
}

.summary-table th:last-child {
  border-radius: 0 10px 0 0;
}

.summary-table tr:hover {
  background: #f8f9fa;
}

.summary-table .day-name {
  font-weight: 600;
  color: #764ba2;
  text-align: left;
}

.summary-table tfoot td {
  font-weight: 700;
  background: #f0f0f0;
  color: #333;
}

.summary-table tfoot tr:first-child td:first-child {
  border-radius: 0 0 0 10px;
}

.summary-table tfoot tr:first-child td:last-child {
  border-radius: 0 0 10px 0;
}

footer {
  text-align: center;
  color: white;
  margin-top: 30px;
  padding: 20px;
  opacity: 0.8;
}

footer a {
  color: white;
  text-decoration: underline;
}

/* Meal slot icons */
.meal-slot[data-slot="snidane"] label::before { content: "🌅 "; }
.meal-slot[data-slot="obed"] label::before { content: "🍽️ "; }
.meal-slot[data-slot="svacina"] label::before { content: "🍎 "; }
.meal-slot[data-slot="vecere"] label::before { content: "🌙 "; }
.meal-slot[data-slot="dezert"] label::before { content: "🍰 "; }

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }

  .week-planner {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .day-card,
  .summary {
    background: #1a1a2e;
    color: #eee;
  }

  .day-card h2,
  .summary h2 {
    color: #a78bfa;
  }

  .meal-slot label {
    color: #ccc;
  }

  .meal-slot select {
    background: #16213e;
    color: #eee;
    border-color: #333;
  }

  .summary-table tr:hover {
    background: #16213e;
  }

  .summary-table tfoot td {
    background: #16213e;
    color: #eee;
  }
}

/* Week Selector */
.week-selector {
  margin-bottom: 25px;
}

.week-selector-container {
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.week-selector-container h3 {
  color: #764ba2;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.week-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.week-btn {
  padding: 12px 20px;
  border: 2px solid #764ba2;
  border-radius: 10px;
  background: white;
  color: #764ba2;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.week-btn:hover {
  background: #f0e6ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(118, 75, 162, 0.2);
}

.week-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
}

.no-data {
  text-align: center;
  color: white;
  font-size: 1.2rem;
  padding: 40px;
}

/* Dark mode for week selector */
@media (prefers-color-scheme: dark) {
  .week-selector-container {
    background: #1a1a2e;
  }

  .week-selector-container h3 {
    color: #a78bfa;
  }

  .week-btn {
    background: #16213e;
    color: #a78bfa;
    border-color: #a78bfa;
  }

  .week-btn:hover {
    background: #2a2a4e;
  }

  .week-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
  }
}
