<!DOCTYPE html>
<html lang="sv" ng-app="mealMenuApp">
<head>
  <meta charset="utf-8" />
  <title>Veckomeny</title>

  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular-sanitize.js"></script>
  <script src="~/js/menu.js"></script>

  <link rel="stylesheet" href="~/css/menu.css" />
</head>
<body ng-controller="MealMenuController">
  <div class="meal-menu-page">
    <div class="menu-header">
      <h1>Veckomeny</h1>
      <div class="top-buttons">
        <button id="toggle-view" class="toggle-view-btn" ng-click="toggleView()" title="Byt vy">🗒️</button>
        <button id="toggle-theme" class="theme-toggle-btn" title="Byt tema">🌙</button>
      </div>
    </div>

    <div class="date-picker">
      <button ng-click="goToPreviousWeek()">← Föregående vecka</button>
      <span>Vecka {{selectedWeek}} – {{selectedYear}}</span>
      <button ng-click="goToNextWeek()">Nästa vecka →</button>
    </div>

    <div ng-switch="viewMode">
      <div ng-switch-when="list" class="list-view">
        <div ng-repeat="day in daysOfWeek" class="day-item">
          <div class="day-header">{{day}}</div>
          <div class="meal-info" ng-if="menu[day]">
            <div ng-if="menu[day].breakfastMealId" class="meal-selection">
              <a href="/Meal/View/{{menu[day].breakfastMealId}}" target="_blank"><strong>Frukost:</strong> {{menu[day].breakfastMealName}}</a>
            </div>
            <div ng-if="menu[day].lunchMealId" class="meal-selection">
              <a href="/Meal/View/{{menu[day].lunchMealId}}" target="_blank"><strong>Lunch:</strong> {{menu[day].lunchMealName}}</a>
            </div>
            <div ng-if="menu[day].dinnerMealId" class="meal-selection">
              <a href="/Meal/View/{{menu[day].dinnerMealId}}" target="_blank"><strong>Middag:</strong> {{menu[day].dinnerMealName}}</a>
            </div>
          </div>
          <div ng-if="!menu[day]">
            <span class="not-assigned">Inte bestämd</span>
          </div>
        </div>
      </div>

    <div ng-switch-when="card" class="card-view">
        <div class="card-container">
        <div ng-repeat="day in daysOfWeek"
                class="meal-card"
                ng-attr-data-has-image="{{getDayImage(day) ? 'true' : 'false'}}"
                ng-style="getDayImage(day) ? {'background-image': 'url(' + getDayImage(day) + ')'} : {}"
                ng-click="openMeal(getMealIdByDay(day))">
            <div class="card-content">
            <div class="day">{{day}}</div>
            <div class="meal" ng-if="menu[day].breakfastMealName">Frukost: {{menu[day].breakfastMealName}}</div>
            <div class="meal" ng-if="menu[day].lunchMealName">Lunch: {{menu[day].lunchMealName}}</div>
            <div class="meal" ng-if="menu[day].dinnerMealName">Middag: {{menu[day].dinnerMealName}}</div>
            <div class="meal" ng-if="!menu[day]">Inte bestämd</div>
            </div>
        </div>
        </div>
    </div>

    </div>
</div>
</body>
</html>
