/* ============================================================================
   assets/css/app.css  -  single stylesheet for the whole platform
   ----------------------------------------------------------------------------
   * ALL colours come from the CSS variables in :root / [data-theme="dark"].
     Never hard-code a colour in a page or component: use var(--...).
   * Theme switch: set  <html data-theme="light|dark">  AND  data-bs-theme="same".
     Colours are palette: white / dark blue / green (green only for accents).
   * Admin can override --c-primary / --c-accent from settings (layout prints
     an inline <style>:root{--c-primary:...}</style> after this file).
   * Load order: bootstrap.min.css -> datatables css -> sweetalert2 -> nprogress -> app.css
   ========================================================================== */

/* ---------- 1. THEME TOKENS ---------- */
:root, [data-theme="light"] {
  --c-primary:        #0b2a5b;   /* dark blue */
  --c-primary-hover:  #081f45;
  --c-primary-soft:   #e6ecf7;
  --c-on-primary:     #ffffff;
  --c-accent:         #1e9e5a;   /* green: small highlights, success, prices */
  --c-accent-hover:   #17824a;
  --c-accent-soft:    #e3f5ec;
  --c-bg:             #f4f6fb;
  --c-surface:        #ffffff;
  --c-surface-2:      #f0f3f9;
  --c-border:         #dde3ef;
  --c-text:           #14213d;
  --c-text-muted:     #5b6785;
  --c-link:           #0b2a5b;
  --c-danger:         #c62f3e;
  --c-danger-soft:    #fde8ea;
  --c-warning:        #b7791f;
  --c-warning-soft:   #fdf3dc;
  --c-info:           #1f6fb2;
  --c-info-soft:      #e4f1fb;
  --c-overlay:        rgba(8, 20, 45, .55);
  --c-skeleton-a:     #e8ecf5;
  --c-skeleton-b:     #f6f8fc;
  --shadow-sm:        0 1px 2px rgba(11, 42, 91, .08);
  --shadow-md:        0 6px 20px rgba(11, 42, 91, .10);
  --radius:           14px;
  --radius-sm:        10px;
  --radius-pill:      999px;
  --topbar-h:         60px;
  --sidebar-w:        260px;
  --bottomnav-h:      58px;
  --font-body:        system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --c-primary:        #3d7bd9;   /* lighter blue so buttons stay readable on dark blue */
  --c-primary-hover:  #5b92e6;
  --c-primary-soft:   #14305f;
  --c-on-primary:     #ffffff;
  --c-accent:         #3ccf84;
  --c-accent-hover:   #5ddc9b;
  --c-accent-soft:    #0f3a2a;
  --c-bg:             #071a3a;   /* dark blue page */
  --c-surface:        #0c2450;
  --c-surface-2:      #10305f;
  --c-border:         #1c3d73;
  --c-text:           #eaf0fb;
  --c-text-muted:     #9fb0d0;
  --c-link:           #8db6f5;
  --c-danger:         #ff6b78;
  --c-danger-soft:    #44151c;
  --c-warning:        #f2c261;
  --c-warning-soft:   #43330f;
  --c-info:           #6cb4ee;
  --c-info-soft:      #0f3050;
  --c-overlay:        rgba(0, 8, 24, .72);
  --c-skeleton-a:     #10305f;
  --c-skeleton-b:     #163b72;
  --shadow-sm:        0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md:        0 8px 24px rgba(0, 0, 0, .40);
  color-scheme: dark;
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
a { color: var(--c-link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { color: var(--c-text); font-weight: 650; line-height: 1.25; }
.text-muted, .text-body-secondary { color: var(--c-text-muted) !important; }
.text-accent { color: var(--c-accent) !important; }
.text-primary-brand { color: var(--c-primary) !important; }
.bg-surface { background: var(--c-surface) !important; }
.bg-surface-2 { background: var(--c-surface-2) !important; }
.bg-primary-soft { background: var(--c-primary-soft) !important; }
.bg-accent-soft { background: var(--c-accent-soft) !important; }
.border-theme { border-color: var(--c-border) !important; }
.fw-600 { font-weight: 600; }
.price { color: var(--c-accent); font-weight: 700; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--c-primary) 55%, transparent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--c-primary); color: var(--c-on-primary); padding: .5rem 1rem; z-index: 3000; }
.skip-link:focus { left: 0; }
::selection { background: var(--c-primary); color: var(--c-on-primary); }

/* ---------- 3. BOOTSTRAP 5 OVERRIDES (map Bootstrap onto our tokens) ---------- */
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
  --bs-body-bg: var(--c-bg);
  --bs-body-color: var(--c-text);
  --bs-border-color: var(--c-border);
  --bs-link-color: var(--c-link);
  --bs-primary: var(--c-primary);
  --bs-success: var(--c-accent);
  --bs-danger: var(--c-danger);
  --bs-border-radius: var(--radius-sm);
  --bs-secondary-color: var(--c-text-muted);
  --bs-emphasis-color: var(--c-text);
  --bs-tertiary-bg: var(--c-surface-2);
}
.btn { border-radius: var(--radius-sm); font-weight: 600; padding: .5rem 1rem; min-height: 40px; }
.btn-sm { min-height: 32px; padding: .25rem .65rem; }
.btn-lg { min-height: 48px; }
.btn-primary { --bs-btn-bg: var(--c-primary); --bs-btn-border-color: var(--c-primary); --bs-btn-color: var(--c-on-primary);
  --bs-btn-hover-bg: var(--c-primary-hover); --bs-btn-hover-border-color: var(--c-primary-hover); --bs-btn-hover-color: var(--c-on-primary);
  --bs-btn-active-bg: var(--c-primary-hover); --bs-btn-active-border-color: var(--c-primary-hover); --bs-btn-disabled-bg: var(--c-primary); --bs-btn-disabled-border-color: var(--c-primary); }
.btn-success { --bs-btn-bg: var(--c-accent); --bs-btn-border-color: var(--c-accent); --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--c-accent-hover); --bs-btn-hover-border-color: var(--c-accent-hover); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--c-accent-hover); --bs-btn-active-border-color: var(--c-accent-hover); }
.btn-outline-primary { --bs-btn-color: var(--c-primary); --bs-btn-border-color: var(--c-primary); --bs-btn-hover-bg: var(--c-primary); --bs-btn-hover-border-color: var(--c-primary); --bs-btn-hover-color: var(--c-on-primary); --bs-btn-active-bg: var(--c-primary); --bs-btn-active-color: var(--c-on-primary); }
.btn-outline-secondary { --bs-btn-color: var(--c-text-muted); --bs-btn-border-color: var(--c-border); --bs-btn-hover-bg: var(--c-surface-2); --bs-btn-hover-color: var(--c-text); --bs-btn-hover-border-color: var(--c-border); --bs-btn-active-bg: var(--c-surface-2); --bs-btn-active-color: var(--c-text); }
.btn-outline-danger { --bs-btn-color: var(--c-danger); --bs-btn-border-color: var(--c-danger); --bs-btn-hover-bg: var(--c-danger); --bs-btn-hover-border-color: var(--c-danger); }
.btn-light { --bs-btn-bg: var(--c-surface-2); --bs-btn-border-color: var(--c-border); --bs-btn-color: var(--c-text); --bs-btn-hover-bg: var(--c-border); --bs-btn-hover-color: var(--c-text); }
.btn-link { color: var(--c-link); }
.btn-ghost { background: transparent; border: 0; color: var(--c-text-muted); }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-icon { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }

.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; color: var(--c-text); }
.form-control, .form-select {
  background-color: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); min-height: 44px; font-size: 16px; /* 16px stops iOS zoom */
}
textarea.form-control { min-height: 90px; }
.form-control::placeholder { color: var(--c-text-muted); opacity: .8; }
.form-control:focus, .form-select:focus { background-color: var(--c-surface); color: var(--c-text); border-color: var(--c-primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--c-primary) 25%, transparent); }
.form-control:disabled, .form-select:disabled { background: var(--c-surface-2); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--c-danger); background-image: none; }
.invalid-feedback { color: var(--c-danger); font-size: .85rem; }
.form-text { color: var(--c-text-muted); }
.form-check-input { border-color: var(--c-border); background-color: var(--c-surface); }
.form-check-input:checked { background-color: var(--c-primary); border-color: var(--c-primary); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; }
.input-group-text { background: var(--c-surface-2); color: var(--c-text-muted); border-color: var(--c-border); }

.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--c-text); }
.card-header, .card-footer { background: transparent; border-color: var(--c-border); }
.list-group-item { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.list-group-item-action:hover { background: var(--c-surface-2); color: var(--c-text); }
.dropdown-menu { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); color: var(--c-text); }
.dropdown-item { color: var(--c-text); padding: .55rem 1rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--c-surface-2); color: var(--c-text); }
.dropdown-divider { border-color: var(--c-border); }
.modal-content { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--c-border); }
.modal-backdrop { --bs-backdrop-bg: #000; }
.btn-close { filter: none; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.nav-tabs { border-color: var(--c-border); }
.nav-tabs .nav-link { color: var(--c-text-muted); border: 0; border-bottom: 3px solid transparent; font-weight: 600; }
.nav-tabs .nav-link:hover { color: var(--c-text); }
.nav-tabs .nav-link.active { background: transparent; color: var(--c-primary); border-bottom-color: var(--c-accent); }
.nav-pills .nav-link { color: var(--c-text-muted); border-radius: var(--radius-pill); font-weight: 600; }
.nav-pills .nav-link.active { background: var(--c-primary); color: var(--c-on-primary); }
.badge { font-weight: 600; border-radius: var(--radius-pill); }
.badge.bg-primary { background: var(--c-primary) !important; color: var(--c-on-primary); }
.badge.bg-success { background: var(--c-accent) !important; }
.badge-soft-success { background: var(--c-accent-soft); color: var(--c-accent); }
.badge-soft-danger  { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-soft-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-soft-info    { background: var(--c-info-soft); color: var(--c-info); }
.badge-soft-primary { background: var(--c-primary-soft); color: var(--c-link); }
.badge-soft-secondary { background: var(--c-surface-2); color: var(--c-text-muted); }
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; }
.alert-success { background: var(--c-accent-soft); color: var(--c-accent); border-color: var(--c-accent); }
.alert-danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: var(--c-danger); }
.alert-warning { background: var(--c-warning-soft); color: var(--c-warning); border-color: var(--c-warning); }
.alert-info { background: var(--c-info-soft); color: var(--c-info); border-color: var(--c-info); }
.page-link { background: var(--c-surface); color: var(--c-link); border-color: var(--c-border); min-width: 40px; text-align: center; }
.page-link:hover { background: var(--c-surface-2); color: var(--c-link); }
.page-item.active .page-link { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.page-item.disabled .page-link { background: var(--c-surface-2); color: var(--c-text-muted); border-color: var(--c-border); }
.progress { background: var(--c-surface-2); border-radius: var(--radius-pill); }
.progress-bar { background: var(--c-accent); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--c-text); --bs-table-border-color: var(--c-border); --bs-table-striped-bg: var(--c-surface-2); --bs-table-hover-bg: var(--c-surface-2); --bs-table-hover-color: var(--c-text); --bs-table-striped-color: var(--c-text); }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); font-weight: 700; white-space: nowrap; }
.toast { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); }
.tooltip { --bs-tooltip-bg: var(--c-primary); }
hr { border-color: var(--c-border); opacity: 1; }
code { color: var(--c-accent); }

/* ---------- 4. LAYOUT SHELL ---------- */
.app-topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
}
.app-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.1rem; color: var(--c-primary); text-decoration: none !important; min-width: 0; }
[data-theme="dark"] .app-brand { color: var(--c-text); }
.app-brand img { height: 34px; width: auto; }
.app-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.app-search { flex: 1 1 auto; max-width: 480px; position: relative; }
.app-search .form-control { border-radius: var(--radius-pill); background: var(--c-surface-2); padding-left: 2.6rem; min-height: 40px; }
.app-search .search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); pointer-events: none; }
.search-dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-md); max-height: 70vh; overflow-y: auto; z-index: 1040; display: none; }
.search-dropdown.show { display: block; }
.search-dropdown .group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-muted); padding: .6rem 1rem .2rem; font-weight: 700; }
.search-dropdown a { display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; color: var(--c-text); }
.search-dropdown a:hover { background: var(--c-surface-2); text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.topbar-actions .btn-icon { position: relative; color: var(--c-text-muted); background: transparent; border: 0; }
.topbar-actions .btn-icon:hover { background: var(--c-surface-2); color: var(--c-text); }
.count-dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--c-danger); color: #fff; font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.count-dot:empty, .count-dot[data-count="0"] { display: none; }

.app-body { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.app-sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--c-surface); border-right: 1px solid var(--c-border);
  padding: 1rem .75rem; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
}
.app-sidebar .menu-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); font-weight: 700; padding: .9rem .75rem .3rem; }
.side-link { display: flex; align-items: center; gap: .8rem; padding: .65rem .85rem; border-radius: var(--radius-sm); color: var(--c-text); font-weight: 600; text-decoration: none !important; }
.side-link i { width: 1.25rem; text-align: center; color: var(--c-text-muted); }
.side-link:hover { background: var(--c-surface-2); }
.side-link.active { background: var(--c-primary-soft); color: var(--c-primary); }
[data-theme="dark"] .side-link.active { color: var(--c-text); }
.side-link.active i { color: var(--c-accent); }
.side-link .badge { margin-left: auto; }
.app-main { flex: 1 1 auto; min-width: 0; padding: 1.25rem; }
.app-container { max-width: 1100px; margin: 0 auto; }
.app-container-narrow { max-width: 720px; margin: 0 auto; }
.app-right { width: 300px; flex: 0 0 300px; padding: 1.25rem 1.25rem 1.25rem 0; position: sticky; top: var(--topbar-h); align-self: flex-start; max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.page-header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; margin: 0; }
.app-footer { border-top: 1px solid var(--c-border); background: var(--c-surface); padding: 1.5rem 1rem; color: var(--c-text-muted); font-size: .9rem; }
.app-footer a { color: var(--c-text-muted); }

/* Sidebar as off-canvas drawer on phones/tablets + bottom navigation */
.sidebar-backdrop { position: fixed; inset: 0; background: var(--c-overlay); z-index: 1039; display: none; }
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
  .app-sidebar { position: fixed; z-index: 1040; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-md); padding-top: 1.25rem; }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
  .app-right { display: none; }
  .app-main { padding: .9rem; padding-bottom: calc(var(--bottomnav-h) + 1rem); }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; height: var(--bottomnav-h);
    background: var(--c-surface); border-top: 1px solid var(--c-border); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .68rem; font-weight: 600; color: var(--c-text-muted); text-decoration: none; position: relative; }
  .bottom-nav a i { font-size: 1.15rem; }
  .bottom-nav a.active { color: var(--c-primary); }
  [data-theme="dark"] .bottom-nav a.active { color: var(--c-accent); }
  .bottom-nav a.active i { color: var(--c-accent); }
  .app-search { max-width: none; }
  .app-brand span { max-width: 28vw; }
}
@media (max-width: 575.98px) {
  .app-topbar { padding: 0 .6rem; gap: .4rem; }
  .app-search.collapsible { display: none; }
  .app-search.collapsible.open { display: block; position: absolute; left: .6rem; right: .6rem; top: calc(var(--topbar-h) - 8px); max-width: none; }
  .page-header h1 { font-size: 1.25rem; }
}

/* ---------- 5. AVATARS ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--c-primary-soft); color: var(--c-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; overflow: hidden; border: 2px solid var(--c-surface); }
[data-theme="dark"] .avatar { color: var(--c-text); }
.avatar-sm { width: 30px; height: 30px; font-size: .75rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 110px; height: 110px; font-size: 2.2rem; border-width: 4px; }
.avatar-square { border-radius: var(--radius-sm); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -10px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- 6. FEED / POST CARD ---------- */
.composer { padding: 1rem; }
.composer textarea { border: 0; background: var(--c-surface-2); border-radius: var(--radius); resize: none; }
.post-card { margin-bottom: 1rem; }
.post-card .post-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem .4rem; }
.post-card .post-author { font-weight: 700; color: var(--c-text); }
.post-card .post-meta { font-size: .8rem; color: var(--c-text-muted); }
.post-card .post-body { padding: .25rem 1rem .75rem; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.post-card .post-media { display: grid; gap: 2px; background: var(--c-surface-2); }
.post-card .post-media.n1 { grid-template-columns: 1fr; }
.post-card .post-media.n2 { grid-template-columns: 1fr 1fr; }
.post-card .post-media.n3, .post-card .post-media.n4 { grid-template-columns: 1fr 1fr; }
.post-card .post-media img { width: 100%; height: 100%; max-height: 520px; object-fit: cover; cursor: zoom-in; display: block; }
.post-card .post-stats { display: flex; justify-content: space-between; padding: .5rem 1rem; font-size: .85rem; color: var(--c-text-muted); border-bottom: 1px solid var(--c-border); }
.post-card .post-actions { display: flex; padding: .25rem .5rem; }
.post-card .post-actions button { flex: 1; background: transparent; border: 0; padding: .6rem; border-radius: var(--radius-sm); font-weight: 600; color: var(--c-text-muted); min-height: 44px; }
.post-card .post-actions button:hover { background: var(--c-surface-2); color: var(--c-text); }
.post-card .post-actions button.active { color: var(--c-accent); }
.post-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; padding: .15rem .6rem; border-radius: var(--radius-pill); }
.post-badge.announcement { background: var(--c-danger-soft); color: var(--c-danger); }
.post-badge.event { background: var(--c-info-soft); color: var(--c-info); }
.post-badge.promotion, .post-badge.listing { background: var(--c-accent-soft); color: var(--c-accent); }
.post-badge.opportunity { background: var(--c-warning-soft); color: var(--c-warning); }
.comments-wrap { padding: .5rem 1rem 1rem; }
.comment { display: flex; gap: .6rem; margin-bottom: .75rem; }
.comment .bubble { background: var(--c-surface-2); border-radius: var(--radius); padding: .5rem .8rem; max-width: 100%; word-wrap: break-word; overflow-wrap: anywhere; }
.comment .bubble .who { font-weight: 700; font-size: .85rem; }
.comment .comment-meta { font-size: .75rem; color: var(--c-text-muted); padding-left: .8rem; }
.comment .replies { margin-left: 2.4rem; margin-top: .5rem; }

/* ---------- 7. ENTITY CARDS (business / group / listing / event / opportunity) ---------- */
.entity-card { height: 100%; display: flex; flex-direction: column; overflow: hidden; transition: transform .15s ease, box-shadow .15s ease; }
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.entity-card .entity-cover { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--c-primary-soft), var(--c-accent-soft)); overflow: hidden; }
.entity-card .entity-cover img { width: 100%; height: 100%; object-fit: cover; }
.entity-card .entity-logo { position: absolute; left: 1rem; bottom: -24px; width: 56px; height: 56px; border-radius: var(--radius-sm); background: var(--c-surface); border: 3px solid var(--c-surface); object-fit: cover; box-shadow: var(--shadow-sm); }
.entity-card .entity-body { padding: 1rem; flex: 1 1 auto; display: flex; flex-direction: column; gap: .35rem; }
.entity-card .entity-body.has-logo { padding-top: 2rem; }
.entity-card .entity-title { font-weight: 700; font-size: 1.02rem; color: var(--c-text); margin: 0; }
.entity-card .entity-sub { color: var(--c-text-muted); font-size: .85rem; }
.entity-card .entity-foot { padding: .75rem 1rem; border-top: 1px solid var(--c-border); display: flex; gap: .5rem; align-items: center; justify-content: space-between; }
.entity-card .ribbon { position: absolute; top: .6rem; left: .6rem; }
.verified-badge { color: var(--c-accent); }
.rating-stars { color: var(--c-warning); letter-spacing: 1px; }
.rating-input { display: inline-flex; flex-direction: row-reverse; gap: .15rem; }
.rating-input input { display: none; }
.rating-input label { font-size: 1.6rem; color: var(--c-border); cursor: pointer; }
.rating-input input:checked ~ label, .rating-input label:hover, .rating-input label:hover ~ label { color: var(--c-warning); }

.profile-cover { height: 200px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); background-size: cover; background-position: center; }
.profile-head { padding: 0 1.25rem 1rem; margin-top: -55px; display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.profile-stats { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.profile-stats strong { display: block; font-size: 1.1rem; color: var(--c-text); }
.profile-stats span { font-size: .8rem; color: var(--c-text-muted); }
@media (max-width: 575.98px) { .profile-cover { height: 140px; } }

.date-chip { width: 56px; text-align: center; border-radius: var(--radius-sm); background: var(--c-primary-soft); color: var(--c-primary); padding: .35rem 0; flex: 0 0 auto; line-height: 1.1; }
[data-theme="dark"] .date-chip { color: var(--c-text); }
.date-chip .d { font-size: 1.35rem; font-weight: 800; display: block; }
.date-chip .m { font-size: .7rem; text-transform: uppercase; font-weight: 700; color: var(--c-accent); }

.priority-urgent { border-left: 5px solid var(--c-danger); }
.priority-high { border-left: 5px solid var(--c-warning); }
.priority-normal { border-left: 5px solid var(--c-primary); }
.priority-low { border-left: 5px solid var(--c-border); }

.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .85rem; border-radius: var(--radius-pill); background: var(--c-surface-2); border: 1px solid var(--c-border); color: var(--c-text); font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.chip:hover { border-color: var(--c-primary); }
.chip.active { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.chip-row { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: thin; }

.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.filter-bar .form-control, .filter-bar .form-select { flex: 1 1 160px; min-width: 0; }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.gallery-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); cursor: zoom-in; }

.hours-list { list-style: none; padding: 0; margin: 0; }
.hours-list li { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed var(--c-border); }
.hours-list li.today { font-weight: 700; color: var(--c-accent); }

/* ---------- 8. NOTIFICATIONS & MESSAGING ---------- */
.notif-item { display: flex; gap: .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--c-border); color: var(--c-text); text-decoration: none !important; }
.notif-item:hover { background: var(--c-surface-2); }
.notif-item.unread { background: var(--c-primary-soft); }
.notif-item .notif-icon { width: 38px; height: 38px; border-radius: 50%; background: var(--c-accent-soft); color: var(--c-accent); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.notif-dropdown { width: 360px; max-width: calc(100vw - 1.5rem); padding: 0; }
.notif-dropdown .notif-list { max-height: 60vh; overflow-y: auto; }

.chat-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--topbar-h) - 2.5rem); min-height: 420px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--c-border); overflow-y: auto; }
.chat-list .chat-item { display: flex; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid var(--c-border); cursor: pointer; color: var(--c-text); }
.chat-list .chat-item:hover, .chat-list .chat-item.active { background: var(--c-surface-2); }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: .8rem 1rem; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: .7rem; }
.chat-messages { flex: 1 1 auto; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; background: var(--c-bg); }
.msg { max-width: 78%; padding: .5rem .85rem; border-radius: 18px; background: var(--c-surface); border: 1px solid var(--c-border); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.msg .time { display: block; font-size: .68rem; opacity: .75; margin-top: .15rem; }
.chat-form { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--c-border); }
@media (max-width: 767.98px) {
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - 1.5rem); }
  .chat-layout .chat-pane { display: none; }
  .chat-layout.in-thread .chat-list { display: none; }
  .chat-layout.in-thread .chat-pane { display: flex; }
}

/* ---------- 9. EMPTY / ERROR / LOADING STATES ---------- */
.state-box { text-align: center; padding: 2.5rem 1rem; color: var(--c-text-muted); }
.state-box .state-icon { font-size: 2.6rem; margin-bottom: .75rem; color: var(--c-primary); opacity: .55; }
.state-box.error .state-icon { color: var(--c-danger); opacity: .8; }
.state-box h3 { font-size: 1.1rem; color: var(--c-text); }
.skeleton { position: relative; overflow: hidden; background: var(--c-skeleton-a); border-radius: var(--radius-sm); min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--c-skeleton-b), transparent); animation: skeleton-shimmer 1.3s infinite; }
@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }
.skeleton-line { height: 12px; margin-bottom: .55rem; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-img { aspect-ratio: 16 / 9; width: 100%; }
.btn-loading { position: relative; pointer-events: none; opacity: .85; }
.btn-loading::after { content: ""; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; margin-left: .5rem; vertical-align: -2px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-center { display: flex; justify-content: center; padding: 2rem; }
.load-more-wrap { text-align: center; padding: 1rem; }

/* ---------- 10. AUTH PAGES ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background:
  radial-gradient(1200px 500px at 10% -10%, var(--c-primary-soft), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, var(--c-accent-soft), transparent 55%), var(--c-bg); }
.auth-card { width: 100%; max-width: 440px; padding: 1.75rem; }
.auth-card .auth-logo { display: block; margin: 0 auto 1rem; max-height: 64px; }
.auth-card h1 { font-size: 1.4rem; text-align: center; }

/* ---------- 11. ADMIN DASHBOARD ---------- */
.admin-stat { display: flex; align-items: center; gap: 1rem; padding: 1.1rem; }
.admin-stat .stat-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; background: var(--c-primary-soft); color: var(--c-primary); flex: 0 0 auto; }
[data-theme="dark"] .admin-stat .stat-icon { color: var(--c-text); }
.admin-stat .stat-icon.green { background: var(--c-accent-soft); color: var(--c-accent); }
.admin-stat .stat-icon.red { background: var(--c-danger-soft); color: var(--c-danger); }
.admin-stat .stat-icon.amber { background: var(--c-warning-soft); color: var(--c-warning); }
.admin-stat .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; color: var(--c-text); }
.admin-stat .stat-label { font-size: .82rem; color: var(--c-text-muted); font-weight: 600; }
.chart-box { position: relative; height: 300px; }
.settings-tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: .4rem; }
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.table-responsive-cards { width: 100%; overflow-x: auto; }
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; border: 1px solid var(--c-border); border-radius: var(--radius-sm); margin-bottom: .75rem; padding: .35rem .5rem; background: var(--c-surface); }
  .table-stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0 !important; padding: .35rem .25rem !important; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-weight: 700; color: var(--c-text-muted); text-align: left; }
}

/* ---------- 12. THIRD-PARTY THEMING ---------- */
/* SweetAlert2 */
.swal2-popup { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); border-radius: var(--radius); font-family: var(--font-body); }
.swal2-title, .swal2-html-container { color: var(--c-text); }
.swal2-styled.swal2-confirm { background: var(--c-primary) !important; color: var(--c-on-primary) !important; border-radius: var(--radius-sm); }
.swal2-styled.swal2-deny { background: var(--c-danger) !important; border-radius: var(--radius-sm); }
.swal2-styled.swal2-cancel { background: var(--c-surface-2) !important; color: var(--c-text) !important; border-radius: var(--radius-sm); }
.swal2-input, .swal2-textarea, .swal2-select { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.swal2-timer-progress-bar { background: var(--c-accent); }
.swal2-container { z-index: 3000; }
/* NProgress */
#nprogress .bar { background: var(--c-accent); height: 3px; z-index: 3100; }
#nprogress .peg { box-shadow: 0 0 10px var(--c-accent), 0 0 5px var(--c-accent); }
#nprogress .spinner-icon { border-top-color: var(--c-accent); border-left-color: var(--c-accent); }
/* DataTables (Bootstrap 5 integration) */
.dataTables_wrapper, div.dt-container { color: var(--c-text); }
div.dt-container .dt-search input, div.dt-container .dt-length select,
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select {
  background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: .35rem .6rem; }
.dataTables_wrapper .dataTables_info, div.dt-container .dt-info { color: var(--c-text-muted); font-size: .85rem; }
table.dataTable tbody tr { background: transparent; }
table.dataTable.table-hover > tbody > tr:hover > * { box-shadow: inset 0 0 0 9999px var(--c-surface-2); }
table.dataTable thead th, table.dataTable thead td { border-bottom: 1px solid var(--c-border) !important; }
table.dataTable.no-footer { border-bottom: 1px solid var(--c-border); }
/* Chart.js canvas never overflows its box */
canvas { max-width: 100%; }

/* ---------- 13. UTILITIES & MOTION ---------- */
.cursor-pointer { cursor: pointer; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fade-in { animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.img-preview { max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--c-border); }
.upload-drop { border: 2px dashed var(--c-border); border-radius: var(--radius); padding: 1.25rem; text-align: center; color: var(--c-text-muted); cursor: pointer; }
.upload-drop:hover, .upload-drop.drag { border-color: var(--c-accent); background: var(--c-accent-soft); }
.maintenance-banner { background: var(--c-warning-soft); color: var(--c-warning); text-align: center; padding: .5rem; font-weight: 600; }
.theme-toggle .when-dark { display: none; }
[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .app-topbar, .app-sidebar, .bottom-nav, .app-footer, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}
