/* 
   App Shell — Sidebar + Topbar + Content Frame
*/

:root {
  --sidebar-width: 16rem;     
  --sidebar-collapsed-width: 5rem; 
  --topbar-height: 3.5rem;

  --sidebar-bg: var(--color-white);          
  --sidebar-foreground: #656e7e;  
  --sidebar-border: var(--color-border);      
  --sidebar-accent: var(--color-secondary);      
  --sidebar-accent-fg: var(--color-secondary-foreground);   
  --sidebar-primary: var(--color-primary);     
  --sidebar-primary-fg: var(--color-primary-foreground);    

  --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
}

.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--color-background);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.sidebar {
  display: none;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  flex-direction: column;
  width: var(--sidebar-width);
  transition: width 0.3s ease-out;
  z-index: 40;
  flex-shrink: 0;
  overflow: visible;
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
  }
}

.sidebar--collapsed,
html.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar__logo {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.sidebar__logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px -1px var(--color-primary-20);
  flex-shrink: 0;
  color: var(--sidebar-primary-fg);
}

.sidebar__logo-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-foreground);
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.sidebar--collapsed .sidebar__logo-text,
html.sidebar-collapsed .sidebar .sidebar__logo-text {
  display: none;
}

.sidebar__nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  list-style: none;
  margin: 0;
}

.sidebar__nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sidebar-foreground);
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
}

.sidebar__nav-link:hover {
  background-color: var(--sidebar-accent);
  color: var(--sidebar-accent-fg);
  text-decoration: none;
}

.sidebar__nav-link--active {
  background-color: var(--sidebar-primary);
  color: var(--sidebar-primary-fg);
  box-shadow: 0 2px 4px -1px var(--color-primary-30);
}

.sidebar__nav-link--active:hover {
  background-color: var(--sidebar-primary);
  color: var(--sidebar-primary-fg);
}

.sidebar__nav-link--active .sidebar__nav-icon {
  color: var(--sidebar-primary-fg);
}

.sidebar__nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  font-size: 1.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar--collapsed .sidebar__nav-label,
html.sidebar-collapsed .sidebar .sidebar__nav-label {
  display: none;
}

.sidebar--collapsed .sidebar__nav-link,
html.sidebar-collapsed .sidebar .sidebar__nav-link {
  justify-content: center;
  padding: 0.625rem;
}

.sidebar__user {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar__user-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s ease;
}

.sidebar__user-link:hover {
  background-color: var(--sidebar-accent);
  text-decoration: none;
  color: inherit;
}

.sidebar--collapsed .sidebar__user-link,
html.sidebar-collapsed .sidebar .sidebar__user-link {
  justify-content: center;
}

.sidebar__user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: var(--color-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-secondary-foreground);
}

.sidebar__user-info {
  flex: 1;
  min-width: 0;
}

.sidebar--collapsed .sidebar__user-info,
html.sidebar-collapsed .sidebar .sidebar__user-info {
  display: none;
}

.sidebar__user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-foreground);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: 0.75rem;
  color: var(--color-muted-foreground);
  margin: 0;
}

.sidebar__collapse-btn {
  position: absolute;
  top: 50%;
  right: -0.75rem;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  background-color: var(--sidebar-bg);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  cursor: pointer;
  transition: background-color 0.2s ease;
  z-index: 10;
  padding: 0;
  color: var(--color-muted-foreground);
}

.sidebar__collapse-btn:hover {
  background-color: var(--color-muted);
}

.sidebar__collapse-btn i {
  font-size: 0.875rem;
  transition: transform 0.2s ease;
}

.sidebar--collapsed .sidebar__collapse-btn i,
html.sidebar-collapsed .sidebar .sidebar__collapse-btn i {
  transform: rotate(180deg);
}

.im-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* prevent flex overflow */
}

.topbar {
  height: var(--topbar-height);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  background-color: #ffffff80;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 30;
}

@media (max-width: 1023px) {
  .topbar {
    position: sticky;
    top: 0;
  }
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.topbar__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-foreground);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

@media (min-width: 640px) {
  .topbar__title {
    font-size: 1.125rem;
    max-width: none;
  }
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .topbar__right {
    gap: 0.75rem;
  }
}

.topbar__search {
  position: relative;
  display: none;
}

@media (min-width: 768px) {
  .topbar__search {
    display: block;
  }
}

.topbar__search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: var(--color-muted-foreground);
  pointer-events: none;
}

.topbar__search-input {
  width: 12rem;
  height: 2.25rem;
  padding-left: 2.25rem;
  padding-right: 1rem;
  border-radius: 0.5rem;
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-foreground);
  transition: all 0.2s ease;
  font-family: inherit;
}

.topbar__search-input::placeholder {
  color: var(--color-muted-foreground);
}

.topbar__search-input:focus {
  outline: none;
  border-color: var(--sidebar-primary);
  box-shadow: 0 0 0 1px var(--color-primary-30);
}

@media (min-width: 1024px) {
  .topbar__search-input {
    width: 20rem;
  }
}

.topbar__search-mobile {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  background-color: var(--color-white);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--color-muted-foreground);
  padding: 0;
}

.topbar__search-mobile:hover {
  background-color: var(--color-muted-50);
}

@media (min-width: 768px) {
  .topbar__search-mobile {
    display: none;
  }
}

.topbar__filter {
  display: flex;
  height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  background-color: var(--color-white);
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-foreground);
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}

.topbar__filter:hover {
  background-color: var(--color-muted-50);
}

.topbar__filter-full {
  display: none;
}

@media (min-width: 1024px) {
  .topbar__filter-full {
    display: inline;
  }
  .topbar__filter-short {
    display: none;
  }
}

.topbar__filter-chevron {
  font-size: 0.875rem;
  color: var(--color-muted-foreground);
  transition: transform 0.2s ease;
}

.topbar__filter-wrapper {
  position: relative;
  display: block;
}

.topbar__filter--active {
  background-color: var(--sidebar-primary) !important;
  border-color: var(--sidebar-primary) !important;
  color: var(--sidebar-primary-fg) !important;
}

.topbar__filter--active .topbar__filter-chevron {
  color: #fff;
}

.topbar__filter-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.topbar__filter-clear:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.topbar__filter-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  padding: 0.25rem 0;
}

.topbar__filter-dropdown--open {
  display: block;
}

.topbar__filter-option {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-foreground);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__filter-option:hover {
  background-color: var(--color-background);
  color: var(--color-foreground);
  text-decoration: none;
}

.topbar__filter-option--active {
  background-color: var(--color-primary-light-bg);
  color: var(--color-secondary-foreground);
  font-weight: 500;
}

.topbar__filter-option--active:hover {
  background-color: var(--color-primary-light-bg);
}

.topbar__filter-empty {
  padding: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-muted-foreground);
  text-align: center;
}

.topbar__search-results {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: 0;
  width: 100%;
  min-width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  padding: 0.5rem 0;
}

.topbar__search-group {
  padding: 0.25rem 0;
}

.topbar__search-group + .topbar__search-group {
  border-top: 1px solid var(--color-border);
}

.topbar__search-group-title {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sidebar-primary);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.topbar__search-result-item {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-foreground);
  text-decoration: none;
  transition: background-color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__search-result-item:hover {
  background-color: var(--color-background);
  color: var(--color-foreground);
  text-decoration: none;
}

.topbar__search-no-results {
  padding: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-muted-foreground);
  text-align: center;
}

.topbar__search--mobile-open {
  display: block !important;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 0.5rem;
  background-color: #fff;
  border-bottom: 1px solid var(--color-border);
  z-index: 50;
}

.topbar__search--mobile-open .topbar__search-input {
  width: 100%;
}

.topbar__search--mobile-open .topbar__search-results {
  min-width: 100%;
}

.topbar__hamburger {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  border-radius: 0.5rem;
  border: none;
  background: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--color-foreground);
  padding: 0;
  font-size: 1.25rem;
}

.topbar__hamburger:hover {
  background-color: var(--color-muted-50);
}

@media (min-width: 1024px) {
  .topbar__hamburger {
    display: none;
  }
}

.topbar--minimal {
  gap: 0.75rem;
}

.topbar__global-search {
  position: relative;
  flex: 1;
  max-width: 36rem;
  margin: 0 auto;
}

.topbar__global-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--color-muted-foreground);
  pointer-events: none;
}

.topbar__global-search-input {
  width: 100%;
  height: 2.25rem;
  padding-left: 2.25rem;
  padding-right: 2rem;
  border-radius: 0.5rem;
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-foreground);
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.topbar__global-search-input::placeholder {
  color: var(--color-muted-foreground);
}

.topbar__global-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary-30);
}

.topbar__global-search .topbar__search-results {
  min-width: 100%;
}

.im-content {
  flex: 1;
  padding: 0.75rem;
  min-width: 0;
}

@media (min-width: 640px) {
  .im-content {
    padding: 1.25rem;
  }
}

.mobile-sidebar .offcanvas-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.mobile-sidebar .offcanvas-header {
  display: none; 
}

.mobile-sidebar {
  width: var(--sidebar-width) !important;
  border-right: 1px solid var(--sidebar-border) !important;
  background-color: var(--sidebar-bg) !important;
}

.mobile-sidebar .sidebar__nav-label {
  display: inline !important;
}

.mobile-sidebar .sidebar__user-info {
  display: block !important;
}

.mobile-sidebar .sidebar__logo-text {
  display: inline !important;
}

.mobile-sidebar .sidebar__nav-link {
  justify-content: flex-start !important;
  padding: 0.625rem 0.75rem !important;
}

.mobile-sidebar .sidebar__user-link {
  justify-content: flex-start !important;
}

.mobile-sidebar .sidebar__collapse-btn {
  display: none;
}

body.im-layout {
  padding: 0 !important;
  background-color: var(--color-background) !important;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body.im-layout .im-content .container {
  display: block !important;
  max-width: 100% !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.im-layout .navbar-custom {
  display: none !important;
}

body.im-layout .im-content .content {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0;
  overflow-x: hidden;
  grid-column: unset !important;
}

body.im-layout,
body.im-layout * {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body.im-layout .wrapper .sidebar {
  display: none !important;
}

body.im-layout .mobile-toggler {
  display: none !important;
}

body.im-layout #navModal {
  display: none !important;
}

.sidebar .btn,
.topbar .btn,
.mobile-sidebar .btn {
  background-color: transparent !important;
  color: inherit !important;
  font-size: inherit !important;
  padding: 0 !important;
  border-radius: 0 !important;
  width: auto !important;
  border: none !important;
}

.sidebar .p-4,
.topbar .p-4,
.mobile-sidebar .p-4 {
  padding: 1.5rem !important;
}

.sidebar .card-body,
.topbar .card-body,
.mobile-sidebar .card-body {
  display: block !important;
}

.sidebar__nav-link,
.sidebar__nav-link:hover,
.sidebar__nav-link:focus,
.sidebar__logo,
.sidebar__logo:hover,
.sidebar__user-link,
.sidebar__user-link:hover {
  text-decoration: none !important;
}

.topbar__hamburger,
.topbar__search-mobile,
.topbar__filter {
  box-shadow: none !important;
}

.topbar__search-results a,
.topbar__search-results a:hover,
.topbar__search-results a:focus,
.topbar__filter-dropdown a,
.topbar__filter-dropdown a:hover,
.topbar__filter-dropdown a:focus {
  text-decoration: none !important;
}

.topbar__filter-dropdown,
.topbar__search-results {
  font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}
