/* ============================================================
   🧱 layout.css — SPA layout (BOOTSTRAP-FIRST)
   Verhaaf DEF — 2025
============================================================ */

/* ------------------------------------------------------------
   🌍 Root & theming
------------------------------------------------------------ */
:root {
  --accent: #0d6efd;
  --accent-strong: #0b5ed7;

  --surface: #ffffff;
  --surface-muted: #f5f7fb;

  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;

  --shadow-sm: 0 6px 14px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 36px rgba(0, 0, 0, 0.18);
}

html,
body {
  height: 100%;
  background-color: #f6f7f9;
}

/* ------------------------------------------------------------
   🌐 SPA shell
------------------------------------------------------------ */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   📦 Content area
   De SPA gebruikt de volledige viewportbreedte. Pagina-templates
   mogen Bootstrap containers blijven gebruiken, maar niet opnieuw
   de inhoud centreren en versmallen binnen deze shell.
------------------------------------------------------------ */
#app-content {
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.75rem;
}

#app-content > .container,
#app-content > .container-fluid,
#app-content > .container-sm,
#app-content > .container-md,
#app-content > .container-lg,
#app-content > .container-xl,
#app-content > .container-xxl,
#app-content > * > .container,
#app-content > * > .container-fluid,
#app-content > * > .container-sm,
#app-content > * > .container-md,
#app-content > * > .container-lg,
#app-content > * > .container-xl,
#app-content > * > .container-xxl {
  width: 100%;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

/* Tablet */
@media (min-width: 768px) {
  #app-content {
    padding: 1rem 1.25rem;
  }
}

@media (max-width: 767.98px) {
  html,
  body {
    overflow-x: hidden;
  }

  #app-content {
    padding: 0.75rem;
  }
}

/* Desktop */
@media (min-width: 1200px) {
  #app-content {
    padding: 1.25rem 1.5rem;
  }
}

@media (min-width: 1600px) {
  #app-content {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Extra ruimte om de onderste knoppen boven het tablettoetsenbord te scrollen. */
@media screen {
  #app-content::after {
    content: "";
    display: block;
    clear: both;
    height: calc(max(24rem, 50vh) + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
  }
}

/* ------------------------------------------------------------
   🧭 Navigatiebalk
------------------------------------------------------------ */
.app-nav-bar {
  position: sticky;
  top: 0;
  z-index: 1020; /* onder modals/toasts, boven content */
  overflow: visible;
  isolation: isolate;

  background: linear-gradient(90deg, #0b0c10 0%, #131720 100%);
  color: #fff;

  border-bottom: 1px solid #1f2937;
  box-shadow: var(--shadow-md);
}

.app-nav-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  min-height: 72px;
}

/* Brand */
.app-nav-bar .brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
}

.nav-toggle {
  display: none;
  margin-left: 0.75rem;
  min-height: 48px;
  min-width: 48px;
}

/* Navigatie links */
.app-nav-links {
  display: flex;
  flex: 1 1 520px;
  min-width: 0;
  gap: 0.5rem 0.75rem;
  justify-content: flex-start;
  flex-wrap: wrap;
  overflow: visible;
  padding: 0.15rem 0;
  background: transparent;
  border: 0;
  position: relative;
}


/* Links */
.app-nav-bar .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;

  padding: clamp(0.4rem, 0.9vw, 0.5rem) clamp(0.6rem, 1.2vw, 0.85rem);
  border-radius: 8px;

  background: transparent;
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  min-height: 48px;
  text-decoration: none;

  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.app-nav-bar .nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.app-nav-bar .nav-link.is-active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.app-nav-bar .nav-link.is-active i {
  color: #f8fafc;
}

.nav-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-group::after {
  content: "";
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  height: 8px; /* hover-bridge to submenu */
}

.nav-group-main {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-caret:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.nav-group.has-active .nav-caret {
  border-color: rgba(255, 255, 255, 0.35);
}

.nav-submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  padding: 0.5rem;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 1040;
  transform: translateY(0.35rem);
}

.app-nav-bar .nav-submenu .nav-link {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-weight: 500;
}

.nav-group.is-open .nav-submenu,
.nav-group:hover .nav-submenu {
  display: block;
}

@media (hover: hover) and (pointer: fine) {
  .nav-group:focus-within .nav-submenu,
  .nav-submenu:hover {
    display: block;
  }
}

.nav-muted {
  color: #cbd5e1;
}

.global-storing-alert {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f172a;
}

.global-storing-alert__button {
  width: 100%;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 0.55rem 1rem;
  font: inherit;
}

.global-storing-alert__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
}

.global-storing-alert__text {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.global-storing-alert__action {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.global-storing-alert.is-open {
  background: #1e40af;
}

.global-storing-alert.is-urgent {
  background: #b45309;
}

.global-storing-alert.is-critical {
  background: #991b1b;
}

@media (max-width: 767.98px) {
  .global-storing-alert__button {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .global-storing-alert__text {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
}

/* User section */
.nav-user {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

/* ------------------------------------------------------------
   📱 Navigatie responsive gedrag
------------------------------------------------------------ */
@media (max-width: 991.98px) {
  html.nav-lock,
  body.nav-lock {
    overflow: hidden;
    touch-action: none;
  }

  .app-nav-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .brand-wrap {
    width: 100%;
    justify-content: space-between;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .app-nav-links {
    width: 100%;
    justify-content: flex-start;
    flex-direction: column;
    align-items: stretch;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
    background: transparent;
    border: 0;
    padding: 0;
  }

  .app-nav-bar.nav-open .app-nav-links {
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-nav-bar .nav-link {
    width: 100%;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
  }

  .nav-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .nav-group-main {
    width: 100%;
    justify-content: space-between;
  }

  .nav-submenu {
    position: static;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    display: none;
  }

  .nav-group:hover .nav-submenu {
    display: none;
  }

  .nav-group.is-open .nav-submenu {
    display: block;
  }

  .app-nav-bar .nav-submenu .nav-link {
    justify-content: flex-start;
    padding-left: 1rem;
  }

  .nav-user {
    width: 100%;
    justify-content: flex-start;
    display: none;
  }

  .app-nav-bar.nav-open .nav-user {
    display: flex;
  }

  .app-nav-bar.nav-open {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .app-nav-bar.nav-open .container-fluid {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
  }

  .app-nav-bar.nav-open .app-nav-inner {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .app-nav-bar.nav-open .app-nav-links {
    min-height: 0;
    padding-bottom: 0.25rem;
  }

  .app-nav-bar.nav-open .nav-user {
    flex: 0 0 auto;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ------------------------------------------------------------
   📱 Responsive tables (stacked on small screens)
------------------------------------------------------------ */
@media (max-width: 767.98px) {
  .table-responsive {
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .table-responsive table {
    border: 0;
  }

  .table-responsive thead {
    display: none;
  }

  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td {
    display: block;
    width: 100%;
  }

  .table-responsive tr {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
  }

  .table-responsive td {
    padding: 0.4rem 0;
    border: 0;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    white-space: normal !important;
  }

  .table-responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted, #6b7280);
    margin-right: 0.75rem;
    white-space: normal;
  }

  .table-responsive td[colspan] {
    display: block;
    text-align: center;
  }

  .table-responsive td[colspan]::before {
    content: "";
    margin: 0;
  }

  .table-responsive td:last-child {
    padding-bottom: 0;
  }
}

/* ------------------------------------------------------------
   🪟 Generieke modal (fallback / custom)
   → Bootstrap modal is leidend waar mogelijk
------------------------------------------------------------ */
.fles-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;

  display: flex;
  align-items: center;
  justify-content: center;
}

/* Backdrop */
.fles-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
}

/* Dialog */
.fles-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  padding: 0.75rem;

  display: flex;
  justify-content: center;
}

/* Card */
.fles-modal__card {
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;

  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
}

/* Header */
.fles-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Meta */
.fles-modal__meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Form */
.fles-modal__form .form-label {
  font-weight: 600;
}

.fles-modal__form input,
.fles-modal__form select {
  min-height: 44px;
}

/* Status */
#modal-status {
  border-radius: 10px;
}

/* ------------------------------------------------------------
   📱 Modal responsive
------------------------------------------------------------ */
@media (max-width: 991.98px) {
  .fles-modal__card {
    padding: 1rem;
    border-radius: 14px;
  }
}

@media (max-width: 575.98px) {
  .fles-modal__dialog {
    padding: 0.5rem;
  }

  .fles-modal__card {
    border-radius: 12px;
  }
}
