/* ============================================
   MOBILE MENU - Slide-in drawer з закладкою
   ============================================

   Архітектура:
   1. .mobile-menu-tab - закладка на лівому краї header панелі
   2. .mobile-menu-drawer - drawer що виїжджає зліва
   3. .mobile-menu-overlay - затемнення фону

   Показується тільки на мобільних (max-width: 1023px)
   ============================================ */

/* Приховано за замовчуванням на desktop */
.mobile-menu-tab,
.mobile-menu-drawer,
.mobile-menu-overlay {
  display: none;
}

/* ============================================
   МОБІЛЬНІ СТИЛІ (max-width: 1023px)
   ============================================ */
@media (max-width: 1023px) {

  /* ============================================
     ЗАКЛАДКА - Вертикальна смужка зліва
     Позиціонування як у dashboard - fixed, по центру екрану
     ============================================ */
  .mobile-menu-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 0;
    top: calc(var(--mobile-head-h, 82px) + env(safe-area-inset-top, 0px) + 70%);
    transform: translateY(-50%);

    /* Tab dimensions */
    width: 30px;
    height: 80px;

    /* Purple accent color */
    background: #363546;

    /* Rounded only on right */
    border-radius: 0 10px 10px 0;

    /* Shadow for depth */
    box-shadow: 4px 0 10px rgba(118, 115, 150, 0.3);

    /* Cursor and animation */
    cursor: pointer;
    transition: all 0.2s ease;

    /* Touch optimization */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;

    /* Z-index above content */
    z-index: 1095;
  }

  /* Hover/Active states */
  .mobile-menu-tab:hover {
    width: 28px;
    background: #64618a;
    box-shadow: 3px 0 8px rgba(118, 115, 150, 0.4);
  }

  .mobile-menu-tab:active {
    width: 22px;
    background: #64618a;
    box-shadow: 1px 0 6px rgba(118, 115, 150, 0.25);
  }

  /* Активний стан коли меню відкрите */
  .mobile-menu-tab.is-active {
    width: 28px;
    background: #a799ff;
  }

  /* Текст "MENU" всередині, повернутий на 90° */
  .mobile-menu-tab::before {
    content: 'MENU';
    font-family: 'Gilroy', 'Manrope', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.85);
    transform: rotate(-90deg);
    white-space: nowrap;
  }

  /* ============================================
     OVERLAY - Затемнення фону
     ============================================ */
  .mobile-menu-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1200;

    /* Початковий стан - невидимий */
    opacity: 0;
    visibility: hidden;

    /* Плавна анімація */
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .mobile-menu-overlay.is-visible {
    opacity: 1;
    visibility: visible;
  }

  /* ============================================
     DRAWER - Меню що виїжджає зліва
     ============================================ */
  .mobile-menu-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;

    /* Ширина drawer */
    width: 280px;
    max-width: 85vw;

    /* Стиль */
    background: #262626;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    z-index: 1250;

    /* Початковий стан - за екраном */
    transform: translateX(-100%);

    /* Плавна анімація виїзду */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Safe area для notch */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
  }

  .mobile-menu-drawer.is-open {
    transform: translateX(0);
  }

  /* ============================================
     DRAWER HEADER - Логотип та кнопка закриття
     ============================================ */
  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 26px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-menu-logo {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  /* Icon logo (square) */
  .mobile-menu-logo img:not(.mobile-menu-logo-svg) {
    width: 32px;
    height: 32px;
  }

  /* Full wordmark logo (white SVG) */
  .mobile-menu-logo .mobile-menu-logo-svg {
    width: auto;
    height: 28px;
  }

  .mobile-menu-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
  }

  .mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-menu-close:hover,
  .mobile-menu-close:active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
  }

  /* ============================================
     DRAWER CONTENT - Пункти меню
     ============================================ */
  .mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
  }

  .mobile-menu-section {
    margin-bottom: 24px;
  }

  .mobile-menu-section:last-child {
    margin-bottom: 0;
  }

  .mobile-menu-section-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 12px 8px;
  }

  /* ============================================
     MENU ITEMS - Пункти меню
     ============================================ */
  .mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Gilroy', 'Manrope', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .mobile-menu-item:hover,
  .mobile-menu-item:active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
  }

  .mobile-menu-item svg {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.15s ease;
  }

  .mobile-menu-item:hover svg,
  .mobile-menu-item:active svg {
    color: rgba(255, 255, 255, 0.8);
  }

  .mobile-menu-item-text {
    flex: 1;
  }

  /* Logout стиль */
  .mobile-menu-item--logout {
    color: #f87171;
  }

  .mobile-menu-item--logout svg {
    color: #f87171;
  }

  .mobile-menu-item--logout:hover,
  .mobile-menu-item--logout:active {
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
  }

  .mobile-menu-item--logout:hover svg,
  .mobile-menu-item--logout:active svg {
    color: #fca5a5;
  }

  /* Login стиль - акцент */
  .mobile-menu-item--login {
    background: linear-gradient(135deg, rgba(87, 22, 196, 0.15) 0%, rgba(214, 0, 169, 0.15) 100%);
    color: #c084fc;
  }

  .mobile-menu-item--login svg {
    color: #c084fc;
  }

  .mobile-menu-item--login:hover,
  .mobile-menu-item--login:active {
    background: linear-gradient(135deg, rgba(87, 22, 196, 0.25) 0%, rgba(214, 0, 169, 0.25) 100%);
    color: #d8b4fe;
  }

  /* ============================================
     LANGUAGE SELECTOR - Dropdown як в desktop версії
     ============================================ */
  .mobile-menu-lang {
    position: relative;
    padding: 0 12px;
  }

  .mobile-menu-lang__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    font-family: 'Gilroy', 'Manrope', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-menu-lang__trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
  }

  .mobile-menu-lang__trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
  }

  .mobile-menu-lang__icon {
    flex-shrink: 0;
    opacity: 0.6;
  }

  .mobile-menu-lang__label {
    flex: 1;
    text-align: left;
  }

  .mobile-menu-lang__chevron {
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform 0.2s ease;
  }

  .mobile-menu-lang__trigger[aria-expanded="true"] .mobile-menu-lang__chevron {
    transform: rotate(180deg);
  }

  /* Dropdown Menu */
  .mobile-menu-lang__menu {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 12px;
    right: 12px;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: #1f1f1f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
    animation: mobileLangMenuSlideUp 0.15s ease-out;
  }

  .mobile-menu-lang__menu[hidden] {
    display: none;
  }

  @keyframes mobileLangMenuSlideUp {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mobile-menu-lang__option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: 'Gilroy', 'Manrope', system-ui, sans-serif;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
  }

  .mobile-menu-lang__option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
  }

  .mobile-menu-lang__option.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
  }

  .mobile-menu-lang__option.is-active::before {
    content: '✓';
    margin-right: 10px;
    font-size: 12px;
  }

  /* ============================================
     DRAWER FOOTER - Версія та інше
     ============================================ */
  .mobile-menu-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-menu-version {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
  }

  /* ============================================
     USER INFO - Якщо залогінений
     ============================================ */
  .mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 12px;
    margin: 0 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
  }

  .mobile-menu-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    object-fit: cover;
  }

  .mobile-menu-user-info {
    flex: 1;
    min-width: 0;
  }

  .mobile-menu-user-name {
    font-size: 15px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-menu-user-email {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ============================================
     HIDDEN STATES - Приховування елементів
     ============================================ */
  .mobile-menu-item[hidden],
  .mobile-menu-user[hidden],
  .mobile-menu-section[hidden] {
    display: none !important;
  }
}

/* ============================================
   SMALL SCREENS - Адаптація для малих екранів
   ============================================ */
@media (max-width: 380px) {
  .mobile-menu-drawer {
    width: 260px;
  }

  .mobile-menu-tab {
    width: 20px;
    height: 54px;
  }

  .mobile-menu-tab::before {
    font-size: 8px;
  }

  .mobile-menu-item {
    padding: 12px 10px;
    font-size: 14px;
  }

  .mobile-menu-lang__trigger {
    padding: 10px 12px;
    font-size: 13px;
  }

  .mobile-menu-lang__option {
    padding: 10px 12px;
    font-size: 13px;
  }
}
