@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --app-bg: #f3f6fb;
  --app-bg-alt: #e7edf5;
  --sidebar-bg: #f1f5f9;
  --sidebar-bg-strong: #e2e8f0;
  --sidebar-border: rgba(15, 23, 42, 0.08);
  --sidebar-text: #1e293b;
  --sidebar-text-strong: #0f172a;
  --sidebar-muted: #64748b;
  --sidebar-surface: rgba(15, 23, 42, 0.06);
  --sidebar-surface-hover: rgba(15, 23, 42, 0.12);
  --sidebar-active-bg: rgba(45, 140, 255, 0.18);
  --sidebar-active-text: #0f172a;
  --sidebar-switch-bg: rgba(15, 23, 42, 0.18);
  --sidebar-switch-handle: #ffffff;
  --accent: #2d8cff;
  --accent-strong: #1f6fd6;
  --card-bg: #ffffff;
  --text-color: #142033;
  --shadow: 0 16px 32px rgba(12, 23, 34, 0.12);
  --transition: 0.2s ease;
}

body {
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  background: var(--app-bg);
  color: var(--text-color);
}

body.dark {
  --app-bg: #0b1420;
  --app-bg-alt: #0f1b2a;
  --sidebar-bg: #0b1521;
  --sidebar-bg-strong: #09111b;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #f1f5fa;
  --sidebar-text-strong: #ffffff;
  --sidebar-muted: #9ab0c6;
  --sidebar-surface: rgba(255, 255, 255, 0.08);
  --sidebar-surface-hover: rgba(255, 255, 255, 0.16);
  --sidebar-active-bg: rgba(45, 140, 255, 0.18);
  --sidebar-active-text: #ffffff;
  --sidebar-switch-bg: rgba(255, 255, 255, 0.25);
  --sidebar-switch-handle: #ffffff;
  --accent: #4ea3ff;
  --accent-strong: #2d7eea;
  --card-bg: #0f1b2a;
  --text-color: #e4ebf3;
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--text-color);
  --bs-secondary-color: #9ab0c6;
  --bs-secondary-color-rgb: 154, 176, 198;
  --bs-secondary-bg: var(--app-bg-alt);
  --bs-tertiary-bg: rgba(15, 23, 42, 0.7);
  --bs-border-color: rgba(148, 163, 184, 0.2);
  --bs-border-color-translucent: rgba(148, 163, 184, 0.18);
  --bs-emphasis-color: #f8fafc;
  --bs-emphasis-color-rgb: 248, 250, 252;
  --bs-table-color: var(--text-color);
  --bs-table-striped-color: var(--text-color);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
  --bs-table-hover-color: var(--text-color);
  --bs-table-hover-bg: rgba(78, 163, 255, 0.08);
  --bs-table-border-color: rgba(148, 163, 184, 0.2);
  --bs-tooltip-bg: #e2e8f0;
  --bs-tooltip-color: #0b1420;
}

body.dark .card,
body.dark .modal-content,
body.dark .table,
body.dark .dropdown-menu {
  background-color: var(--card-bg);
  color: var(--text-color);
}

body.dark .table {
  --bs-table-color: var(--text-color);
  --bs-table-striped-color: var(--text-color);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
  --bs-table-hover-color: var(--text-color);
  --bs-table-hover-bg: rgba(78, 163, 255, 0.08);
  --bs-table-border-color: rgba(148, 163, 184, 0.2);
}

body.dark .table-light {
  --bs-table-bg: rgba(15, 23, 42, 0.65);
  --bs-table-color: var(--text-color);
  color: var(--text-color);
}

body.dark .table-dark {
  --bs-table-bg: rgba(9, 17, 27, 0.9);
  --bs-table-color: var(--text-color);
  color: var(--text-color);
}

body.dark .text-muted {
  color: #9ab0c6 !important;
}

body.dark .badge.bg-light {
  background-color: rgba(15, 23, 42, 0.7) !important;
  color: var(--text-color) !important;
  border-color: rgba(148, 163, 184, 0.3) !important;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--app-bg);
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-strong) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 16px;
  border-right: 1px solid var(--sidebar-border);
  transition: width var(--transition), transform var(--transition);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--sidebar-text);
}

.brand:hover {
  color: var(--sidebar-text-strong);
}

.brand img {
  width: 34px;
  height: 34px;
}

body.dark .brand img,
body.dark .user-card img {
  filter: brightness(0.85) contrast(0.9) saturate(0.9);
}

.user-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--sidebar-surface);
}

.user-card img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--sidebar-border);
}

.user-card .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.user-card .info strong {
  font-size: 0.95rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-card .info span {
  font-size: 0.78rem;
  color: var(--sidebar-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.profile-menu-toggle {
  margin-left: auto;
  border: none;
  background: var(--sidebar-surface);
  color: var(--sidebar-text);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  transition: transform var(--transition), background var(--transition);
}

.profile-menu-toggle:focus-visible,
.toggle-theme:focus-visible,
.toggle-sidebar:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.profile-menu-toggle.open {
  transform: rotate(90deg);
}

.profile-dropdown-menu {
  position: absolute;
  top: 68px;
  right: 12px;
  background: var(--sidebar-bg-strong);
  border: 1px solid var(--sidebar-border);
  border-radius: 12px;
  padding: 8px;
  display: none;
  min-width: 200px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.profile-dropdown-menu.open {
  display: grid;
  gap: 4px;
}

.profile-dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.profile-dropdown-menu .dropdown-item:hover {
  background: var(--sidebar-surface-hover);
  color: var(--sidebar-text-strong);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-muted);
  margin: 12px 0 6px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.menu-item i {
  font-size: 1.1rem;
}

.menu-item:hover {
  background: var(--sidebar-surface-hover);
  color: var(--sidebar-text-strong);
}

.menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.menu-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: inset 0 0 0 1px rgba(45, 140, 255, 0.3);
}

.bottom {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
}

.toggle-theme,
.toggle-sidebar {
  width: 100%;
  border: none;
  background: var(--sidebar-surface);
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.toggle-theme:hover,
.toggle-sidebar:hover {
  background: var(--sidebar-surface-hover);
}

.toggle-theme i {
  font-size: 1rem;
}

.toggle-theme .bi-moon {
  display: none;
}

body.dark .toggle-theme .bi-sun {
  display: none;
}

body.dark .toggle-theme .bi-moon {
  display: inline;
}

.toggle-theme .switch {
  width: 34px;
  height: 18px;
  background: var(--sidebar-switch-bg);
  border-radius: 999px;
  position: relative;
  margin-left: auto;
}

.toggle-theme .switch-handle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--sidebar-switch-handle);
  border-radius: 50%;
  transition: transform var(--transition);
}

body.dark .toggle-theme .switch-handle {
  transform: translateX(16px);
}

.toggle-sidebar span {
  font-size: 0.85rem;
  color: var(--sidebar-muted);
}

.toggle-sidebar i:last-child {
  display: none;
}

body.sidebar-collapsed .toggle-sidebar i:first-child {
  display: none;
}

body.sidebar-collapsed .toggle-sidebar i:last-child {
  display: inline;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(45, 140, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(255, 193, 7, 0.12), transparent 55%),
    var(--app-bg);
}

.page-wrapper {
  padding: 28px 32px 40px;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--app-bg-alt);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.mobile-topbar .mobile-brand {
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: inherit;
}

.icon-button {
  border: none;
  background: rgba(0, 0, 0, 0.08);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

body.dark .mobile-topbar {
  background: var(--app-bg-alt);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark .icon-button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
}

.sidebar-overlay {
  display: none;
}

body.sidebar-collapsed .sidebar {
  width: 86px;
}

body.sidebar-collapsed .sidebar .brand span,
body.sidebar-collapsed .sidebar .info,
body.sidebar-collapsed .sidebar .menu-item span,
body.sidebar-collapsed .sidebar .menu-section,
body.sidebar-collapsed .sidebar .toggle-sidebar span {
  display: none;
}

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

body.sidebar-collapsed .sidebar .profile-dropdown-menu {
  right: -10px;
}

body.sidebar-collapsed .sidebar .profile-menu-toggle {
  transform: rotate(0deg);
}

@media (max-width: 991px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
  }

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

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 28, 0.6);
    backdrop-filter: blur(2px);
    z-index: 900;
    display: none;
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .mobile-topbar {
    display: flex;
  }

  .page-wrapper {
    padding: 20px;
  }
}

@media (max-width: 576px) {
  .page-wrapper {
    padding: 16px;
  }
}
