html,
body {
  font-family: var(--font-family);
  font-size: 20px;
  line-height: 1.4;
  font-weight: 600;
}

body {
  margin: 0;
  background: var(--bg-color);
  color: var(--text-color);
}

/* Sidebar */

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(
    180deg,
    var(--sidebar-bg-start) 0%,
    var(--sidebar-bg-end) 100%
  );
  color: var(--sidebar-text-color);
  padding: 18px 14px;
  overflow-y: auto;
  overflow-x: visible;
  border-right: 1px solid var(--sidebar-divider-color);
  transition: width .2s ease, transform .2s ease;
  z-index: 1050;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--sidebar-divider-color);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: .82rem;
  font-weight: 500;
  color: var(--sidebar-text-muted-color);
  margin-top: 2px;
  white-space: nowrap;
}

.sidebar-toggle {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;

  border: 0;
  border-radius: var(--radius-md);

  background: var(--sidebar-brand-bg);
  color: #fff;

  display: grid;
  place-items: center;

  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--sidebar-hover-bg);
}

.sidebar-menu {
  display: grid;
  gap: 4px;
}

.menu-section {
  margin: 18px 10px 8px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--sidebar-text-muted-color);
  letter-spacing: .4px;
  white-space: nowrap;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--sidebar-text-color);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  transition: .18s ease;
  position: relative;
}

.sidebar-link i {
  width: 22px;
  text-align: center;
  font-size: 1.05rem;
  opacity: .9;
}

.sidebar-link span {
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: var(--shadow-md);
}

.sidebar-link.active i {
  opacity: 1;
}

/* Collapsed Sidebar */

body.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
  padding-left: 12px;
  padding-right: 12px;
}

body.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .menu-section,
body.sidebar-collapsed .sidebar-link span {
  display: none;
}

body.sidebar-collapsed .sidebar-header {
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding-bottom: 14px;
}

body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

body.sidebar-collapsed .brand-text {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle {
  position: static;
  width: 38px;
  height: 38px;
}

body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 12px;
  overflow: visible;
}

body.sidebar-collapsed .sidebar-link i {
  width: auto;
  font-size: 1.25rem;
}

/* Custom Tooltip */

body.sidebar-collapsed .sidebar-link:hover::after {
  content: attr(data-tooltip);
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 12px);
  top: var(--tooltip-top, 0px);

  background: rgba(17, 24, 39, .96);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 99999;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
}

body.sidebar-collapsed .sidebar-link:hover::before {
  content: "";
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 5px);
  top: var(--tooltip-arrow-top, 0px);

  border-width: 7px 7px 7px 0;
  border-style: solid;
  border-color: transparent rgba(17, 24, 39, .96) transparent transparent;
  z-index: 99999;
}


@keyframes tooltipFade {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

/* Main */

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}

.app-topbar {
  min-height: 64px;
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-sidebar-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--surface-color);
  color: var(--text-color);
  align-items: center;
  justify-content: center;
}

.topbar-title {
  display: grid;
  gap: 2px;
}

.topbar-page-title {
  font-weight: 700;
  line-height: 1.1;
}

.topbar-subtitle {
  font-size: .88rem;
  color: var(--text-muted-color);
}

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

.topbar-user {
  color: var(--text-muted-color);
  font-size: .95rem;
}

.page-container {
  flex: 1;
  padding: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.app-footer {
  padding: 14px 24px;
  color: var(--text-muted-color);
  font-size: .9rem;
}

/* Typography Override */

html,
body,
input,
select,
textarea,
button,
table,
.form-control,
.form-select,
.btn,
.modal-content,
.dropdown-menu,
.nav-link,
.card {
  font-family: var(--font-family) !important;
}

h1,
h2,
h3,
h4,
h5,
h6,
.form-label,
.btn,
.table th {
  font-weight: 700;
}

.form-control,
.form-select,
.table td {
  font-weight: 600;
}

.sidebar-overlay {
  display: none;
}

#togglePin {
    min-width: 52px;
}

#togglePin i {
    font-size: 1rem;
}

.app-sidebar::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.25);
    border-radius: 999px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.45);
}


/* Responsive */

@media (max-width: 991.98px) {
  .mobile-sidebar-toggle {
    display: flex;
  }

  .app-sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0 !important;
  }

  body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width);
  }

  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .menu-section,
  body.sidebar-collapsed .sidebar-link span {
    display: block;
  }

  body.sidebar-collapsed .sidebar-header {
    flex-direction: row;
    justify-content: space-between;
  }

  body.sidebar-collapsed .sidebar-toggle {
    position: static;
    width: 38px;
    height: 38px;
  }

  body.sidebar-collapsed .sidebar-link {
    justify-content: flex-start;
  }

  body.sidebar-collapsed .sidebar-link:hover::before,
  body.sidebar-collapsed .sidebar-link:hover::after {
    display: none;
  }

   body.sidebar-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
    z-index: 1040;
  }
}