/* Mobile: bottom nav + split accordion */

:root {
  --bottom-nav-h: 3.35rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav {
  display: none;
}

.bottom-sheet {
  display: none;
}

@media (max-width: 768px) {
  body.mobile-ui {
    --bottom-nav-h: 3.35rem;
  }

  body.mobile-ui .sidebar {
    display: none;
  }

  body.mobile-ui .app {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }

  body.mobile-ui .main {
    min-height: 0;
  }

  body.mobile-ui .content {
    padding-bottom: 0.35rem;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding: 0.35rem 0.25rem var(--safe-bottom);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
  }

  .bottom-nav-item {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    padding: 0.15rem 0.1rem;
    border-radius: 0.65rem;
    cursor: pointer;
    position: relative;
  }

  .bottom-nav-item svg {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
  }

  .bottom-nav-item span {
    font-size: 0.58rem;
    font-weight: 600;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bottom-nav-item.active {
    color: var(--brand);
    background: var(--brand-soft);
  }

  .bottom-nav-badge {
    position: absolute;
    top: 0.1rem;
    right: calc(50% - 1.1rem);
    min-width: 0.95rem;
    height: 0.95rem;
    padding: 0 0.22rem;
    border-radius: 999px;
    font-size: 0.52rem;
    font-weight: 700;
    line-height: 0.95rem;
    text-align: center;
    background: var(--brand);
    color: #fff;
  }

  .bottom-nav-badge:empty {
    display: none;
  }

  .bottom-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 130;
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0.2s;
  }

  .bottom-sheet.open {
    pointer-events: auto;
    visibility: visible;
  }

  .bottom-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.35);
    opacity: 0;
    transition: opacity 0.2s;
  }

  .bottom-sheet.open .bottom-sheet-backdrop {
    opacity: 1;
  }

  .bottom-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 1rem 1rem 0 0;
    padding: 0.85rem 0.85rem calc(0.85rem + var(--safe-bottom));
    transform: translateY(100%);
    transition: transform 0.22s ease;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  }

  .bottom-sheet.open .bottom-sheet-panel {
    transform: translateY(0);
  }

  .bottom-sheet-panel h3 {
    margin: 0 0 0.65rem;
    font-size: 0.9rem;
    font-weight: 700;
  }

  .bottom-sheet-links {
    display: grid;
    gap: 0.35rem;
  }

  .bottom-sheet-links button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 0.75rem;
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
  }

  .bottom-sheet-links button:active {
    background: #f9fafb;
  }

  /* Split workspace: toolbar sticky, hide right column */
  body.mobile-ui .page.split-workspace.active {
    min-height: 0;
  }

  body.mobile-ui .content-split.resizable-split {
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1;
    padding: 0.45rem;
    gap: 0.45rem;
  }

  body.mobile-ui .detail-column {
    display: contents;
  }

  body.mobile-ui .split-resizer,
  body.mobile-ui .detail-panel {
    display: none !important;
  }

  body.mobile-ui .split-toolbar {
    order: -2;
    position: sticky;
    top: 0;
    z-index: 15;
    margin: 0;
  }

  body.mobile-ui .split-toolbar-filters,
  body.mobile-ui .split-toolbar-filters-top {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.1rem;
  }

  body.mobile-ui .split-toolbar-filters::-webkit-scrollbar,
  body.mobile-ui .split-toolbar-filters-top::-webkit-scrollbar {
    display: none;
  }

  body.mobile-ui .split-toolbar-row-search,
  body.mobile-ui .split-toolbar-row-main {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.mobile-ui .split-toolbar-row-search::-webkit-scrollbar,
  body.mobile-ui .split-toolbar-row-main::-webkit-scrollbar {
    display: none;
  }

  body.mobile-ui .split-toolbar-row-search .split-toolbar-search,
  body.mobile-ui .split-toolbar-row-main .split-toolbar-search {
    min-width: 4.5rem;
    flex: 1 1 4.5rem;
  }

  body.mobile-ui .split-toolbar .law-filters,
  body.mobile-ui .split-toolbar .group-filters {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  body.mobile-ui .list-panel {
    order: -1;
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  body.mobile-ui .khoper-stats {
    display: none;
  }

  body.mobile-ui #page-khoper .content-split.resizable-split {
    padding-top: 0.45rem;
  }

  body.mobile-ui .tender-list {
    padding: 0.2rem;
    gap: 0.2rem;
  }

  /* Accordion expand under card */
  .tender-item-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .tender-item-wrap .tender-item {
    width: 100%;
  }

  .tender-item-wrap.expanded .tender-item {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: var(--brand-border);
  }

  .tender-item-expand {
    border: 1px solid var(--brand-border);
    border-top: none;
    border-radius: 0 0 0.6rem 0.6rem;
    background: #fff;
    overflow: hidden;
  }

  .tender-item-expand[hidden] {
    display: none !important;
  }

  .tie-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.55rem;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
  }

  .tender-item-expand .detail-scroll {
    max-height: min(62vh, 520px);
    padding: 0.75rem 0.85rem 1rem;
  }

  body.mobile-ui .app-header {
    display: block !important;
    padding: 0.65rem 0.85rem 0.35rem;
  }

  body.mobile-ui.split-workspace-mode .app-header {
    display: none !important;
  }

  body.mobile-ui .greeting {
    font-size: 1.15rem;
  }

  body.mobile-ui .greeting-sub {
    font-size: 0.78rem;
  }

  body.mobile-ui .copilot {
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 0.5rem);
  }
}
