/*
 * Workrlab — App layout styles
 * Sidebar, topbar, pagina layout voor ingelogde pagina's
 *
 * Vereist: workrlab.css
 */

/* ─────────────────────────────────────────
   App layout
───────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--slate-100);
}

.app-main {
  margin-left: 232px;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
}

/* ─────────────────────────────────────────
   Sidebar
───────────────────────────────────────── */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 232px;
  height: 100vh;
  background: var(--slate-900);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  overflow: hidden;
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity var(--duration) var(--ease);
}

.sidebar-logo:hover {
  opacity: .85;
}

.sidebar-logo-icon {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

/* Full logo (logo_white.png) variant */
.sidebar-logo-full {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 140px;
  height: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.sidebar-logo-tagline {
  font-size: 9px;
  color: var(--slate-500);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: 1px;
}

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

.sidebar-nav::-webkit-scrollbar {
  width: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
}

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

.sidebar-section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--slate-600);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 12px 10px 5px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
  margin-bottom: 1px;
  cursor: pointer;
}

.sidebar-link svg,
.sidebar-link i.lni {
  width: 16px;
  height: 16px;
  font-size: 16px;
  flex-shrink: 0;
  opacity: .7;
  line-height: 1;
  transition: opacity var(--duration) var(--ease);
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, .06);
  color: var(--slate-100);
}

.sidebar-link:hover svg,
.sidebar-link:hover i.lni {
  opacity: 1;
}

.sidebar-link.active {
  background: rgba(14, 165, 233, .14);
  color: var(--sky-400);
}

.sidebar-link.active svg,
.sidebar-link.active i.lni {
  opacity: 1;
  color: var(--sky-400);
}

.sidebar-link .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 7px;
}

.sidebar-link-sub {
  padding-left: 35px;
  font-size: 12px;
  color: var(--slate-500);
}
.sidebar-link-sub i.lni {
  font-size: 13px;
  width: 13px;
  height: 13px;
}

/* Footer */
.sidebar-footer {
  padding: 10px 8px 14px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  flex-shrink: 0;
}

/* Tenant badge */
.sidebar-tenant {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
  margin-bottom: 8px;
}

.sidebar-tenant-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
}

.sidebar-tenant-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-tenant-url {
  font-size: 10px;
  color: var(--slate-600);
  margin-top: 1px;
}

/* User + uitlog rij */
.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
}

.sidebar-user-row:hover {
  background: rgba(255, 255, 255, .04);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-email {
  font-size: 11px;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--slate-600);
  padding: 4px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  transition: color var(--duration) var(--ease);
  flex-shrink: 0;
}

.sidebar-logout-btn:hover {
  color: var(--slate-500);
}

/* ─────────────────────────────────────────
   Topbar
───────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 28px;
  background: white;
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-900);
  letter-spacing: -.02em;
  line-height: 1;
}

.topbar-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--slate-500);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────────────────────────────────────
   Pagina inhoud
───────────────────────────────────────── */

.page-alerts {
  padding: 16px 28px 0;
}

.page-content {
  padding: 24px 28px 40px;
  flex: 1;
}

/* Pagina header met titel + acties */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header-text {}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--slate-900);
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-bottom: 4px;
}

.page-description {
  font-size: 13px;
  color: var(--slate-500);
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────
   Stat grid
───────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ─────────────────────────────────────────
   Content secties
───────────────────────────────────────── */

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.content-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.content-grid-wide {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.sidebar-badge {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.sidebar-link.active .sidebar-badge {
  background: rgba(255,255,255,.25);
  color: white;
}

/* ─────────────────────────────────────────
   Hamburger toggle knop
───────────────────────────────────────── */

.sidebar-toggle-btn {
  display: none; /* verborgen op desktop */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
  flex-shrink: 0;
  margin-right: 4px;
}
.sidebar-toggle-btn:hover { background: var(--slate-100); }

.sidebar-toggle-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--slate-600);
  border-radius: 2px;
  transition: transform .22s ease, opacity .16s ease;
  transform-origin: center;
}

/* Geanimeerd naar × wanneer open */
.sidebar-toggle-btn.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-toggle-btn.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.sidebar-toggle-btn.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─────────────────────────────────────────
   Sidebar backdrop (mobile overlay)
───────────────────────────────────────── */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 290;
  opacity: 0;
  pointer-events: none;          /* onzichtbaar → klikken gaan erdoorheen */
  transition: opacity .28s ease;
}
.sidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: all;           /* zichtbaar → klikken sluiten sidebar */
}

/* Scroll-lock wanneer sidebar open */
body.sidebar-is-open { overflow: hidden; }

/* ─────────────────────────────────────────
   Responsive — ≤ 1024px (tablet landscape)
───────────────────────────────────────── */

@media (max-width: 1024px) {
  .content-grid-3    { grid-template-columns: 1fr 1fr; }
  .content-grid-wide { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────
   Responsive — ≤ 768px (tablet portrait + mobile)
───────────────────────────────────────── */

@media (max-width: 768px) {

  /* Sidebar: schuift van links uit ── */
  .sidebar {
    transform: translateX(-232px);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    z-index: 300; /* boven topbar */
  }
  .sidebar.open { transform: translateX(0); }

  /* Backdrop actief op mobile */
  .sidebar-backdrop { display: block; }

  /* Main vult volle breedte */
  .app-main { margin-left: 0; }

  /* Hamburger zichtbaar */
  .sidebar-toggle-btn { display: flex; }

  /* Topbar compacter */
  .topbar { padding: 0 14px; gap: 0; }
  .topbar-title { font-size: 14px; }

  /* Page padding */
  .page-content { padding: 16px 16px 32px; }
  .page-alerts  { padding: 12px 16px 0; }

  /* Grids → single column */
  .content-grid,
  .content-grid-3 { grid-template-columns: 1fr; }

  /* Page header verticaal stapelen */
  .page-header {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-header-actions { width: 100%; }

  /* Stat grid kleinere minimum */
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
}

/* ─────────────────────────────────────────
   Responsive — ≤ 640px (kleine telefoons)
───────────────────────────────────────── */

@media (max-width: 640px) {
  .topbar         { padding: 0 12px; height: 52px; }
  .page-content   { padding: 12px 12px 28px; }
  .stat-grid      { grid-template-columns: 1fr 1fr; gap: 10px; }
  .topbar-actions { gap: 6px; }

  /* Topbar-actions: verberg labels, houd iconen */
  .topbar-actions .btn-text { display: none; }
}

/* ─────────────────────────────────────────
   Safe-area-inset — notch-telefoons (iPhone)
───────────────────────────────────────── */

@supports (padding: env(safe-area-inset-left)) {
  @media (max-width: 768px) {
    .topbar {
      padding-left:  max(14px, env(safe-area-inset-left));
      padding-right: max(14px, env(safe-area-inset-right));
    }
    .sidebar {
      padding-bottom: env(safe-area-inset-bottom);
    }
    .page-content {
      padding-bottom: max(32px, calc(28px + env(safe-area-inset-bottom)));
    }
  }
}

/* ─────────────────────────────────────────
   Multi-select filter dropdowns (.al-*)
───────────────────────────────────────── */

.al-filter-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px;
  background: white; border: 1.5px solid var(--slate-200);
  border-radius: 9px; font-size: 13px; font-weight: 500;
  color: var(--slate-600); cursor: pointer; white-space: nowrap;
  transition: border-color .15s, box-shadow .15s;
}
.al-filter-btn:hover { border-color: var(--slate-300); }
.al-filter-btn.active { border-color: #6366f1; color: #4f46e5; background: #f5f3ff; }
.al-filter-btn .al-badge {
  min-width: 18px; height: 18px; border-radius: 99px;
  background: #6366f1; color: white;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.al-filter-btn .al-caret { font-size: 9px; color: var(--slate-400); transition: transform .15s; }
.al-filter-btn.open .al-caret { transform: rotate(180deg); }

.al-dropdown {
  position: fixed; z-index: 9999;
  background: white; border: 1.5px solid var(--slate-200);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.1);
  padding: 8px 0; min-width: 180px; max-height: 280px;
  overflow-y: auto;
}
.al-dropdown-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; margin: 0 4px; font-size: 13px; color: var(--slate-700);
  cursor: pointer; transition: background .1s; user-select: none;
  border-radius: 7px;
}
.al-dropdown-item:hover { background: var(--slate-50); }
.al-dropdown-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: #6366f1; flex-shrink: 0; pointer-events: none; }
.al-dropdown-item.checked { background: #ede9fe; color: #4f46e5; font-weight: 600; }
.al-dropdown-item.checked:hover { background: #ddd6fe; }
.al-dropdown-divider { height: 1px; background: var(--slate-100); margin: 6px 0; }
.al-dropdown-clear {
  display: block; width: 100%; text-align: left;
  padding: 7px 14px; font-size: 12px; color: var(--slate-500);
  background: none; border: none; cursor: pointer;
}
.al-dropdown-clear:hover { color: #4f46e5; }
