/**
 * app.css — APP SHELL (LAYOUT)
 *
 * Содержит:
 * - общий SPA layout (.app-container)
 * - icon rail / sidebar (левая навигация)
 * - main-content
 * - мобильная адаптация shell
 *
 * ⚠️ НЕ содержит:
 * - карточки
 * - catalog
 * - entity контент
 */

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ==========================================================================
   ICON RAIL (SIDEBAR NAV)
   ========================================================================== */
.rail,
.sidebar {
    width: 64px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--bd-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 4px;
    flex-shrink: 0;
    z-index: 30;
}

.rail-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--text-main);
    color: var(--bg-sidebar);
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.rail-btn,
.nav-item {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
    cursor: pointer;
}

.rail-btn#global-menu-toggle {
    background: var(--bg-hover);
}

.rail-btn:hover,
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.rail-btn.active,
.nav-item.active {
    background: var(--accent-bg);
    color: var(--accent);
}

/* активный индикатор — левая полоска */
.rail-btn.active::before,
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.rail-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.rail-divider {
    width: 20px;
    height: 1px;
    background: var(--line);
    margin: 6px 0;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    min-width: 0;
    overflow: hidden;
}

/* ============ MOBILE ADAPTATION ============ */
@media (max-width: 768px) {
  
  /* 1. Нижня панель навігації (твій варіант з fixed) */
  .rail {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    min-height: 60px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--line);
    padding: 8px 16px;
    /* Відступ для "шторки" на нових iPhone, щоб лінія не перекривала кнопки */
    padding-bottom: calc(8px + env(safe-area-inset-bottom)); 
    z-index: 60;
  }
  .rail-divider {
    transform: rotate(90deg);
  }

  .rail-btn.active::before, .nav-item.active::before {display: none;}
  
  .rail-bottom { margin-top: 0; margin-left: auto; flex-direction: row; gap: 8px; }
  .rail-logo { margin-bottom: 0; margin-right: 15px; } /* Або зменш, якщо хочеш залишити */

  /* 2. Ріжемо величезні десктопні відступи і робимо 1 колонку */
  .cat-head { padding: 16px 16px 12px; }
  .active-filters, .cat-chips { padding: 8px 16px 12px; }
  
  .cat-grid { 
    /* 100px знизу гарантують, що остання картка не сховається під fixed-меню */
    padding: 16px 16px 100px; 
    grid-template-columns: 1fr; 
  }

  /* 3. Адаптуємо шапку і пошук */
  .cat-head-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .cat-tools { width: 100%; }
  .cat-tools .search { min-width: 100%; }
  .cat-title { font-size: 28px; }
}