@use '../shared/styles/rds-profile-menu';

.rds-header--transparent {
  background: transparent !important;
  box-shadow: none !important;
  color: var(--rds-color-on-surface);
}

.rds-header--primary {
  background: var(--rds-color-primary) !important;
  color: var(--rds-color-on-primary) !important;
  .rds-header__title,
  .rds-header__actions,
  .rds-header__logo {
    color: var(--rds-color-on-primary) !important;
  }
  .rds-header__search {
    background: var(--rds-color-surface-overlay, rgba(255,255,255,0.12));
    color: var(--rds-color-on-primary);
    border-color: var(--rds-color-border-overlay, rgba(255,255,255,0.24));
    input {
      color: var(--rds-color-on-primary);
    }
  }
  .MuiTab-root {
    color: var(--rds-color-on-primary);
    &.Mui-selected {
      color: var(--rds-color-primary);
      background: var(--rds-color-surface);
    }
  }
}

.rds-header--secondary {
  background: var(--rds-color-secondary) !important;
  color: var(--rds-color-on-secondary) !important;
  .rds-header__title,
  .rds-header__actions,
  .rds-header__logo {
    color: var(--rds-color-on-secondary) !important;
  }
  .rds-header__search {
    background: var(--rds-color-surface-overlay, rgba(255,255,255,0.12));
    color: var(--rds-color-on-secondary);
    border-color: var(--rds-color-border-overlay, rgba(255,255,255,0.24));
    input {
      color: var(--rds-color-on-secondary);
    }
  }
  .MuiTab-root {
    color: var(--rds-color-on-secondary);
    &.Mui-selected {
      color: var(--rds-color-secondary);
      background: var(--rds-color-surface);
    }
  }
}

.rds-header {
  --rds-header-search-width: 220px;
  --rds-header-search-height: 36px;
  --rds-header-search-input-height: 34px;
  --rds-header-tabs-height: 40px;
  --rds-header-focus-ring-offset: 2px;
  display: flex;
  flex-direction: column;
  background: var(--rds-color-surface);
  color: var(--rds-color-on-surface);
  border-bottom: 1px solid var(--rds-color-border);
  box-shadow: var(--rds-elevation-1, 0 2px 8px 0 rgba(60,60,60,0.03));
  position: relative;
  width: 100%;
  z-index: var(--rds-z-index-sticky, 1100);
  font-family: var(--rds-font-family-base);

  &__toolbar {
    display: flex;
    align-items: center;
    min-height: var(--rds-header-toolbar-height, 56px);
    padding-left: var(--rds-spacing-xl, 32px);
    padding-right: var(--rds-spacing-xl, 32px);
    gap: var(--rds-spacing-lg, 24px);
    background: transparent;
    position: relative;
  }

  &__logo {
    display: flex;
    align-items: center;
    height: var(--rds-header-logo-height, 32px);
    min-width: var(--rds-header-logo-min-width, 120px);
    font-size: var(--rds-font-size-lg, 20px);
    font-weight: var(--rds-font-weight-bold, 700);
    letter-spacing: var(--rds-letter-spacing, 0.1px);
  }

  &__title {
    flex-grow: 1;
    font-weight: var(--rds-font-weight-semibold, 600);
    font-size: var(--rds-font-size-md, 18px);
    color: var(--rds-color-on-surface);
    letter-spacing: var(--rds-letter-spacing-wide, 0.2px);
    display: flex;
    align-items: center;
    min-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__search {
    min-width: var(--rds-header-search-width, 220px);
    color: var(--rds-color-on-surface);
    background: var(--rds-color-surface-alt);
    padding: 0 var(--rds-spacing-sm, 12px);
    border-radius: var(--rds-border-radius, 6px);
    font-size: var(--rds-font-size-body, 15px);
    border: 1px solid var(--rds-color-border);
    box-shadow: none;
    height: var(--rds-header-search-height, 36px);
    display: flex;
    align-items: center;
    transition: border-color var(--rds-transition-base);
    &:focus-within {
      border-color: var(--rds-color-primary);
      outline-offset: var(--rds-header-focus-ring-offset, 2px);
    }
    input {
      background: transparent;
      border: none;
      outline: none;
      width: 100%;
      font-size: var(--rds-font-size-body, 15px);
      color: var(--rds-color-on-surface);
      padding: 0;
      height: var(--rds-header-search-input-height, 34px);
    }
  }

  &__actions {
    display: flex;
    align-items: center;
    gap: var(--rds-spacing-md, 16px);
  }

  &__tabs {
    min-height: var(--rds-header-tabs-height, 40px);
    border-bottom: none;
    .MuiTabs-indicator {
      height: 2px;
      background: var(--rds-color-primary);
      border-radius: var(--rds-border-radius-xs) 2px 0 0;
    }
    .MuiTabs-flexContainer {
      gap: var(--rds-spacing-xs, 8px);
    }
    .MuiTab-root {
      min-height: var(--rds-header-tabs-height, 40px);
      font-weight: var(--rds-font-weight-medium, 500);
      font-size: var(--rds-font-size-body, 15px);
      color: var(--rds-color-on-surface);
      padding: 0 var(--rds-spacing-lg, 20px);
      border-radius: var(--rds-border-radius, 6px) var(--rds-border-radius, 6px) 0 0;
      border-bottom: none;
      &.Mui-selected {
        color: var(--rds-color-primary);
        background: var(--rds-color-surface);
        box-shadow: none;
      }
    }
  }

  &__sub-header {
    background: var(--rds-color-surface-alt);
    padding: var(--rds-spacing-xs, 8px) var(--rds-spacing-xl, 32px);
    border-top: 1px solid var(--rds-color-border);
    font-size: var(--rds-font-size-body, 15px);
    color: var(--rds-color-on-surface);
    display: flex;
    align-items: center;
    min-height: var(--rds-header-tabs-height, 40px);
  }

  &--sticky {
    position: sticky;
    top: 0;
  }
  &--shadow {
    box-shadow: var(--rds-elevation-2, 0 2px 8px 0 rgba(60,60,60,0.03));
  }

  &__search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: var(--rds-header-search-width, 220px);
  }

  &__search-clear {
    position: absolute !important;
    right: var(--rds-spacing-xs, 4px);
    top: 50%;
    transform: translateY(-50%);
    z-index: calc(var(--rds-z-index-base) + 1);
  }

  &__tabs {
    ~ .rds-header__sub-header {
      border-top: none;
    }
  }
}
