/* ============================================================
   layout-responsive.css
   /public/assets/layout-responsive.css
   ============================================================ */

/* ── 1. RESET styles.css conflicting media queries ─────────── */
@media (max-width: 1300px) {
  .app {
    grid-template-columns: 200px 1fr !important;
    grid-template-rows: 56px 1fr !important;
    grid-template-areas: "side top" "side main" !important;
  }
  .brand .t, .brand .s, .nav a .label, .label {
    display: unset !important;
    opacity: 1 !important;
    max-width: 200px !important;
  }
}
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 200px 1fr !important;
    grid-template-rows: 56px 1fr !important;
    grid-template-areas: "side top" "side main" !important;
  }
  .sidebar { display: flex !important; }
  .lp-wrap { grid-template-columns: 280px 1fr !important; }
}

/* ── 2. SIDEBAR SIZE — smaller & compact ────────────────────── */
.app {
  grid-template-columns: 200px 1fr !important;
  grid-template-rows: 56px 1fr !important;
  grid-template-areas: "side top" "side main" !important;
}

.sidebar {
  padding: 10px 8px !important;
  gap: 6px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(255,255,255,.12) transparent !important;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* Brand compact */
.brand {
  padding: 8px 8px !important;
  gap: 8px !important;
  border-radius: 10px !important;
}
.logo {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  border-radius: 8px !important;
  flex-shrink: 0;
}
.brand .t { font-size: 11px !important; font-weight: 800 !important; }
.brand .s { font-size: 10px !important; }

/* Nav compact */
.nav {
  padding: 4px !important;
  gap: 2px !important;
  border-radius: 10px !important;
}
.nav a {
  padding: 7px 8px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  gap: 6px !important;
}
.nav a .icon {
  width: 22px !important;
  height: 22px !important;
  font-size: 14px !important;
  border-radius: 6px !important;
  flex-shrink: 0;
}
.nav a .label {
  font-size: 12px !important;
  font-weight: 600 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav a .badge {
  font-size: 10px !important;
  padding: 2px 6px !important;
  border-radius: 999px !important;
  flex-shrink: 0;
}

/* Side footer compact */
.side-footer {
  font-size: 9px !important;
  padding: 8px !important;
  border-radius: 8px !important;
  line-height: 1.4 !important;
  word-break: break-all;
}

/* Topbar compact */
.topbar {
  height: 56px !important;
  padding: 0 14px !important;
}

/* ── 3. COLLAPSE STATE — on .app not body ───────────────────── */
.app.sidebar-collapsed {
  grid-template-columns: 0px 1fr !important;
}
.app.sidebar-collapsed .sidebar {
  display: none !important;
}

/* ── 4. HAMBURGER — hidden on desktop ────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 6px;
  transition: background 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,.08); }
.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text, #e0e0e0);
  border-radius: 2px;
}

/* Hide old JS sidebarToggle on mobile */
@media (max-width: 900px) {
  .sidebarToggle { display: none !important; }
}

/* ── 5. MOBILE OVERLAY ───────────────────────────────────────── */
.mobileOverlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.mobileSidebar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 220px;
  overflow-y: auto;
  z-index: 1000;
  animation: slideInLeft 0.2s ease;
}
.mobileSidebar .sidebar {
  position: static !important;
  height: 100% !important;
  width: 100% !important;
  border-right: none !important;
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0.3; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ── 6. MOBILE BREAKPOINT ≤ 900px ────────────────────────────── */
@media (max-width: 900px) {
  .app > aside.sidebar { display: none !important; }
  .hamburger { display: flex; }

  .app {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: 56px 1fr !important;
    grid-template-areas: "top" "main" !important;
    height: 100% !important;
  }

  /* collapsed does nothing on mobile */
  .app.sidebar-collapsed {
    grid-template-columns: 1fr !important;
  }

  .topbar {
    grid-area: top !important;
    padding: 0 12px !important;
    height: 56px !important;
  }
  .main {
    grid-area: main !important;
    padding: 10px !important;
    min-width: 0;
    overflow: auto;
  }

  .card { overflow-x: auto; }
  table { min-width: 420px; }

  .page-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
  .topbar .row { flex-wrap: wrap; gap: 6px; }
  .pluginGrid { grid-template-columns: 1fr !important; }
  .lp2 { flex-direction: column !important; }
  .lp2Nav {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--line, rgba(255,255,255,.10)) !important;
  }
  .lp-wrap { grid-template-columns: 1fr !important; }
  .permsHeader { flex-direction: column !important; gap: 10px !important; }
  .permsHeaderRight { flex-wrap: wrap !important; }
  .consoleRow { grid-template-columns: repeat(2, 1fr) !important; }
  .consoleBody { grid-template-columns: 1fr !important; }
}

/* ── 7. OVERRIDE styles.css body.sidebar-collapsed rules ───────
   styles.css uses body.sidebar-collapsed but we now use .app.sidebar-collapsed
   These nullify the old body-based rules so they don't interfere            */
body.sidebar-collapsed .app { grid-template-columns: unset; }
body.sidebar-collapsed .brand { padding: unset; justify-content: unset; gap: unset; }
body.sidebar-collapsed .nav { padding: unset; }
body.sidebar-collapsed .nav a { justify-content: unset; gap: unset; }
body.sidebar-collapsed .nav a .left { justify-content: unset; gap: unset; }
body.sidebar-collapsed .brand .t,
body.sidebar-collapsed .brand .s,
body.sidebar-collapsed .nav a .label,
body.sidebar-collapsed .nav a .badge,
body.sidebar-collapsed .homeButton .label,
body.sidebar-collapsed .homeButton .badge,
body.sidebar-collapsed .side-footer { display: unset; opacity: unset; max-height: unset; }

/* ── 8. SMALL MOBILE ≤ 480px ─────────────────────────────────── */
@media (max-width: 480px) {
  .main { padding: 8px !important; }
  .tabs { flex-wrap: wrap; gap: 3px; }
  .lp2MainTabs { flex-wrap: wrap; gap: 3px; }
  .page h1 { font-size: 18px !important; }
  .topbar .crumb b { font-size: 13px; }
  .btn, .btn-primary, .btn-ghost {
    padding: 7px 9px !important;
    font-size: 12px !important;
  }
  .mobileSidebar { width: 200px; }
  .mobileSidebar .nav a { padding: 6px 7px !important; }
  .mobileSidebar .nav a .icon { font-size: 13px !important; width: 20px !important; height: 20px !important; }
  .mobileSidebar .nav a .label { font-size: 11px !important; }
  .mobileSidebar .nav a .badge { font-size: 9px !important; padding: 1px 5px !important; }
}