/* Global responsive adjustments */
@media (max-width: 1200px) {
  .app-content .row > [class^="col-"],
  .app-content .row > [class*=" col-"] {
    margin-bottom: 1rem;
  }
}

/* Density modes */
body.density-compact .card .card-header,
body.density-compact .card .card-body,
body.density-compact .card .card-footer {
  padding: 0.6rem 0.8rem;
}

body.density-compact .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

body.density-compact .form-control,
body.density-compact .form-select {
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

body.density-compact .table > :not(caption) > * > * {
  padding: 0.4rem 0.6rem;
}

body.density-comfort .table > :not(caption) > * > * {
  padding: 0.65rem 0.75rem;
}

@media (max-width: 992px) {
  .app-header .navbar-nav .nav-item.d-none.d-md-block {
    display: none !important;
  }

  .app-header .navbar-nav.ms-auto {
    gap: 0.5rem;
  }

  .app-sidebar .nav-link p {
    font-size: 0.95rem;
  }

  .app-content-header .breadcrumb {
    float: none !important;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .app-header .navbar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app-header .navbar-nav.ms-auto {
    width: 100%;
    justify-content: flex-end;
  }

  .app-content-header h3 {
    font-size: 1.2rem;
  }

  .card .card-header,
  .card .card-body,
  .card .card-footer {
    padding: 0.75rem;
  }

  .small-box > .inner > h3 {
    font-size: 1.6rem;
  }

  .small-box > .icon {
    font-size: 50px;
    top: 12px;
  }

  .table-responsive,
  .dataTables_wrapper {
    overflow-x: auto;
  }

  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length {
    text-align: left;
    margin-bottom: 0.5rem;
  }

  .btn-group,
  .btn-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Sidebar default collapsed on mobile */
  .app-sidebar {
    width: 0 !important;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

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

  body.sidebar-open .app-sidebar {
    width: 250px !important;
    transform: translateX(0);
    z-index: 1040;
  }

  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1030;
  }
}

@media (max-width: 576px) {
  .app-header .navbar-nav.ms-auto {
    justify-content: space-between;
  }

  .app-header .nav-link {
    padding: 0.4rem 0.5rem;
  }

  .app-sidebar .nav-link {
    margin: 2px 6px;
  }

  .small-box {
    margin-bottom: 12px;
  }

  .form-control,
  .form-select,
  .btn {
    width: 100%;
  }

  .input-group > .form-control,
  .input-group > .form-select,
  .input-group > .input-group-text {
    width: auto;
  }

  .breadcrumb {
    font-size: 0.85rem;
  }

  /* Compact cards and lists */
  .card .card-header,
  .card .card-body,
  .card .card-footer {
    padding: 0.6rem;
  }

  .list-group-item {
    padding: 0.6rem 0.75rem;
  }

  /* Hide less critical sidebar labels on very small screens */
  .app-sidebar .nav-link p {
    font-size: 0.9rem;
  }
}

/* Sticky table headers inside responsive wrappers */
.table-responsive thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Page actions bar */
.page-actions-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .page-actions-bar {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 0.5rem;
  }
}

/* Filter drawer (mobile) */
@media (max-width: 768px) {
  .filter-card {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 85vw;
    max-width: 360px;
    transform: translateX(100%);
    z-index: 1060;
    transition: transform 0.2s ease;
  }

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

  body.filter-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1055;
  }
}

/* Skeletons */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-text {
  height: 0.9rem;
  border-radius: 4px;
}

.skeleton-text-lg {
  height: 1.1rem;
  border-radius: 4px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.skeleton-card {
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.skeleton-card .skeleton-text {
  margin-bottom: 0.5rem;
}

.skeleton-card .skeleton-text:last-child {
  width: 60%;
  margin-bottom: 0;
}

.skeleton-table td {
  position: relative;
  color: transparent !important;
}

.skeleton-table td::after {
  content: "";
  display: block;
  height: 0.75rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Loading state for content areas */
.content-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 2rem;
  color: var(--bs-secondary, #6c757d);
}

.content-loading .spinner-border {
  width: 2rem;
  height: 2rem;
}
