/*!
 * sbomify Layout Components
 * AdminKit-inspired layout with Bootstrap 5.3
 */

/* ===== CSS VARIABLES ===== */
:root {
  --sidebar-width: 280px;
  --sidebar-width-tablet: 260px;
  --sidebar-width-mobile: 300px;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e9ecef;
  --sidebar-color: #495057;
  --sidebar-hover-bg: #f8f9fa;
  --sidebar-active-bg: #0d6efd;
  --sidebar-active-color: #ffffff;
  --transition-sidebar: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s ease-in-out;
  --topnav-height: 64px;
  --topnav-height-mobile: 56px;

  /* Touch targets */
  --touch-target-min: 44px;
  --tap-area-padding: 12px;

  /* Responsive breakpoints */
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
}

/* ===== ADMINKIT-STYLE LAYOUT ===== */
body {
  height: 100vh;
  overflow-x: hidden;
}

.wrapper {
  display: flex;
  width: 100%;
  align-items: stretch;
  min-height: 100vh;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding-left: var(--sidebar-width);
  min-height: 100vh;
}

.content {
  flex: 1;
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-primary);
}

/* ===== SIDEBAR STYLING ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: all var(--transition-sidebar);
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.05);
}

.sidebar-content {
  position: relative;
}

/* Sidebar header row with brand and close button */
.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  padding: 1.25rem 1.5rem;
  margin: 0 0 0.75rem 0;
  height: var(--topnav-height);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--sidebar-color);
  text-decoration: none;
  font-size: 1.1rem;
  white-space: nowrap;
  flex: 1;
}

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

/* Sidebar close button */
.sidebar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-sidebar);
  flex-shrink: 0;
}

.sidebar-close:hover {
  background-color: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.2);
  color: #dc3545;
}

.sidebar-close:focus {
  outline: 2px solid #dc3545;
  outline-offset: 2px;
}

.sidebar-close .fas {
  font-size: 1.1rem;
}

.sidebar-nav {
  padding: 0.5rem 0;
  margin: 0;
  list-style: none;
}

.sidebar-header {
  color: var(--sidebar-color);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 1.75rem 1.5rem 0.75rem;
  padding: 0;
  opacity: 0.8;
}

.sidebar-item {
  position: relative;
  margin: 0.25rem 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--sidebar-color);
  background: transparent;
  border: 0;
  padding: 0.875rem 1.25rem;
  position: relative;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0.375rem;
  transform: translateX(0);
  min-height: 2.75rem;
}

.sidebar-link:hover,
.sidebar-link:focus {
  color: var(--sidebar-color);
  background: var(--sidebar-hover-bg);
  text-decoration: none;
  transform: translateX(2px);
  outline: none;
}

.sidebar-link:focus-visible {
  outline: 2px solid var(--sidebar-active-bg);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

.sidebar-item.active > .sidebar-link {
  color: var(--sidebar-active-color);
  background: var(--sidebar-active-bg);
  font-weight: 500;
  transform: translateX(2px);
}

.sidebar-item.active > .sidebar-link:hover {
  color: var(--sidebar-active-color);
  background: var(--sidebar-active-bg);
  transform: translateX(4px);
}

.sidebar-link i {
  width: 1.125rem;
  height: 1.125rem;
  margin-right: 1rem;
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.75;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== TOP NAVIGATION ===== */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
  z-index: var(--z-fixed);
  height: var(--topnav-height);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-nav {
  gap: 0.5rem;
}

.navbar-bg {
  background-color: var(--white) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

.navbar-light .navbar-nav .nav-link {
  color: var(--text-primary);
}

.navbar-align {
  margin-left: auto;
}

/* Team selector styling */
.navbar .form-select {
  border: 1px solid var(--border-color);
  background-color: var(--white);
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
}

.navbar .form-select:focus {
  border-color: var(--sidebar-active-bg);
  box-shadow: 0 0 0 0.2rem rgba(59, 125, 221, 0.25);
}

/* ===== ENHANCED SIDEBAR TOGGLE ===== */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  width: 2.75rem;
  height: 2.75rem;
  text-decoration: none;
  color: var(--text-secondary);
  border-radius: 0.5rem;
  transition: all var(--transition-sidebar);
  background: transparent;
  border: 2px solid transparent;
  margin-right: 0.75rem;
  position: relative;
  overflow: hidden;
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  background-color: rgba(13, 110, 253, 0.1);
  border-color: rgba(13, 110, 253, 0.2);
  text-decoration: none;
  transform: scale(1.05);
}

.sidebar-toggle:focus {
  outline: 2px solid var(--sidebar-active-bg);
  outline-offset: 2px;
  border-color: var(--sidebar-active-bg);
}

.sidebar-toggle:active {
  transform: scale(0.95);
  background-color: rgba(13, 110, 253, 0.2);
}

/* Enhanced hamburger icon with animation */
.hamburger {
  position: relative;
  display: inline-block;
  width: 1.25rem;
  height: 1rem;
  vertical-align: middle;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  transition: all var(--transition-sidebar);
}

.hamburger::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0.125rem;
  background: currentColor;
  border-radius: 0.0625rem;
  box-shadow: 0 0.375rem 0 0 currentColor, 0 0.75rem 0 0 currentColor;
}

/* Hamburger animation when sidebar is open */
[aria-expanded="true"] .hamburger::before {
  transform: rotate(45deg) translate(0.25rem, 0.25rem);
  box-shadow: 0 0 0 0 transparent;
}

[aria-expanded="true"] .hamburger::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0.375rem;
  width: 100%;
  height: 0.125rem;
  background: currentColor;
  border-radius: 0.0625rem;
  transform: rotate(-45deg);
}

/* ===== ENHANCED RESPONSIVE DESIGN ===== */

/* Large screens and up (Desktop) */
@media (min-width: 992px) {
  .sidebar-toggle {
    display: none;
  }

  .sidebar {
    width: var(--sidebar-width);
  }

  .main {
    padding-left: var(--sidebar-width);
  }
}

/* Large screens down (Tablet landscape and below) */
@media (max-width: 991.98px) {
  .sidebar {
    width: var(--sidebar-width-tablet);
    margin-left: calc(var(--sidebar-width-tablet) * -1);
    z-index: 1050; /* Higher than Bootstrap modals */
  }

  .sidebar.sidebar-mobile-show {
    margin-left: 0;
    box-shadow: 0 0 2rem rgba(0, 0, 0, 0.3);
  }

  .main {
    padding-left: 0;
  }

  .main.sidebar-mobile-show::before {
    content: "";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1040;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.25s ease-out;
  }

  .navbar {
    height: var(--topnav-height);
    padding: 0.75rem 1.5rem;
  }

  /* Touch-friendly workspace selector */
  .workspace-selector .nav-link {
    min-height: var(--touch-target-min);
    padding: var(--tap-area-padding) 1rem;
    font-size: 0.875rem;
  }

  .workspace-selector {
    margin-right: auto;
    flex: 1;
    max-width: 300px;
  }
}

/* Medium screens (Tablet portrait) */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width-mobile);
    margin-left: calc(var(--sidebar-width-mobile) * -1);
  }

  .content {
    padding: 1rem;
  }

  .navbar {
    height: var(--topnav-height-mobile);
    padding: 0.5rem 1rem;
  }

  .sidebar-header-row {
    padding: 1rem 1.25rem;
    height: var(--topnav-height-mobile);
  }

  .sidebar-brand {
    font-size: 1rem;
  }

  /* Enhanced touch targets for tablet */
  .sidebar-link {
    padding: 1rem 1.25rem;
    min-height: var(--touch-target-min);
    font-size: 0.9rem;
  }

  .sidebar-header {
    margin: 1.5rem 1.25rem 0.75rem;
    font-size: 0.8rem;
  }

  .sidebar-item {
    margin: 0.25rem 0.75rem;
  }

  /* Improve form layouts for tablet */
  .form-control,
  .form-select {
    min-height: var(--touch-target-min);
    padding: 0.75rem 1rem;
    font-size: 1rem; /* Prevent zoom on iOS */
  }

  .btn {
    min-height: var(--touch-target-min);
    padding: 0.75rem 1.5rem;
  }
}

/* Small screens (Mobile) */
@media (max-width: 576px) {
  .sidebar {
    width: 100%;
    margin-left: -100%;
  }

  .content {
    padding: 1rem 0.75rem;
  }

  .navbar {
    padding: 0.75rem 1rem;
    height: auto;
    min-height: var(--topnav-height-mobile);
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Optimize navbar layout for mobile */
  .navbar .workspace-selector {
    order: 1;
    flex: 1;
    max-width: calc(100% - 120px);
  }

  .navbar .navbar-collapse {
    order: 2;
    flex-shrink: 0;
  }

  .sidebar-toggle {
    order: 0;
    margin-right: 1rem;
  }

  .sidebar-header-row {
    padding: 0.875rem 1rem;
    height: var(--topnav-height-mobile);
  }

  .sidebar-brand {
    font-size: 0.9rem;
  }

  /* Mobile-optimized touch targets */
  .sidebar-link {
    padding: 1rem;
    min-height: var(--touch-target-min);
    font-size: 0.9rem;
  }

  .sidebar-header {
    margin: 1.25rem 1rem 0.5rem;
    font-size: 0.75rem;
  }

  .sidebar-item {
    margin: 0.25rem 0.5rem;
  }

  /* Mobile form improvements */
  .form-control,
  .form-select,
  .btn {
    min-height: var(--touch-target-min);
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .form-control,
  .form-select {
    padding: 0.875rem 1rem;
  }

  .btn {
    padding: 0.875rem 1.5rem;
    font-weight: 500;
  }

  /* Stack form elements vertically on mobile */
  .row > [class*="col-"] {
    margin-bottom: 1rem;
  }

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

  /* Mobile workspace selector */
  .workspace-selector {
    max-width: calc(100vw - 120px);
  }

  .workspace-selector .nav-link {
    padding: var(--tap-area-padding) 0.75rem;
    font-size: 0.875rem;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .content {
    padding: 0.5rem 0.75rem;
  }

  .sidebar-link {
    padding: 0.875rem 0.75rem;
  }

  .sidebar-header-row {
    padding: 0.75rem;
  }

  .sidebar-brand img {
    width: 100px;
    height: auto;
  }

  .sidebar-close {
    width: 2rem;
    height: 2rem;
  }

  .sidebar-close .fas {
    font-size: 1rem;
  }
}

/* Animation keyframes */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .hamburger::before {
    height: 0.0625rem;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

.sidebar-link:focus {
  outline: 2px solid var(--sidebar-active-bg);
  outline-offset: 2px;
}

/* ===== JAVASCRIPT TOGGLE CLASSES ===== */
.js-sidebar-toggle {
  cursor: pointer;
}

.sidebar-mobile-show {
  margin-left: 0 !important;
}

/* ===== USER DROPDOWN STYLING ===== */
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  text-decoration: none;
  color: var(--text-secondary);
  border-radius: 0.25rem;
  transition: all var(--transition-sidebar);
}

.nav-icon:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  text-decoration: none;
}

.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  padding: 0.5rem 0;
}

.dropdown-item {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background-color var(--transition-sidebar);
}

.dropdown-item:hover {
  background-color: var(--gray-100);
  color: var(--text-primary);
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
}

/* ===== MESSAGES CONTAINER ===== */
.messages-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1055;
  max-width: 350px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .messages-container {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }
}

/* ===== CONTENT IMPROVEMENTS ===== */
.content .container-fluid {
  max-width: none;
}

/* Ensure proper spacing for dashboard cards */
.content .row {
  margin-left: -0.75rem;
  margin-right: -0.75rem;
}

.content .row > [class*="col-"] {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* ===== WORKSPACE SELECTOR STYLING ===== */
.workspace-selector {
  max-width: 280px;
}

.workspace-selector .nav-link {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.workspace-selector .nav-link .fas {
  flex-shrink: 0;
}

.workspace-selector .nav-link:hover,
.workspace-selector .nav-link:focus {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--bs-dark);
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.workspace-selector .nav-link:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.workspace-selector .dropdown-menu {
  min-width: 220px;
  max-width: 320px;
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
}

.workspace-selector .dropdown-item {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  border-radius: 0;
}

.workspace-selector .dropdown-item:hover {
  background-color: #f8f9fa;
}

.workspace-selector .dropdown-item.active {
  background-color: var(--bs-primary);
  color: white;
}

.workspace-selector .dropdown-item.active:hover {
  background-color: var(--bs-primary);
  color: white;
}

.workspace-selector .dropdown-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary);
  padding: 0.5rem 1rem;
}

.workspace-selector .fas {
  font-size: 0.875rem;
  opacity: 0.7;
  width: 1rem;
}

.workspace-selector .dropdown-item.active .fas {
  opacity: 1;
}

.workspace-selector .fas.fa-check {
  font-size: 0.75rem;
  margin-left: auto;
}

/* Mobile adjustments for workspace selector */
@media (max-width: 768px) {
  .workspace-selector {
    max-width: 200px;
  }

  .workspace-selector .dropdown-menu {
    min-width: 180px;
    max-width: 250px;
  }
}

/* ===== MODERN BALANCED FOOTER STYLING ===== */
.modern-footer {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 2rem 0;
  margin-top: auto;
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.03);
}

.modern-footer .container-fluid {
  padding-left: 2rem;
  padding-right: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}

.footer-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.brand-link {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0d6efd !important;
  text-decoration: none;
  letter-spacing: -0.025em;
  transition: all 0.2s ease;
}

.brand-link:hover {
  color: #0b5ed7 !important;
  transform: translateY(-1px);
}

.version-tag {
  background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
  color: #1976d2;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(25, 118, 210, 0.2);
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.version-tag:hover {
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  color: white;
  border-color: #1976d2;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
  text-decoration: none;
}

.copyright-text {
  font-size: 0.875rem;
  color: #6c757d;
  line-height: 1.4;
  font-weight: 400;
}

.footer-right {
  display: flex;
  align-items: flex-start;
}

.footer-actions {
  display: flex;
  gap: 1rem;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #495057;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.action-link:hover {
  color: #0d6efd;
  background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
  border-color: rgba(13, 110, 253, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15);
  text-decoration: none;
}

.action-link .fas {
  font-size: 0.875rem;
  opacity: 0.8;
}

.action-link:hover .fas {
  opacity: 1;
}

/* Responsive adjustments for footer */
@media (max-width: 992px) {
  .modern-footer {
    padding: 1.75rem 0;
  }

  .modern-footer .container-fluid {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .footer-content {
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .modern-footer {
    padding: 1.5rem 0;
  }

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

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

  .footer-left {
    align-items: center;
    text-align: center;
  }

  .brand-section {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .footer-right {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 576px) {
  .modern-footer {
    padding: 1.25rem 0;
  }

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

  .version-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
  }

  .copyright-text {
    font-size: 0.8rem;
  }

  .action-link {
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
  }

  .action-link span {
    display: none;
  }

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