/*!
 * sbomify Responsive Utilities
 * Phase 2: Advanced responsive design utilities
 */

/* ===== RESPONSIVE UTILITIES ===== */

/* Touch-friendly spacing */
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

.touch-target-large {
  min-height: 48px;
  min-width: 48px;
}

/* Responsive text sizes */
.text-responsive {
  font-size: clamp(0.875rem, 2vw, 1rem);
}

.text-responsive-lg {
  font-size: clamp(1rem, 3vw, 1.25rem);
}

.text-responsive-xl {
  font-size: clamp(1.25rem, 4vw, 1.875rem);
}

/* ===== ENHANCED DASHBOARD RESPONSIVE IMPROVEMENTS ===== */

/* Dashboard grid system */
.dashboard-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
  }
}

@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
  }
}

/* Enhanced dashboard cards for mobile */
@media (max-width: 767.98px) {
  /* Single column layout for mobile dashboard stats */
  .dashboard-stats .row {
    margin-left: 0;
    margin-right: 0;
  }

  .dashboard-stats .row>[class*="col-"] {
    padding-left: 0;
    padding-right: 0;
    margin-bottom: 1rem;
  }

  .dashboard-stats .row>[class*="col-"]:last-child {
    margin-bottom: 0;
  }

  /* Better mobile card spacing */
  .dashboard-stats .card {
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 0;
  }

  /* Mobile-optimized stat cards */
  .stats-card .card-header {
    padding: 1rem 1.25rem 0.75rem;
  }

  .stats-card .card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
  }

  .stats-card .card-body {
    padding: 1rem 1.25rem 1.5rem;
  }

  /* Mobile stat display improvements */
  .stat-display {
    min-height: 60px;
    padding: 0.5rem 0;
  }

  .stat-value {
    margin-bottom: 0.25rem;
  }

  .stat-number {
    font-size: 2.25rem !important;
    font-weight: 700;
    line-height: 1;
  }

  .stat-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
  }
}

/* Responsive card layouts */
.card-responsive {
  width: 100%;
  margin-bottom: 1rem;
}

@media (min-width: 576px) {
  .card-responsive {
    margin-bottom: 1.5rem;
  }
}

@media (min-width: 992px) {
  .card-responsive {
    margin-bottom: 2rem;
  }
}

/* ===== MOBILE CONTENT AND TYPOGRAPHY IMPROVEMENTS ===== */

/* Mobile content optimizations */
@media (max-width: 767.98px) {
  /* Page titles and headers */
  .page-title {
    font-size: 1.75rem !important;
    font-weight: 700;
    margin-bottom: 1.5rem !important;
    color: #1f2937;
    line-height: 1.2;
  }

  /* Content container improvements */
  .content {
    padding: 0.75rem !important;
  }

  .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Reduce excessive row margins */
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
  }

  /* Better spacing for content sections */
  .content>.container-fluid>.row {
    margin-bottom: 1rem !important;
  }

  /* Improved card layouts */
  .card {
    border-radius: 1rem !important;
    margin-bottom: 1rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  }

  .card-header {
    padding: 1rem 1.25rem !important;
    border-radius: 1rem 1rem 0 0 !important;
  }

  .card-body {
    padding: 1.25rem !important;
  }

  /* Better mobile typography */
  h1,
  .h1 {
    font-size: 1.75rem !important;
  }

  h2,
  .h2 {
    font-size: 1.5rem !important;
  }

  h3,
  .h3 {
    font-size: 1.25rem !important;
  }

  h4,
  .h4 {
    font-size: 1.1rem !important;
  }

  h5,
  .h5 {
    font-size: 1rem !important;
  }

  h6,
  .h6 {
    font-size: 0.9rem !important;
  }

  /* Row and column improvements */
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .row>[class*="col-"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-bottom: 1rem;
  }

  .row>[class*="col-"]:last-child {
    margin-bottom: 0;
  }

  /* Alert improvements */
  .alert {
    border-radius: 0.75rem !important;
    padding: 1rem 1.25rem !important;
    margin-bottom: 1rem !important;
  }

  /* Loading placeholders */
  .placeholder-glow .placeholder {
    border-radius: 0.5rem;
  }
}

/* ===== MOBILE TABLE OPTIMIZATIONS ===== */

/* Mobile-first table styling */
@media (max-width: 767.98px) {
  /* Convert tables to card layout on mobile */
  .dashboard-table {
    border: none;
  }

  .dashboard-table thead {
    display: none;
  }

  .dashboard-table tbody {
    display: block;
  }

  .dashboard-table tr {
    display: block;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }

  .dashboard-table td {
    display: block;
    border: none;
    padding: 0.25rem 0;
    text-align: left !important;
  }

  /* Add labels for each data cell */
  .dashboard-table td:before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
  }

  /* Style the first cell (name) differently */
  .dashboard-table tr td:first-child {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
  }

  .dashboard-table tr td:first-child:before {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #6b7280;
    margin-bottom: 0.5rem;
  }

  .dashboard-table tr td:first-child a {
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
  }

  /* Badge improvements for mobile */
  .dashboard-table .badge {
    display: inline-block;
    margin: 0.125rem 0.25rem 0.125rem 0;
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 8px;
  }

  /* Special styling for badge collections */
  .dashboard-table td>div {
    margin-top: 0.25rem;
  }

  .dashboard-table td>div .badge {
    margin-bottom: 0.25rem;
  }

  /* ===== MOBILE CARD TABLE (Global Pattern) ===== */
  /* Transforms any table with this class into a card list on mobile */
  .mobile-card-table {
    border: none !important;
    background: transparent !important;
  }

  .mobile-card-table thead {
    display: none !important;
  }

  .mobile-card-table tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .mobile-card-table tr {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--border-color, #e5e7eb) !important;
    border-radius: 0.75rem;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
  }

  .mobile-card-table tr:hover {
    background: #ffffff !important;
    /* Reset hover to white or let specific hover work */
  }

  .mobile-card-table td {
    display: block;
    /* Stack content within cells naturally, or use flex if needed */
    width: 100% !important;
    padding: 1rem !important;
    border: none !important;
    border-bottom: 1px solid var(--border-light, #f3f4f6) !important;
    text-align: left !important;
  }

  .mobile-card-table td:last-child {
    border-bottom: none !important;
  }

  /* Optional: Utility to hide specific columns on mobile */
  .mobile-hide {
    display: none !important;
  }

  /* Specific tweak for icon+text pattern in first column often used */
  .mobile-card-table td:first-child .d-flex {
    align-items: center;
  }

  .mobile-card-table .scan-td-name {
    background: #f9fafb;
    /* Slight highlight for the 'header' part of the card */
    border-bottom: 1px solid var(--border-color, #e5e7eb) !important;
  }

  /* Mobile card header optimization */
  .card .card-header {
    padding: 1rem 1.25rem;
  }

  .card .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .card .header-content .card-title {
    margin-bottom: 0;
    font-size: 1.1rem;
  }

  .card .header-actions {
    justify-content: stretch;
  }

  .card .header-actions .btn {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }

  /* ===== MOBILE NAVIGATION LAYOUT FIXES ===== */

  /* Fix navbar alignment and spacing for ALL mobile screens */
  .navbar {
    padding: 0.625rem 0.875rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.5rem !important;
    flex-wrap: nowrap !important;
    min-height: 48px !important;
    height: auto !important;
    overflow: visible !important;
    position: relative !important;
    z-index: 100 !important;
  }

  /* Sidebar toggle - ensure proper spacing and prevent merging */
  .sidebar-toggle {
    order: 1 !important;
    margin-right: 0.5rem !important;
    flex-shrink: 0 !important;
    width: 2.25rem !important;
    height: 2.25rem !important;
    min-width: 2.25rem !important;
    padding: 0 !important;
  }

  /* Remove flex-grow spacer to prevent alignment issues */
  .navbar .flex-grow-1 {
    display: none !important;
  }

  /* Adjust search on mobile */
  .navbar-search {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 200px !important;
    margin: 0 0.5rem !important;
    order: 2 !important;
    position: relative !important;
    overflow: visible !important;
    z-index: 100 !important;
  }

  .search-input {
    font-size: 0.8rem !important;
    padding: 0.4rem 0.6rem 0.4rem 2rem !important;
  }

  .search-icon {
    left: 0.625rem !important;
    font-size: 0.8rem !important;
  }

  /* Search results dropdown - mobile optimizations */
  .search-results-dropdown {
    position: fixed !important;
    top: var(--topnav-height-mobile) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100vh - var(--topnav-height-mobile)) !important;
    margin-top: 0 !important;
    z-index: 1050 !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
    border-radius: 0 0 1rem 1rem !important;
    border-top: 1px solid var(--border-color) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: var(--white) !important;
  }

  /* Ensure search input wrapper contains dropdown properly */
  .search-input-wrapper {
    position: relative !important;
    width: 100% !important;
  }

  .search-results-content {
    padding: 0.375rem 0 !important;
  }

  .search-results-section-header {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.7rem !important;
  }

  .search-result-item {
    padding: 0.625rem 0.75rem !important;
    min-height: 44px !important;
  }

  .search-result-item-name {
    font-size: 0.8125rem !important;
  }

  .search-result-item-description {
    font-size: 0.6875rem !important;
  }

  .search-results-empty {
    padding: 1.5rem 0.75rem !important;
  }

  .search-results-empty p {
    font-size: 0.8125rem !important;
  }

  /* Navbar actions - ensure proper spacing from sidebar toggle */
  .navbar-actions {
    order: 3 !important;
    gap: 0.375rem !important;
    margin-left: 0.375rem !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Ensure "New" text is visible on mobile (will be hidden on very small screens) */
  .btn-new {
    padding: 0.5rem 0.75rem !important;
    min-width: auto !important;
  }

  .btn-new span {
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Smaller icon buttons on mobile */
  .btn-icon {
    width: 2.25rem !important;
    height: 2.25rem !important;
    min-width: 2.25rem !important;
  }

  /* User dropdown - ensure it doesn't merge with sidebar toggle */
  .navbar-user-dropdown {
    margin-left: 0 !important;
    flex-shrink: 0 !important;
  }

  /* Workspace selector - remove border and fix alignment (if present) */
  .workspace-selector {
    order: 2 !important;
    flex: 1 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    max-width: 150px !important;
  }

  .workspace-selector .nav-link,
  .workspace-selector .nav-icon {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem !important;
    border-radius: 0.5rem !important;
    text-decoration: none !important;
  }

  .workspace-selector .nav-link:hover,
  .workspace-selector .nav-icon:hover,
  .workspace-selector .nav-link:focus,
  .workspace-selector .nav-icon:focus {
    background: rgba(0, 0, 0, 0.05) !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* Ensure proper spacing between all navbar elements */
  .navbar>*:not(:first-child):not(.navbar-search):not(.navbar-actions) {
    margin-left: 0.25rem !important;
  }

  .navbar>*:not(:last-child) {
    margin-right: 0 !important;
  }

  /* ===== PAGE HEADER MOBILE OPTIMIZATIONS ===== */

  /* Page header layout improvements */
  .page-header {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
    border-radius: 1rem !important;
  }

  /* Override Bootstrap margin classes */
  .page-header.mb-4 {
    margin-bottom: 1rem !important;
  }

  .header-main {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
  }

  .title-section {
    text-align: left !important;
  }

  .item-title {
    font-size: 1.75rem !important;
    line-height: 1.2 !important;
    margin-bottom: 0.75rem !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 0.75rem !important;
  }

  .item-title .fas,
  .item-title .fa,
  .item-title i,
  .item-title .align-middle {
    font-size: 1.5rem !important;
    margin-right: 0.75rem !important;
    margin-left: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    flex-shrink: 0;
  }

  /* Override Bootstrap margin classes specifically */
  .item-title .me-3 {
    margin-right: 0.75rem !important;
  }

  .item-subtitle {
    font-size: 1rem !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0 !important;
    color: #6b7280 !important;
    line-height: 1.4 !important;
  }

  /* ===== FOOTER MOBILE OPTIMIZATIONS ===== */

  /* Modern footer mobile layout - COMPACT */
  .modern-footer {
    padding: 0.75rem 0 !important;
    margin-top: auto !important;
    position: relative !important;
  }

  /* Ensure proper page layout with sticky footer */
  .wrapper {
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .main {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .content {
    flex: 1 !important;
  }

  .modern-footer .container-fluid {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .footer-content {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 0.75rem !important;
  }

  .footer-left {
    order: 1;
    text-align: center !important;
  }

  .footer-right {
    order: 2;
    width: 100%;
    justify-content: center !important;
  }

  .brand-section {
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }

  .brand-link {
    font-size: 1.1rem !important;
  }

  .version-tag {
    font-size: 0.7rem !important;
    padding: 0.25rem 0.5rem !important;
  }

  .copyright-text {
    font-size: 0.75rem !important;
    margin-top: 0.25rem !important;
  }

  .footer-actions {
    width: 100%;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  .action-link {
    flex: 1;
    min-width: 160px;
    max-width: 200px;
    justify-content: center !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
  }

  /* Public page footer optimizations */
  .public-footer {
    padding: 1.5rem 0 !important;
    margin-top: 2rem !important;
  }

  .public-footer-container {
    padding: 0 1rem !important;
  }

  .footer-content {
    text-align: center !important;
  }

  .footer-branding {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .footer-brand-name {
    font-size: 1.1rem !important;
    margin-bottom: 0.25rem !important;
  }

  .footer-powered-by {
    font-size: 0.85rem !important;
  }
}

/* Very small mobile devices (phones in portrait) */
@media (max-width: 480px) {
  /* Ultra-compact mobile layout */
  .content {
    padding: 0.75rem 0.5rem !important;
  }

  .page-title {
    font-size: 1.5rem !important;
    margin-bottom: 1rem !important;
  }

  /* Ultra-compact cards */
  .card {
    border-radius: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }

  .card-header {
    padding: 0.75rem 1rem !important;
  }

  .card-body {
    padding: 1rem !important;
  }

  /* Smaller stat numbers for very small screens */
  .stat-number {
    font-size: 1.75rem !important;
  }

  .stats-card .card-title {
    font-size: 0.75rem !important;
  }

  /* Button improvements for small screens */
  .btn {
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
  }

  /* ===== MOBILE NAVIGATION ALIGNMENT FIXES ===== */

  /* Navbar structure improvements - refine spacing */
  .navbar {
    padding: 0.625rem 0.875rem !important;
    gap: 0.5rem !important;
  }

  /* Hamburger menu positioning - ensure proper spacing */
  .sidebar-toggle {
    order: 1 !important;
    margin-right: 0.5rem !important;
    flex-shrink: 0 !important;
    width: 2.25rem !important;
    height: 2.25rem !important;
  }

  /* Search bar refinement */
  .navbar-search {
    max-width: 180px !important;
    margin: 0 0.375rem !important;
  }

  /* Navbar actions refinement */
  .navbar-actions {
    gap: 0.375rem !important;
    margin-left: 0.375rem !important;
  }

  /* Workspace selector positioning and styling */
  .workspace-selector {
    order: 2 !important;
    flex: 1 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  .workspace-selector .nav-link,
  .workspace-selector .nav-icon {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem !important;
    border-radius: 0.5rem !important;
  }

  .workspace-selector .nav-link:hover,
  .workspace-selector .nav-icon:hover {
    background: rgba(0, 0, 0, 0.05) !important;
  }

  /* User dropdown positioning */
  .navbar-collapse {
    order: 3 !important;
    flex-shrink: 0 !important;
  }

  .navbar-nav {
    margin-left: auto !important;
  }

  /* Ultra-compact table cards */
  .dashboard-table tr {
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
  }

  .dashboard-table tr td:first-child a {
    font-size: 1rem;
  }

  .dashboard-table .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  /* Ultra-compact page headers */
  .page-header {
    padding: 1rem 0.75rem !important;
    margin-bottom: 1rem !important;
    border-radius: 0.75rem !important;
  }

  .item-title {
    font-size: 1.5rem !important;
    gap: 0.5rem !important;
  }

  .item-title .fas,
  .item-title .fa,
  .item-title i {
    font-size: 1.25rem !important;
  }

  .item-subtitle {
    font-size: 0.9rem !important;
  }

  /* Ultra-compact footer */
  .modern-footer {
    padding: 1.25rem 0 !important;
  }

  .modern-footer .container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .brand-section {
    gap: 0.5rem !important;
    margin-bottom: 0.75rem !important;
  }

  .brand-link {
    font-size: 1.1rem !important;
  }

  .version-tag {
    font-size: 0.7rem !important;
    padding: 0.25rem 0.5rem !important;
  }

  .copyright-text {
    font-size: 0.75rem !important;
  }

  .action-link {
    min-width: 180px;
    padding: 0.875rem 1.25rem !important;
    font-size: 0.85rem !important;
  }

  .action-link span {
    display: none;
  }

  .action-link .fas {
    margin-right: 0 !important;
  }
}

/* ===== IPHONE SE AND VERY SMALL DEVICES (320px) ===== */
@media (max-width: 375px) {
  /* Ultra-compact navbar for iPhone SE */
  .navbar {
    padding: 0.5rem 0.75rem !important;
    gap: 0.375rem !important;
    min-height: 48px !important;
    height: auto !important;
  }

  /* Sidebar toggle - ensure proper spacing */
  .sidebar-toggle {
    order: 1 !important;
    margin-right: 0.375rem !important;
    flex-shrink: 0 !important;
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    padding: 0 !important;
  }

  /* Search bar - reduce size on very small screens */
  .navbar-search {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 120px !important;
    margin: 0 0.25rem !important;
    order: 2 !important;
  }

  .search-input {
    font-size: 0.75rem !important;
    padding: 0.375rem 0.5rem 0.375rem 1.75rem !important;
  }

  .search-input::placeholder {
    font-size: 0.7rem !important;
  }

  .search-icon {
    left: 0.5rem !important;
    font-size: 0.75rem !important;
  }

  /* Search results dropdown - very small screens */
  .search-results-dropdown {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(50vh, 350px) !important;
    margin-top: 0.375rem !important;
  }

  .search-results-content {
    padding: 0.25rem 0 !important;
  }

  .search-result-item {
    padding: 0.5rem 0.625rem !important;
    min-height: 40px !important;
  }

  .search-results-section-header {
    padding: 0.375rem 0.625rem !important;
    font-size: 0.6875rem !important;
  }

  .search-result-item-name {
    font-size: 0.75rem !important;
  }

  .search-result-item-description {
    font-size: 0.625rem !important;
  }

  /* Remove flex-grow spacer if it exists */
  .navbar .flex-grow-1 {
    display: none !important;
  }

  /* Navbar actions - ensure proper spacing from sidebar toggle */
  .navbar-actions {
    order: 3 !important;
    gap: 0.25rem !important;
    margin-left: 0.25rem !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Hide "New" text on very small screens - icon only */
  .btn-new {
    padding: 0.375rem 0.5rem !important;
    min-width: 2rem !important;
    width: 2rem !important;
  }

  .btn-new span {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .btn-new i {
    margin-right: 0 !important;
  }

  .btn-new.dropdown-toggle::after {
    display: none !important;
  }

  /* Icon buttons - smaller on very small screens */
  .btn-icon {
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    padding: 0 !important;
  }

  .btn-icon i {
    font-size: 0.875rem !important;
  }

  /* User dropdown - ensure it doesn't merge with sidebar toggle */
  .navbar-user-dropdown {
    margin-left: 0 !important;
    flex-shrink: 0 !important;
  }

  /* Ensure proper spacing between all navbar elements */
  .navbar>*:not(:first-child) {
    margin-left: 0.25rem !important;
  }

  .navbar>*:not(:last-child) {
    margin-right: 0 !important;
  }

  /* Content padding adjustments */
  .content {
    padding: 0.75rem 0.5rem !important;
  }

  /* Page title */
  .page-title {
    font-size: 1.375rem !important;
    margin-bottom: 0.875rem !important;
  }
}

/* ===== MOBILE EMPTY STATE AND GENERAL OPTIMIZATIONS (ALL MOBILE) ===== */
@media (max-width: 767.98px) {
  /* Better empty state layout */
  .dashboard-empty {
    padding: 2rem 1rem !important;
    text-align: center !important;
  }

  .dashboard-empty i {
    font-size: 2.5rem !important;
    margin-bottom: 1rem !important;
    color: #9ca3af !important;
  }

  .dashboard-empty p {
    font-size: 1rem !important;
    color: #6b7280 !important;
    margin: 0 !important;
  }

  /* Loading states */
  .spinner-border {
    width: 2rem !important;
    height: 2rem !important;
  }
}

/* ===== MOBILE-FIRST FORM LAYOUTS ===== */

/* Form container improvements */
.form-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

@media (min-width: 576px) {
  .form-container {
    max-width: 540px;
    padding: 1.5rem;
  }
}

@media (min-width: 768px) {
  .form-container {
    max-width: 720px;
    padding: 2rem;
  }
}

@media (min-width: 992px) {
  .form-container {
    max-width: 960px;
  }
}

/* Responsive form groups */
.form-group-responsive {
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .form-group-responsive {
    margin-bottom: 1.5rem;
  }
}

/* Multi-column forms */
.form-row-responsive {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .form-row-responsive {
    flex-direction: row;
    gap: 1.5rem;
  }

  .form-row-responsive>* {
    flex: 1;
  }
}

/* ===== TABLET OPTIMIZATIONS ===== */

@media (min-width: 768px) and (max-width: 1199.98px) {
  /* Tablet-specific dashboard layout */
  .dashboard-tablet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  /* Tablet sidebar optimizations */
  .sidebar-tablet {
    width: 240px;
  }

  /* Tablet form layout */
  .form-tablet-stack .row {
    margin-bottom: 1rem;
  }

  .form-tablet-stack .col-md-6 {
    margin-bottom: 0.75rem;
  }

  /* Tablet table improvements */
  .table-tablet th,
  .table-tablet td {
    padding: 0.875rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* ===== LARGE SCREEN ENHANCEMENTS ===== */

@media (min-width: 1200px) {
  /* Enhanced sidebar for large screens */
  .sidebar-large {
    width: 300px;
  }
  /* Large screen dashboard grid */
  .dashboard-large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
  }

  /* Enhanced content spacing */
  .content-large {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 3rem;
  }

  /* Large screen typography */
  .title-large {
    font-size: 2.25rem;
    line-height: 1.2;
  }

  .subtitle-large {
    font-size: 1.125rem;
    opacity: 0.8;
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Focus management */
.focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .sidebar,
  .main,
  .card,
  .btn {
    transition: none !important;
    transform: none !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .btn {
    border-width: 3px;
  }

  .form-control,
  .form-select {
    border-width: 3px;
  }

  .card {
    border-width: 2px;
  }

  .sidebar {
    border-right-width: 3px;
  }
}

/* ===== PRINT OPTIMIZATIONS ===== */

@media print {
  .sidebar,
  .navbar,
  .sidebar-toggle,
  .btn:not(.btn-print),
  .dropdown,
  .modal {
    display: none !important;
  }

  .main {
    padding-left: 0 !important;
  }

  .content {
    padding: 0 !important;
    max-width: none !important;
  }

  .card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }

  .table {
    font-size: 0.8rem;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
  }
}

/* ===== RESPONSIVE NAVIGATION HELPERS ===== */

/* Mobile navigation stack */
.nav-mobile-stack {
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .nav-mobile-stack {
    flex-direction: row;
    gap: 1rem;
  }
}

/* Responsive breadcrumb */
.breadcrumb-responsive {
  font-size: 0.75rem;
  padding: 0.5rem 0;
}

@media (min-width: 768px) {
  .breadcrumb-responsive {
    font-size: 0.875rem;
    padding: 0.75rem 0;
  }
}

/* ===== CONTAINER IMPROVEMENTS ===== */

/* Responsive container with better mobile margins */
.container-responsive {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 576px) {
  .container-responsive {
    max-width: 540px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 768px) {
  .container-responsive {
    max-width: 720px;
  }
}

@media (min-width: 992px) {
  .container-responsive {
    max-width: 960px;
  }
}

@media (min-width: 1200px) {
  .container-responsive {
    max-width: 1140px;
  }
}

@media (min-width: 1400px) {
  .container-responsive {
    max-width: 1320px;
  }
}

/* ===== SPACING UTILITIES ===== */

/* Responsive margin utilities */
.m-responsive {
  margin: 0.5rem;
}

@media (min-width: 768px) {
  .m-responsive {
    margin: 1rem;
  }
}

@media (min-width: 1200px) {
  .m-responsive {
    margin: 1.5rem;
  }
}

/* Responsive padding utilities */
.p-responsive {
  padding: 0.5rem;
}

@media (min-width: 768px) {
  .p-responsive {
    padding: 1rem;
  }
}

@media (min-width: 1200px) {
  .p-responsive {
    padding: 1.5rem;
  }
}

/* ===== OVERFLOW HANDLING ===== */

/* Responsive text overflow */
.text-truncate-responsive {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .text-truncate-responsive {
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
  }
}

/* Responsive scroll containers */
.scroll-container-mobile {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .scroll-container-mobile {
    overflow-x: visible;
  }
}