/* static/css/app.css — Sidebar layout & app shell */

/* ─── App shell layout ─────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 240px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
}

/* ─── Main area ────────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: 240px;
  transition: margin-left 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.sidebar-collapsed .app-main {
  margin-left: 64px;
}

.app-content {
  padding: 28px 28px 40px;
  flex: 1;
  max-width: 1120px;
  width: 100%;
}

/* ─── Sidebar header ───────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  min-height: 62px;
  gap: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.sidebar-brand-text {
  font-weight: 750;
  font-size: 15px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  transition: opacity 0.2s ease, width 0.26s ease;
}

/* ─── Collapse button ──────────────────────────────── */
.sidebar-collapse-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
  width: 30px;
  height: 30px;
}

.sidebar-collapse-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-collapse-btn svg {
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

/* ─── Hide labels when collapsed ──────────────────── */
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-family-text,
.sidebar.collapsed .sidebar-user-meta,
.sidebar.collapsed .sidebar-bottom-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ─── Collapsed: center icons ──────────────────────── */
.sidebar.collapsed .sidebar-link,
.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .sidebar-family-badge {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* ─── Nav body ─────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 10px 6px;
  white-space: nowrap;
  display: block;
  transition: opacity 0.2s ease;
}

/* ─── Active family badge ──────────────────────────── */
.sidebar-family-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  margin: 4px 2px 8px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(37,79,34,0.18), rgba(37,79,34,0.08));
  border: 1px solid rgba(37,79,34,0.28);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s ease;
}

.sidebar-family-badge:hover {
  background: linear-gradient(135deg, rgba(37,79,34,0.25), rgba(37,79,34,0.14));
}

.sidebar-family-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74,222,128,0.18);
  flex-shrink: 0;
}

.sidebar-family-text {
  font-size: 12.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

/* ─── Nav links ────────────────────────────────────── */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  margin-bottom: 2px;
  border: 1px solid transparent;
  position: relative;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--text);
  opacity: 1;
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(245,130,74,0.14), rgba(160,58,19,0.08));
  color: var(--text);
  border-color: rgba(245,130,74,0.20);
}

.sidebar-link.active .sidebar-icon {
  color: var(--o-500);
}

.sidebar-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.sidebar-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

/* ─── Divider ──────────────────────────────────────── */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

/* ─── Sidebar footer ───────────────────────────────── */
.sidebar-footer {
  padding: 10px 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: background 0.12s ease;
}

.sidebar-user:hover {
  background: var(--surface-2);
  opacity: 1;
}

.sidebar-user-meta {
  overflow: hidden;
  flex: 1;
  min-width: 0;
  transition: opacity 0.2s ease;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.sidebar-bottom-actions {
  display: flex;
  gap: 6px;
}

.sidebar-bottom-actions .sidebar-link {
  flex: 1;
  justify-content: center;
  margin-bottom: 0;
}

.sidebar.collapsed .sidebar-bottom-actions {
  flex-direction: column;
}

/* ─── Mobile topbar ────────────────────────────────── */
.app-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 54px;
}

.app-topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
  font-size: 15px;
  text-decoration: none;
  color: var(--text);
}

.sidebar-mobile-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Mobile overlay ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ─── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 240px !important;
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .app-main {
    margin-left: 0 !important;
  }

  .app-topbar {
    display: flex;
  }

  .app-content {
    padding: 20px 16px 32px;
  }
}
