/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors
 *
 * This file is part of Dnote.
 *
 * Dnote is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Dnote is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Dnote.  If not, see <https://www.gnu.org/licenses/>.
 */

@use "sass:color";
@use 'theme';
@use 'variables';
@use "font";
@use "rem";
@use "responsive";

.header-wrapper {
  padding: 0;
  z-index: 2;
  position: relative;
  display: flex;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  background: theme.$first;
  align-items: stretch;
  justify-content: space-between;
  flex: 1;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 4;
  height: variables.$header-height;

  .container {
    height: 100%;
  }

  @include responsive.breakpoint(md) {
    flex-direction: row;
  }

  .header-content {
    display: flex;
    justify-content: space-between;
    height: 100%;
  }

  .left {
    display: flex;
  }

  .right {
    display: flex;
  }

  .search-wrapper {
    align-items: center;
    display: flex;
    margin-left: rem.rem(32px);
  }

  .search-input {
    width: rem.rem(356px);
    border: 0;
    padding: 4px 12px;
    border-radius: rem.rem(4px);
    @include font.font-size('small');
  }

  .brand {
    display: flex;
    align-items: center;

    &:hover {
      text-decoration: none;
    }
  }

  .main-nav {
    margin-left: rem.rem(32px);
    display: flex;

    .list {
      display: flex;
    }

    .item {
      display: flex;
      align-items: stretch;
    }

    .nav-link {
      @include font.font-size('small');
      display: flex;
      font-weight: 600;
      align-items: center;
      padding: 0 rem.rem(16px);
      color: theme.$white;

      &:hover {
        color: theme.$white;
        text-decoration: none;
        background: color.adjust(theme.$first, $lightness: 10%);
      }
    }

    .nav-item {
      @include font.font-size('small');
      font-weight: 600;
    }
  }

  .dropdown-trigger {
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
  }

  .dropdown {
    position: relative;
    display: inline-block;
  }

  .dropdown-content {
    display: none;
    position: absolute;
    background-color: #f1f1f1;
    width: rem.rem(240px);
    background: #fff;
    border: 1px solid #d8d8d8;
    border-radius: 4px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
    top: calc(100% + 4px);
    z-index: 1;

    &.show {
      display: block;
    }

    &.right-align {
      right: 0;
    }
  }

  .account-dropdown {
    .dropdown-trigger {
      height: 100%;
    }

    .account-dropdown-header {
      @include font.font-size('small');
      color: theme.$light-gray;
      padding: rem.rem(8px) rem.rem(12px);
      display: block;
      margin-bottom: 0;
      white-space: nowrap;

      svg {
        fill: theme.$light-gray;
      }

      .email {
        font-weight: 600;
        white-space: normal;
        word-break: break-all;
      }
    }

    .dropdown-link {
      @include font.font-size('small');
      white-space: pre;
      padding: rem.rem(8px) rem.rem(14px);
      width: 100%;
      display: block;
      color: black;

      &:hover {
        background: theme.$lighter-gray;
        text-decoration: none;
        color: #0056b3;
      }

      &.disabled {
        color: #d4d4d4;
        cursor: not-allowed;
      }

      &:not(.disabled):focus {
        background: theme.$lighter-gray;
        color: #0056b3;
        outline: 1px dotted gray;
      }
    }

    .session-notice-wrapper {
      display: flex;
      align-items: center;
    }

    .session-notice {
      margin-left: rem.rem(4px);
    }
  }
}
