/*
 * =============================================================================
 *  Project:   Badura GLANZ – panel v2
 *  Location:  /public/assets/css/app.css
 *  Function:  Brand theme on top of Bootstrap 6 (green #0A812E) and the panel
 *             layout: sidebar, top bar, right-hand drawer, lists, cards,
 *             portal and login pages. WCAG 2.2: visible focus, 24px targets.
 *  Version:   2.0.0
 *  Build:     2026.11.06.2215
 * =============================================================================
 */

/* ---------- brand tokens (override Bootstrap 6 primary) ---------- */
:root {
  --brand: #0A812E;
  --brand-dark: #065A20;
  --brand-light: #E7F4EB;
  --bs-primary-base: var(--brand);
  --bs-primary-bg: var(--brand);
  --bs-primary-fg: light-dark(#087028, #5fcf83);
  --bs-primary-fg-emphasis: light-dark(#054a1a, #a6e6bb);
  --bs-primary-bg-subtle: light-dark(#e7f4eb, #0d2a17);
  --bs-primary-bg-muted: light-dark(#cfe9d7, #134024);
  --bs-primary-border: light-dark(#8fd0a4, #1f6b39);
  --bs-primary-contrast: #fff;
  --bs-primary-focus-ring: color-mix(in oklch, var(--brand) 45%, transparent);
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --app-bg: light-dark(#f5f6f5, #0f1110);
  accent-color: var(--brand);
}

body.app { background: var(--app-bg); min-height: 100dvh; }
:focus-visible { outline: 3px solid var(--bs-primary-focus-ring); outline-offset: 2px; }
.skip-link { position: absolute; z-index: 2000; top: .5rem; left: .5rem; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
a:not([class*="btn-"]):not(.menu-item):not(.sidebar-link):not(.portal-link) { color: var(--bs-primary-fg); }
a[class*="btn-"] { text-decoration: none; }
.btn-solid, .btn-outline, .btn-subtle, .btn-text, .menu-item, .sidebar-link, .portal-link { min-height: 24px; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100dvh; }
.app-sidebar {
  width: var(--sidebar-w); background: #0f1a13; color: #d6e2da;
  border: 0; padding: 0; display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .app-sidebar { position: sticky; top: 0; height: 100dvh; flex: 0 0 var(--sidebar-w); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .75rem; }
.brand-link { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-weight: 700; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.app-sidebar .brand-text { color: #fff; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .75rem; }
.nav-section-title { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: #8fa596; margin: .75rem .5rem .35rem; }
.sidebar-link { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: .5rem; color: #d6e2da; text-decoration: none; font-weight: 500; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active { background: var(--brand); color: #fff; }
.sidebar-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.sidebar-footer { padding: .75rem 1rem; color: #8fa596; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 100; height: var(--topbar-h);
  display: flex; align-items: center; gap: .5rem; padding: 0 1rem;
  background: light-dark(rgba(255,255,255,.92), rgba(20,22,21,.92)); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bs-border-color, #e3e6e4);
}
.topbar-spacer { flex: 1; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; background: none; border: 0; padding: .25rem .5rem; border-radius: 999px; color: inherit; }
.user-chip:hover { background: var(--bs-bg-2); }
.avatar-initials { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-light); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.notif-count { position: absolute; top: 2px; right: 2px; font-size: .65rem; padding: .1rem .3rem; }
.impersonation-bar { background: #fff3cd; color: #664d03; padding: .4rem 1rem; display: flex; gap: .75rem; align-items: center; justify-content: center; font-weight: 500; position: sticky; top: 0; z-index: 1100; }

.app-content { padding: 1.25rem 1.25rem 3rem; max-width: 1400px; width: 100%; }
@media (min-width: 992px) { .app-content { padding: 1.5rem 2rem 3rem; } }
.page-header { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.breadcrumb { margin-bottom: .25rem; font-size: .85rem; }

/* ---------- cards, lists ---------- */
.card { background: light-dark(#fff, #161918); }
.panel-card { margin-bottom: 1.25rem; }
.panel-card > .card-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-weight: 600; }
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.25rem; }
.stat-card { padding: 1rem 1.1rem; border-radius: .75rem; background: light-dark(#fff, #161918); border: 1px solid var(--bs-border-color, #e3e6e4); text-decoration: none; color: inherit; display: block; }
.stat-card:hover { border-color: var(--brand); }
.stat-card .stat-label { color: var(--bs-fg-2); font-size: .85rem; display: flex; gap: .4rem; align-items: center; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .form-control { max-width: 260px; }
.table-wrap { background: light-dark(#fff, #161918); border: 1px solid var(--bs-border-color, #e3e6e4); border-radius: .75rem; overflow-x: auto; }
.table-wrap .table { margin: 0; }
.table td, .table th { vertical-align: middle; }
.table tr.row-link { cursor: pointer; }
.table .actions { white-space: nowrap; text-align: end; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bs-fg-2); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .6; }
.dl-grid { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: .4rem 1rem; margin: 0; }
.dl-grid dt { color: var(--bs-fg-2); font-weight: 500; }
.dl-grid dd { margin: 0; overflow-wrap: anywhere; }
.note-internal { background: light-dark(#fff8e6, #2a2414); border-left: 4px solid #e0a800; padding: .6rem .8rem; border-radius: .4rem; }
.note-internal::before { content: attr(data-label); display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: #8a6d00; margin-bottom: .2rem; }
.file-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.file-list li { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border: 1px solid var(--bs-border-color, #e3e6e4); border-radius: .5rem; }
.file-list a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--bs-border-color, #e3e6e4); }
.timeline li { position: relative; padding: 0 0 .9rem .75rem; }
.timeline li::before { content: ''; position: absolute; left: -1.4rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--brand); }
.items-table input.form-control { min-width: 80px; }
.money { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.totals { margin-left: auto; max-width: 360px; }
.totals .row-total { font-weight: 700; border-top: 2px solid currentColor; }

/* ---------- drawer (right-hand edit panel) ---------- */
.app-drawer { --bs-drawer-width: min(480px, 100vw); }
.app-drawer.drawer-wide { --bs-drawer-width: min(820px, 100vw); }
@media (max-width: 575.98px) { .app-drawer, .app-drawer.drawer-wide { --bs-drawer-width: 100vw; } }
.app-drawer .drawer-header { gap: .5rem; border-bottom: 1px solid var(--bs-border-color, #e3e6e4); }
.app-drawer .drawer-title { flex: 1; }
.app-drawer .drawer-body { padding-bottom: 6rem; }
.app-drawer .form-actions { position: sticky; bottom: -1px; background: inherit; padding: .75rem 0; border-top: 1px solid var(--bs-border-color, #e3e6e4); margin-top: 1rem; background: light-dark(#fff, #161918); }
.drawer-loading { display: grid; place-items: center; min-height: 200px; }
.app-form .form-field { margin-bottom: .9rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 575.98px) { .form-grid { grid-template-columns: 1fr; } }
fieldset.form-section { border: 0; padding: 0; margin: 0 0 1rem; }
fieldset.form-section > legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-fg-2); font-weight: 700; margin-bottom: .6rem; }

/* ---------- toasts ---------- */
.app-toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display: grid; gap: .5rem; }
.app-toast { min-width: 260px; max-width: 420px; padding: .75rem 1rem; border-radius: .6rem; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; gap: .6rem; align-items: start; }
.app-toast.success { background: #0b7a2d; } .app-toast.danger { background: #b42318; }
.app-toast.warning { background: #9a6700; } .app-toast.info { background: #1d4ed8; }
.app-toast button { background: none; border: 0; color: inherit; margin-left: auto; font-size: 1.1rem; line-height: 1; }

/* ---------- portal ---------- */
.portal-topbar { background: light-dark(#fff, #161918); border-bottom: 1px solid var(--bs-border-color, #e3e6e4); position: sticky; top: 0; z-index: 100; }
.portal-inner { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.portal-topbar .portal-inner { display: flex; align-items: center; gap: 1rem; min-height: var(--topbar-h); }
.portal-nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.portal-link { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .7rem; border-radius: .5rem; color: var(--bs-fg-1); text-decoration: none; white-space: nowrap; font-weight: 500; }
.portal-link:hover { background: var(--bs-bg-2); }
.portal-link.active { background: var(--brand-light); color: var(--brand-dark); }
@media (max-width: 767.98px) {
  .portal-link span { display: none; }
  .portal-topbar .brand-text { display: none; }
}

/* ---------- auth ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-content: center; padding: 1rem; background: radial-gradient(circle at 20% 10%, #e7f4eb, transparent 50%), var(--app-bg); }
.auth-card { width: min(420px, 92vw); border-radius: 1rem; box-shadow: 0 12px 40px rgba(10,129,46,.12); }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.25rem; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--brand); }
.qr-box svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: .5rem; }
.backup-codes { columns: 2; font-family: ui-monospace, monospace; font-size: 1rem; }

/* ---------- calendar, map ---------- */
.calendar-wrap { background: light-dark(#fff, #161918); border: 1px solid var(--bs-border-color, #e3e6e4); border-radius: .75rem; padding: 1rem; }
.fc .fc-button-primary { background: var(--brand); border-color: var(--brand); }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.map-box { height: 300px; border-radius: .6rem; border: 1px solid var(--bs-border-color, #e3e6e4); }

@media print {
  .app-sidebar, .app-topbar, .page-actions, .toolbar, .app-drawer { display: none !important; }
  .app-content { padding: 0; }
}
.worker-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--dot, #0A812E); vertical-align: middle; }
.mail-preview { width: 100%; min-height: 420px; border: 1px solid var(--bs-border-color, #e3e6e4); border-radius: .5rem; background: #fff; }

/* ---------- fixes after visual review (2.0.0) ---------- */
/* Bootstrap 6 sets a layered `background-color: transparent !important` on
   .lg:drawer, which unlayered CSS cannot override – paint with an image. */
.app-sidebar { --bs-drawer-bg: #0f1a13; --bs-drawer-color: #d6e2da; background-image: linear-gradient(#0f1a13, #0f1a13); color: #d6e2da; }
.app-sidebar .nav-section-title { color: #8fa596; }
.card-header.d-flex { flex-direction: row; text-align: start; }
.stat-card > i { display: block; font-size: 1.35rem; color: var(--brand); margin-bottom: .15rem; }
.stat-card .stat-label { flex-wrap: wrap; }
.card-body.timeline { margin: 1rem 1rem 1rem 1.75rem; padding: 0 0 0 1rem; }
