/* v2-dashboard.css — logged-in dashboard delta. Loaded ON TOP of v2-public.css.
 * Scoped under body.v2 (when in dashboard mode, hide_menu is false).
 */

/* =========================================================================
   1. Layout: fixed sidebar + main content offset
   ========================================================================= */
body.v2 .navpanel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 16rem;
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  padding: 1.25rem 1rem;
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
body.v2 .navpanel .logo img { height: 1.75rem; width: auto; }
body.v2 .navpanel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
}

@media (min-width: 1200px) {
  body.v2 main { padding-left: 16rem; }
  body.v2 .container-fluid { max-width: calc(var(--container-max) + 2rem); }
}
@media (max-width: 1199.98px) {
  body.v2 .navpanel {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.v2 .navpanel.open,
  body.v2 .navpanel.show {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
}

/* =========================================================================
   2. Sidebar nav (classic navpanel.html — keeps working)
   ========================================================================= */
body.v2 .navpanel-tabs {
  display: flex;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 0.25rem;
  margin-bottom: 1rem;
  gap: 0.125rem;
}
body.v2 .navpanel-tabs .nav-link {
  flex: 1;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.375rem 0.5rem;
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius-sm);
  background: transparent;
}
body.v2 .navpanel-tabs .nav-link.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-xs);
}
body.v2 .navpanel-tabs .nav-link::after { display: none; }

body.v2 .navpanel-menu .nav-item {
  margin: 0.0625rem 0;
}
body.v2 .navpanel-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
}
body.v2 .navpanel-menu .nav-link:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
body.v2 .navpanel-menu .nav-link.active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-weight: 600;
}
body.v2 .navpanel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
}
body.v2 .navpanel-menu .nav-link.active .navpanel-icon,
body.v2 .navpanel-menu .nav-link:hover .navpanel-icon {
  color: hsl(var(--primary));
}
body.v2 .navpanel-menu .nav-link svg { width: 1rem; height: 1rem; }
body.v2 .navpanel-menu .nav-link::after { display: none; }
body.v2 .navpanel-menu .has-submenu::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid hsl(var(--muted-foreground));
  border-bottom: 1.5px solid hsl(var(--muted-foreground));
  transform: rotate(-45deg);
  margin-left: auto;
  transition: transform .15s ease;
}
body.v2 .navpanel-menu .has-submenu.active::before {
  transform: rotate(45deg);
}
body.v2 .navpanel-submenu {
  margin: 0.125rem 0 0.25rem 1.875rem;
  padding-left: 0.5rem;
  border-left: 1px solid hsl(var(--border));
}
body.v2 .navpanel-submenu .nav-link {
  padding: 0.375rem 0.5rem;
  font-weight: 400;
  font-size: 0.8125rem;
}
body.v2 .navpanel-submenu .nav-link.text-white {
  color: hsl(var(--primary)) !important;
  background: transparent;
}

/* =========================================================================
   3. Top header (header_cp.html, classic markup retained)
   ========================================================================= */
body.v2 .header {
  background: hsl(var(--background) / 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid hsl(var(--border));
  position: sticky;
  top: 0;
  z-index: 100;
}
body.v2 .header > .container-fluid {
  padding: 0 1.25rem;
}
body.v2 .header .header-row {
  min-height: 3.75rem;
  margin: 0;
}
body.v2 .header .open-menu {
  width: 2.25rem;
  height: 2.25rem;
}
body.v2 .header .logo img { height: 1.5rem; width: auto; }

body.v2 .js-header,
body.v2 .header-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}
body.v2 .header-stats > span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding-right: 1rem;
}
body.v2 .header-stats .border-end {
  border-right: 1px solid hsl(var(--border)) !important;
}
body.v2 .header-stats .text-success {
  color: hsl(var(--success)) !important;
  font-weight: 600;
}
body.v2 .header-stats .text-warning {
  color: hsl(var(--warning)) !important;
  font-weight: 600;
}
body.v2 .header-stats svg { color: hsl(var(--primary)); }

/* =========================================================================
   4. Page content surfaces
   ========================================================================= */
body.v2 main {
  background: hsl(var(--background));
  min-height: 100vh;
}
body.v2 main > .container-fluid {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

body.v2 h1.page-title,
body.v2 .page-title h1,
body.v2 .container-fluid > h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

/* "Block" = the panel/card that wraps every dashboard section in XFS */
body.v2 main .block {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
}
body.v2 main .block-tabs {
  background: hsl(var(--subtle));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 0.5rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: -1.25rem -1.25rem 1rem;
}

/* =========================================================================
   5. File list table (files.html / my_files.html)
   ========================================================================= */
body.v2 .files-table,
body.v2 .my-files .table {
  font-size: 0.8125rem;
}
body.v2 .files-table thead,
body.v2 .my-files thead {
  background: hsl(var(--subtle));
}
body.v2 .files-table th {
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  padding: 0.625rem 0.625rem;
  border-bottom: 1px solid hsl(var(--border));
}
body.v2 .files-table td {
  padding: 0.625rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}
body.v2 .files-table tr:hover td { background: hsl(var(--muted) / 0.5); }
body.v2 .file-icon,
body.v2 .file-thumb {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--muted));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
body.v2 .file-name a {
  font-weight: 500;
  color: hsl(var(--foreground));
}
body.v2 .file-meta {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

body.v2 .files-controls,
body.v2 .files-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: hsl(var(--subtle));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: 1rem;
  align-items: center;
}

/* =========================================================================
   6. My account / forms in dashboard
   ========================================================================= */
body.v2 .my-account-stats,
body.v2 .stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
body.v2 .stat-tile {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 1rem 1.125rem;
}
body.v2 .stat-tile .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.25rem;
}
body.v2 .stat-tile .value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

body.v2 .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

/* =========================================================================
   7. Reports / charts
   ========================================================================= */
body.v2 .report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
body.v2 .report-summary > div,
body.v2 .report-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
}

/* =========================================================================
   8. Misc compatibility for original navpanel widget classes
   ========================================================================= */
body.v2 .custom-scrollbar::-webkit-scrollbar { width: 6px; }
body.v2 .custom-scrollbar::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 999px;
}
body.v2 .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground));
}

body.v2 .text-reset { color: hsl(var(--muted-foreground)) !important; }

/* =========================================================================
   9. Responsive: mobile menu toggle keeps working
   ========================================================================= */
@media (max-width: 1199.98px) {
  body.v2 main { padding-left: 0; }
  body.v2 .navpanel-close { display: flex; }
}
@media (min-width: 1200px) {
  body.v2 .open-menu { display: none; }
  body.v2 .navpanel-close { display: none; }
}

/* =========================================================================
   10. Mobile padding
   ========================================================================= */
@media (max-width: 768px) {
  body.v2 main > .container-fluid { padding: 1rem; }
  body.v2 main .block { padding: 1rem; }
  body.v2 .header > .container-fluid { padding: 0 1rem; }
}

/* =========================================================================
   11. v2 sidebar (navpanel_v2.html)
   ========================================================================= */
body.v2 .v2-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 16rem;
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  padding: 1.25rem 0.75rem 1rem;
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
body.v2 .v2-sidebar-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}
body.v2 .v2-sidebar-brand {
  padding: 0.25rem 0.5rem;
  margin-bottom: 1.25rem;
}
body.v2 .v2-sidebar-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}
body.v2 .v2-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
}
body.v2 .v2-sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  padding: 0.375rem 0.625rem;
  margin-bottom: 0.125rem;
}
body.v2 .v2-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
body.v2 .v2-sidebar-link svg {
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
  transition: color .15s ease;
}
body.v2 .v2-sidebar-link:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
body.v2 .v2-sidebar-link:hover svg {
  color: hsl(var(--foreground));
}
body.v2 .v2-sidebar-link.active {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  font-weight: 600;
}
body.v2 .v2-sidebar-link.active svg {
  color: hsl(var(--primary));
}

body.v2 .v2-sidebar-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}
body.v2 .v2-sidebar-skin {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  margin-bottom: 0.5rem;
}
body.v2 .v2-sidebar-skin:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
body.v2 .v2-sidebar-skin--soon {
  border: 0; background: transparent; width: 100%; text-align: left;
  cursor: not-allowed; opacity: .8;
}
body.v2 .v2-sidebar-skin--soon:hover {
  background: hsl(var(--muted) / .5);
  color: hsl(var(--muted-foreground));
}
body.v2 .v2-sidebar-skin__pill {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
body.v2 .v2-sidebar-copyright {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  padding: 0 0.625rem;
}
body.v2 .v2-sidebar-copyright a { color: hsl(var(--muted-foreground)); }
body.v2 .v2-sidebar-copyright a:hover { color: hsl(var(--foreground)); }

@media (max-width: 1199.98px) {
  body.v2 .v2-sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.v2 .v2-sidebar.open,
  body.v2 .v2-sidebar.show {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  body.v2 .v2-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: hsl(0 0% 0% / 0.4);
    z-index: 199;
  }
}

/* =========================================================================
   12. Admin pages (still use classic navpanel.html, restyled by v2)
   ========================================================================= */
body.v2 .admin-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}
body.v2 .admin-menu .nav-link {
  padding: 0.4375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius-sm);
  background: transparent;
  white-space: nowrap;
  flex: 0 0 auto;
}
body.v2 .admin-menu .nav-link:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
body.v2 .admin-menu .has-new {
  position: relative;
  color: hsl(var(--primary));
}
body.v2 .admin-menu .has-new::after {
  content: "";
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  width: 0.375rem;
  height: 0.375rem;
  background: hsl(var(--primary));
  border-radius: 50%;
}

/* btn-outline-light is used heavily in admin file rows for compact actions */
body.v2 .btn-outline-light {
  background: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
body.v2 .btn-outline-light:hover {
  background: hsl(var(--muted));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

body.v2 .btn-check + .btn,
body.v2 .btn-check + label.btn {
  background: hsl(var(--background));
  border-color: hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
body.v2 .btn-check:checked + .btn,
body.v2 .btn-check:checked + label.btn {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

body.v2 .btn-group .btn {
  border-color: hsl(var(--border));
}
body.v2 .btn-group-sm .btn { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }
body.v2 .input-group-sm .form-control,
body.v2 .input-group-sm .input-group-text {
  font-size: 0.8125rem;
  padding: 0.3125rem 0.5rem;
}
body.v2 .form-control-sm { font-size: 0.8125rem; padding: 0.3125rem 0.5rem; }

/* Admin settings input groupings */
body.v2 .admin-settings {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
body.v2 .admin-settings .form-control,
body.v2 .admin-settings .form-select {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
}
body.v2 .admin-settings .input-group .form-control { border-radius: 0; }
body.v2 .admin-settings .status {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
body.v2 .admin-settings .status.ok { color: hsl(var(--success)); }
body.v2 .admin-settings .status.error { color: hsl(var(--destructive)); }

body.v2 .filename {
  font-weight: 500;
  color: hsl(var(--foreground));
  word-break: break-all;
}

/* Tabs at top of admin sidebar */
body.v2 .navpanel .navpanel-tabs.nav-fill {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 0.25rem;
  gap: 0.125rem;
}
body.v2 .navpanel .navpanel-tabs.nav-fill .nav-link {
  text-align: center;
  background: transparent;
  border: none;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius-sm);
}
body.v2 .navpanel .navpanel-tabs.nav-fill .nav-link.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-xs);
}
body.v2 .navpanel .navpanel-tabs.nav-fill .nav-link::after { display: none; }

/* =========================================================================
   RTL — flip the sidebar to the right side and rebalance main content.
   Triggered when <body dir="rtl"> is set by main.html for lang_rtl=1 langs
   (Arabic, Hebrew, etc.).
   ========================================================================= */
body.v2[dir="rtl"] .v2-sidebar {
  left: auto;
  right: 0;
  border-right: 0;
  border-left: 1px solid hsl(var(--border));
}
body.v2[dir="rtl"] .v2-sidebar-close {
  right: auto;
  left: 0.625rem;
}
@media (max-width: 1199.98px) {
  /* Mobile drawer: the sidebar is anchored right:0 in RTL, so the LTR
     "hide" transform of translateX(-100%) drags it ACROSS the viewport and
     parks it half-visible at the left edge. Off-screen is +100% here, and
     the open state must re-assert translateX(0) at equal specificity. */
  body.v2[dir="rtl"] .v2-sidebar {
    transform: translateX(100%);
  }
  body.v2[dir="rtl"] .v2-sidebar.open,
  body.v2[dir="rtl"] .v2-sidebar.show {
    transform: translateX(0);
  }
}
@media (min-width: 1200px) {
  body.v2[dir="rtl"] main {
    padding-left: 0;
    padding-right: 16rem;
  }
}

/* Custom scrollbar on the sidebar: native browsers handle RTL automatically
   for overflow scrollbars; no rule needed. The visible bar will appear on
   the appropriate side per locale. */

/* RTL — topbar (header_cp.html). Flips:
   - .header padding so it sits to the LEFT of the right-side sidebar
   - .topbar-right margin-auto so it pushes toward the LEFT edge
     (where user identity sits in RTL)
   - Dropdown anchors stay right-side via .dropdown-menu-end which Bootstrap
     handles via [dir]; we just normalise margin direction.
*/
@media (min-width: 1200px) {
  body.v2[dir="rtl"] .header {
    padding-left: 0;
    padding-right: var(--sidebar-w);
  }
}
body.v2[dir="rtl"] .topbar-right {
  margin-left: 0;
  margin-right: auto;
}
