// -------------------------------------------------------------------------------------------------------------------
// @ Matcha Drawer Component Styles (Refatorado baseado no Angular Material Sidenav)
// @ Todos os estilos consolidados aqui para facilitar manutenção
// -------------------------------------------------------------------------------------------------------------------

@mixin matcha-drawer-theme($theme) {
  $primary: map-get($theme, primary);
  $accent: map-get($theme, accent);
  $warn: map-get($theme, warn);
  $background: map-get($theme, background);
  $foreground: map-get($theme, foreground);

  // ===== DRAWER CONTAINER =====
  matcha-drawer-container {
    display: block;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overflow: hidden;
    background-color: getBackground($theme);
    color: getForeground($theme);

    // Backdrop
    .matcha-drawer-backdrop {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: block;
      z-index: 3;
      visibility: hidden;
      background-color: getBackgroundAlpha($theme);
      backdrop-filter: blur(4px);
      opacity: 0;
      transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
                  visibility 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    // Backdrop visível quando há drawer aberto
    &.matcha-drawer-container-has-open .matcha-drawer-backdrop {
      visibility: visible;
      opacity: 1;
    }

    // Container do conteúdo principal
    .matcha-drawer-content-container {
      position: relative;
      z-index: 0; // Menor que o drawer (z-index: 3)
      display: block;
      height: 100%;
      overflow: auto;
    }
  }

  // ===== DRAWER =====
  matcha-drawer {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 10; // Maior z-index para garantir que fique acima do conteúdo
    outline: 0;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translate3d(-100%, 0, 0);
    visibility: hidden;
    transition: transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
                visibility 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
    background-color: getBackground($theme);
    color: getForeground($theme);
    box-shadow: 0 8px 10px -5px rgba(0,0,0,.2),
                0 16px 24px 2px rgba(0,0,0,.14),
                0 6px 30px 5px rgba(0,0,0,.12);
    pointer-events: auto; // Garante que seja sempre clicável

    // Largura agora é controlada pela propriedade width do componente
    // width: 256px; // Removido - agora é dinâmico

    // Posição end (direita)
    &.matcha-drawer-end {
      right: 0;
      transform: translate3d(100%, 0, 0);
    }

    // Estado aberto
    &.matcha-drawer-opened {
      transform: translate3d(0, 0, 0);
      visibility: visible;
    }

    // Modo over - fica por cima com z-index maior
    &.matcha-drawer-over {
      z-index: 15; // Maior que o z-index base (10)
      border-right: 1px solid getDisabled($theme);

      &.matcha-drawer-end {
        border-right: none;
        border-left: 1px solid getDisabled($theme);
      }
    }

    // Modo side - fica fixo sem shadow
    &.matcha-drawer-side {
      z-index: 10; // Mantém o z-index base
      border-right: 1px solid getDisabled($theme);
      box-shadow: none;

      &.matcha-drawer-end {
        border-right: none;
        border-left: 1px solid getDisabled($theme);
      }
    }

    // Modo push - empurra o conteúdo sem shadow
    &.matcha-drawer-push {
      border-right: 1px solid getDisabled($theme);
      box-shadow: none;

      &.matcha-drawer-end {
        border-right: none;
        border-left: 1px solid getDisabled($theme);
      }
    }

    // Inner container do drawer
    .matcha-drawer-inner-container {
      width: 100%;
      height: 100%;
      -webkit-overflow-scrolling: touch;
      display: flex;
      flex-direction: column;
      position: relative; // Garante posicionamento correto
      pointer-events: auto; // Garante que seja clicável
    }
  }

  // ===== DRAWER CONTENT =====
  matcha-drawer-content {
    position: relative;
    z-index: 1;
    display: block;
    height: 100%;
    overflow: auto;
    transition: margin 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
  }
}
