﻿/* ═══════════════════════════════
   LAYOUT — shell, header, sidebar, footer
   ═══════════════════════════════ */

.app-shell {
  display: grid;
  height: 100vh;
  min-width: 0;
  grid-template-columns: auto 1fr;
  grid-template-rows: 72px 1fr 48px;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  overflow: hidden;
}

/* Header */
.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 11, 0.58);
  backdrop-filter: blur(18px);
  z-index: 10;
}

.brand,
.header-actions,
.action-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  gap: 12px;
  font-weight: 700;
}

.brand,
.header-actions {
  min-width: 0;
}

.logo {
  height: 40px;
  width: 40px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(0, 136, 204, 0.3));
}

.brand-text {
  white-space: nowrap;
}

.header-actions {
  gap: 12px;
}

.network-badge {
  border: 1px solid rgba(242, 201, 76, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--warning);
  font-size: 13px;
  background: rgba(242, 201, 76, 0.08);
}
.network-badge.is-wrong-network {
  border-color: rgba(255, 116, 116, 0.5);
  color: #ff9b9b;
  background: rgba(255, 116, 116, 0.1);
}

.wallet-status {
  color: #ff7474;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.wallet-status.is-connected {
  color: #52d98a;
}

.wallet-status.is-disconnected {
  color: #ff7474;
}

/* Sidebar */
.app-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  background: rgba(17, 17, 17, 0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: 64px;
  min-width: 64px;
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}

.app-sidebar.is-expanded {
  width: 200px;
  min-width: 200px;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  margin: 0 auto 12px auto;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.sidebar-toggle:hover {
  background: var(--panel-soft);
  color: var(--accent);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.25s ease;
}

.app-sidebar.is-expanded .sidebar-toggle svg {
  transform: rotate(180deg);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.nav-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  font-size: 13px;
  text-decoration: none;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
}

.app-sidebar:not(.is-expanded) .nav-link svg {
  margin-left: 7px;
}

.app-sidebar.is-expanded .nav-link svg {
  margin-left: 0;
}

.nav-label {
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 13px;
}

.app-sidebar.is-expanded .nav-label {
  opacity: 1;
}

.nav-link:hover {
  background: var(--panel-soft);
  color: var(--accent);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

/* Main */
.app-main {
  grid-area: main;
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 24px clamp(18px, 2.2vw, 32px);
  width: 100%;
  min-width: 0;
  overflow-y: auto;
}

/* Footer */
.app-footer {
  grid-area: footer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: "header" "main";
    width: 100vw;
    max-width: 100vw;
  }

  .app-header {
    gap: 10px;
    padding: 0 14px;
    overflow: hidden;
  }

  .brand-text,
  .wallet-status,
  .app-footer,
  #ton-connect {
    display: none;
  }

  .brand {
    flex-shrink: 0;
  }

  .header-actions {
    flex: 1;
    justify-content: flex-end;
    overflow: hidden;
  }

  .app-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100vw;
    height: 64px;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 8px;
    transition: none;
  }

  .app-sidebar.is-expanded {
    width: 100% !important;
    min-width: 100% !important;
  }

  .sidebar-toggle {
    display: none;
  }

  .side-nav {
    flex-direction: row;
    justify-content: stretch;
    width: 100%;
    padding: 0;
    gap: 0;
  }

  .nav-link {
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    font-size: 10px;
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .app-sidebar:not(.is-expanded) .nav-link svg {
    margin-left: 0;
  }

  .nav-label {
    max-width: 100%;
    opacity: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
  }

  .app-main {
    gap: 16px;
    padding: 16px;
    padding-bottom: 84px;
  }
}

@media (max-width: 420px) {
  .app-header {
    padding: 0 10px;
  }

  .header-actions {
    gap: 8px;
  }

  .network-badge {
    padding: 5px 8px;
    font-size: 12px;
  }

  .nav-link {
    padding: 6px 4px;
  }

  .app-main {
    padding-inline: 12px;
  }
}
