*, *::before, *::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden !important;
  width: 100%;
  scrollbar-gutter: stable;
}

body {
  height: 100%;
  margin: 0;
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100%;
}

body > * {
  padding-right: 0;
}

#wrapper {
  min-height: 100vh;
  display: flex;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#wrapper.wrapper-with-sidebar {
  display: grid !important;
  grid-template-columns: 360px 1fr;
}

#wrapper.wrapper-with-sidebar #sidebar-wrapper {
  grid-row: 1 / -1;
  overflow-x: hidden;
  overflow-y: auto;
}

#page-content-wrapper {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden !important;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden !important;
  width: 100%;
}

.full-width-content {
  padding: 0;
  width: 100%;
}

.sidebar-heading {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

.logo-section {
  width: 320px;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  overflow-x: hidden;
}

@media (max-width: 991px) {
  #sidebar-wrapper {
    display: none;
  }
  .logo-section {
    width: auto;
    min-width: auto;
  }
  .navbar-nav {
    min-width: 0;
  }
  .navbar-collapse {
    overflow-x: hidden !important;
  }
}

@media (max-width: 768px) {
  .logo-section {
    width: auto;
    min-width: auto;
  }
}

.list-group-item.active {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.list-group-item-action:hover {
  background-color: #343a40;
}

#sidebar-wrapper .list-group-item {
  background-color: #1a1d20 !important;
  color: #e0e0e0 !important;
  border-color: #2a2d30 !important;
}

#sidebar-wrapper .list-group-item.active {
  background-color: #0d6efd !important;
  color: #ffffff !important;
}

#sidebar-wrapper .list-group-item-dark {
  background-color: #1a1d20 !important;
  color: #e0e0e0 !important;
}

#sidebar-wrapper .list-group-item-action:hover {
  background-color: #25282b !important;
}

.folder-indent-0 { padding-left: 0.75rem !important; }
.folder-indent-1 { padding-left: 1.25rem !important; }
.folder-indent-2 { padding-left: 1.75rem !important; }
.folder-indent-3 { padding-left: 2.25rem !important; }
.folder-indent-4 { padding-left: 2.75rem !important; }
.folder-indent-5 { padding-left: 3.25rem !important; }
.folder-indent-6 { padding-left: 3.75rem !important; }
.folder-indent-7 { padding-left: 4.25rem !important; }
.folder-indent-8 { padding-left: 4.75rem !important; }
.folder-indent-9 { padding-left: 5.25rem !important; }
.folder-indent-10 { padding-left: 5.75rem !important; }
.folder-indent-11 { padding-left: 6.25rem !important; }
.folder-indent-12 { padding-left: 6.75rem !important; }
.folder-indent-13 { padding-left: 7.25rem !important; }
.folder-indent-14 { padding-left: 7.75rem !important; }

.app-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  overflow-x: hidden;
}

@media (min-width: 992px) {
  .app-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .app-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 767px) {
  .app-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.app-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  background: #fff;
  border-radius: 16px;
  border: 2px solid #dee2e6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  color: #212529;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  outline: none;
  max-width: 100%;
  overflow: hidden;
  margin-top: 20px;
}

.app-button svg {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.app-button span {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  padding: 0 4px;
  overflow-wrap: break-word;
  white-space: nowrap;
}

.app-button:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  border-color: #0d6efd;
}

.app-button:active {
  transform: translateY(-2px);
  background-color: #0d6efd;
}

.app-button:active svg,
.app-button:active span {
  fill: #fff;
  color: #fff;
}

@media (max-width: 575px) {
  .app-button {
    min-height: 120px;
  }
  .app-button svg {
    width: 36px;
    height: 36px;
  }
  .app-button span {
    font-size: 12px;
  }
}

.breadcrumb-separator {
  color: #6c757d;
  margin: 0 0.5rem;
  font-size: 1.1rem;
}

.breadcrumb-current {
  color: #212529;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background-color: #e9ecef;
  border-radius: 0.375rem;
}

.breadcrumb a {
  color: #0d6efd;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

.breadcrumb a:hover {
  background-color: #e9ecef;
  color: #0a58ca;
  text-decoration: none;
}

@media (max-width: 768px) {
  .breadcrumb a {
    padding: 0.15rem 0.25rem;
  }
  .breadcrumb-separator {
    margin: 0 0.25rem;
    font-size: 1rem;
  }
}

/* Full-width navbar and content - remove container-fluid padding */
#page-content-wrapper > .navbar .container-fluid,
#page-content-wrapper > .container-fluid {
  padding-left: 0;
  padding-right: 0;
  max-width: 100%;
}

#page-content-wrapper > .navbar .container-fluid .logo-section,
#page-content-wrapper > .navbar .container-fluid .navbar-nav {
  padding-left: 1rem;
  padding-right: 1rem;
}

#page-content-wrapper > .container-fluid.py-4,
#page-content-wrapper > .full-width-content {
  padding-left: 0;
  padding-right: 0;
}

#page-content-wrapper > .container-fluid.py-4 > .content-area,
#page-content-wrapper > .full-width-content > .content-area {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Folder picker tree styles */
.cursor-pointer {
  cursor: pointer;
  user-select: none;
}

.folder-item:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Navbar search form */
.navbar .navbar-nav .nav-item form {
  margin: 0;
}

.navbar .navbar-nav .nav-item .form-control {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.navbar .navbar-nav .nav-item .form-control::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.navbar .navbar-nav .nav-item .form-control:focus {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  box-shadow: none;
}

.navbar .navbar-nav .nav-item .form-check-input {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.navbar .navbar-nav .nav-item .form-check-input:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.navbar .navbar-nav .nav-item .form-check-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  padding-left: 0.25rem;
}

.navbar .navbar-nav .nav-item .form-check-sm {
  margin: 0;
}

@media (max-width: 991px) {
  .navbar .navbar-nav .nav-item form {
    margin: 0.5rem 1rem;
    width: 100%;
  }
  
  .navbar .navbar-nav .nav-item .form-control {
    width: 100%;
  }
  
  .navbar .navbar-nav .nav-item .d-flex {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}

/* Annotation toolbar and overlay styles */
.annotation-toolbar {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 12px;
}

.annotation-toolbar .btn {
  font-size: 0.85rem;
}

.annotation-overlay-container {
  position: relative;
}

.annotation-overlay-img {
  position: absolute;
  cursor: move;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  background: white;
}

.annotation-overlay-img:hover {
  border-color: #007bff;
}

.annotation-overlay-img.dragging {
  opacity: 0.7;
  border-color: #0d6efd;
}
