:root {
  --sidebar-width: 215px;
  --sidebar-collapsed-width: 72px;
  --sidebar-bg: #1a2234;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.06);
  --sidebar-bg-active: rgba(255, 255, 255, 0.1);
  --sidebar-border: rgba(255, 255, 255, 0.12);
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;
  --sidebar-icon: #7dd3fc;
  --sidebar-search-bg: #243044;
  --main-bg: linear-gradient(135deg, #ddd6fe 0%, #bfdbfe 45%, #c7d2fe 100%);
  --header-height: 64px;
  --transition-sidebar: 0.25s ease;
}

[x-cloak] {
  display: none !important;
}

body.has-sidebar {
  background: #eef2ff;
  overflow-x: hidden;
}

body.content-no-sidebar {
  background: #f8fafc;
}

/* Layout — sidebar fixed full height, content to the right */
.app-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  height: 100vh;
  z-index: 1050;
  transition: width var(--transition-sidebar);
  flex-shrink: 0;
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 0.5rem 0 0.35rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem 0.5rem 0.75rem 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-sidebar);
  background: var(--main-bg);
}

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

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.75rem;
  min-height: var(--header-height);
  background: transparent;
}

.main-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.main-header-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: -0.02em;
}

.main-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.main-header-phone {
  font-size: 0.875rem;
  color: #475569;
  font-weight: 500;
}

.main-header-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: #334155;
  font-size: 0.8rem;
  font-weight: 600;
}

.main-content {
  flex: 1;
  padding: 0 1.75rem 1.75rem;
}

.content-no-sidebar .main-content {
  padding: 1.5rem;
  margin: 0;
}

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

.sidebar-backdrop {
  display: none;
}

/* Brand */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.5rem 0.75rem 0.35rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
  text-decoration: none;
  color: #fff;
  min-width: 0;
  padding: 0.15rem 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-brand:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.sidebar-brand-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 50%;
  flex-shrink: 0;
  background: #fff;
  padding: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: block;
}

.sidebar-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #0ea5e9;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.sidebar-brand-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  line-height: 1.2;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text-muted);
  cursor: pointer;
}

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

/* Search */
.sidebar-search-wrap {
  padding: 0 0.5rem 0.85rem 0.35rem;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--sidebar-search-bg);
  border-radius: 999px;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-search i {
  color: var(--sidebar-text-muted);
  font-size: 0.85rem;
}

.sidebar-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  outline: none;
  min-width: 0;
}

.sidebar-search-input::placeholder {
  color: var(--sidebar-text-muted);
}

/* Nav links — flat vertical menu */
.sidebar-link,
.sidebar-link-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 0.65rem 0.75rem 0.5rem;
  margin-bottom: 0.1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.sidebar-link.is-active,
.sidebar-link-toggle.is-active {
  background: var(--sidebar-bg-active);
  color: #fff;
}

.sidebar-link-icon {
  width: 20px;
  text-align: center;
  color: var(--sidebar-icon);
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-link.is-active .sidebar-link-icon,
.sidebar-link-toggle.is-active .sidebar-link-icon {
  color: #bae6fd;
}

.sidebar-link-text {
  flex: 1;
  white-space: nowrap;
}

.sidebar-chevron {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  transition: transform 0.2s;
}

.sidebar-chevron.is-open {
  transform: rotate(180deg);
}

/* Submenu */
.sidebar-group {
  margin-bottom: 0.15rem;
}

.sidebar-submenu {
  padding: 0.2rem 0 0.45rem 2.15rem;
}

.sidebar-sublink {
  display: block;
  padding: 0.55rem 0.75rem;
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

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

.sidebar-sublink.is-active {
  color: #bae6fd;
  background: rgba(125, 211, 252, 0.08);
}

/* Footer actions (pinned to bottom) */
.sidebar-footer {
  margin-top: auto;
}

.sidebar-link-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.sidebar-link-logout:hover .sidebar-link-icon {
  color: #f87171;
}

/* Collapsed desktop */
.app-sidebar.is-collapsed .sidebar-search-wrap,
.app-sidebar.is-collapsed .sidebar-brand-text,
.app-sidebar.is-collapsed .sidebar-link-text,
.app-sidebar.is-collapsed .sidebar-chevron,
.app-sidebar.is-collapsed .sidebar-submenu {
  display: none !important;
}

.app-sidebar.is-collapsed .sidebar-link,
.app-sidebar.is-collapsed .sidebar-link-toggle {
  justify-content: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.app-sidebar.is-collapsed .sidebar-header {
  justify-content: center;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

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

.app-sidebar.is-collapsed .sidebar-brand-img {
  width: 42px;
  height: 42px;
}

/* Mobile toggle in main header */
.sidebar-toggle-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.85);
}

.sidebar-collapse-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Public pages navbar */
.navbar-public {
  border-bottom: 1px solid rgba(182, 207, 232, 0.55);
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0, 61, 130, 0.06);
  padding: 0.65rem 0;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.navbar-public-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  align-items: center;
}

.navbar-brand-logo {
  display: inline-flex;
  align-items: center;
  padding: 0;
  margin: 0;
  line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.navbar-brand-logo:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.navbar-logo-img {
  display: block;
  width: auto;
  height: 46px;
  max-width: min(220px, 58vw);
  object-fit: contain;
  object-position: left center;
}

.navbar-public-toggler {
  border: 1px solid #e2e8f0;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
}

.navbar-public-toggler:focus {
  box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.15);
}

.navbar-public-link {
  color: #1a2b3c !important;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0.85rem !important;
  border-radius: 10px;
  transition: color 0.15s ease, background 0.15s ease;
}

.navbar-public-link:hover,
.navbar-public-link:focus {
  color: #0056b3 !important;
  background: rgba(0, 86, 179, 0.06);
}

.navbar-public-signup {
  background: linear-gradient(135deg, #003d82, #0056b3) !important;
  color: #fff !important;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1.15rem !important;
  border-radius: 10px;
  border: none;
  box-shadow: 0 4px 14px rgba(0, 86, 179, 0.22);
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.navbar-public-signup:hover,
.navbar-public-signup:focus {
  color: #fff !important;
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 86, 179, 0.28);
}

@media (max-width: 991.98px) {
  .navbar-public {
    padding: 0.5rem 0;
  }

  .navbar-logo-img {
    height: 40px;
    max-width: min(190px, 52vw);
  }

  .navbar-public-inner .navbar-collapse {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
  }

  .navbar-public-link {
    padding: 0.6rem 0.5rem !important;
  }

  .navbar-public-signup {
    display: inline-block;
    width: 100%;
    text-align: center;
    margin-top: 0.35rem !important;
    margin-left: 0 !important;
  }
}

@media (max-width: 400px) {
  .navbar-logo-img {
    height: 36px;
    max-width: 160px;
  }
}

/* Mobile */
@media (max-width: 991.98px) {
  .app-main {
    margin-left: 0 !important;
  }

  .app-sidebar {
    width: 0;
    pointer-events: none;
  }

  .app-sidebar.is-mobile-open {
    width: min(var(--sidebar-width), 88vw);
    pointer-events: auto;
  }

  .app-sidebar.is-mobile-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: -1;
  }

  .main-content {
    padding: 0 1rem 1rem;
  }

  .main-header {
    padding: 0.85rem 1rem;
  }
}

@media (min-width: 992px) {
  .sidebar-close-btn {
    display: none !important;
  }
}

/* Super admin: navbar above sidebar */
:root {
  --superadmin-navbar-height: 72px;
}

body.has-superadmin-layout .navbar-public {
  position: sticky;
  top: 0;
  z-index: 1060;
}

body.has-superadmin-layout .app-sidebar {
  top: var(--superadmin-navbar-height);
  height: calc(100vh - var(--superadmin-navbar-height));
}

body.has-superadmin-layout .sidebar-panel {
  height: calc(100vh - var(--superadmin-navbar-height));
}

body.has-superadmin-layout .app-layout {
  min-height: calc(100vh - var(--superadmin-navbar-height));
}

/* Super admin profile menu */
.navbar-superadmin .navbar-public-inner {
  justify-content: space-between;
}

.superadmin-profile-menu {
  position: relative;
}

.superadmin-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.superadmin-profile-btn:hover,
.superadmin-profile-btn:focus,
.superadmin-profile-btn.show {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.superadmin-profile-btn::after {
  margin-left: 0.15rem;
}

.superadmin-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ecfeff, #dbeafe);
  color: #0891b2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.superadmin-profile-meta {
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: left;
}

.superadmin-profile-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
}

.superadmin-profile-phone {
  font-size: 0.75rem;
  color: #64748b;
}

.superadmin-profile-dropdown {
  min-width: 14rem;
  border: 1px solid #f1f5f9;
  border-radius: 0.875rem;
  padding: 0.35rem;
  margin-top: 0.5rem !important;
}

.superadmin-dropdown-header {
  padding: 0.65rem 0.85rem 0.45rem;
}

.superadmin-dropdown-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: #0f172a;
}

.superadmin-dropdown-subtitle {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.superadmin-profile-dropdown .dropdown-item {
  border-radius: 0.55rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
}

.superadmin-profile-dropdown .dropdown-item:hover {
  background: #f8fafc;
}
