/**
 * Calculator Sidebar Styles
 * Desktop persistent, tablet collapsible layout
 */

/* Global body class för desktop layout */
body.has-sidebar {
  margin-left: 0;
}

/* Pusha app-shell åt höger på desktop */
@media (min-width: 1025px) {
  body.has-sidebar {
    padding-left: 280px;
  }
  
  body.has-sidebar app-shell {
    margin-left: 0;
    transition: margin-left 0.3s ease;
  }
}

/* Tablet och mindre - overlay mode, ingen margin */
@media (max-width: 1024px) {
  body.has-sidebar app-shell {
    margin-left: 0;
  }
}

/* Calculator sidebar custom element */
calculator-sidebar {
  display: block;
  position: relative;
  z-index: 999;
}

/* Smooth transitions */
calculator-sidebar * {
  transition-property: transform, opacity, background-color;
  transition-duration: 0.3s;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure sidebar doesn't interfere with FAB on mobile */
@media (max-width: 767px) {
  calculator-sidebar {
    display: none;
  }
}

/* Z-index hierarchy */
.calculator-sidebar-toggle {
  z-index: 1001;
}

calculator-sidebar {
  z-index: 999;
}

/* Ensure header stays above sidebar */
header,
.header-container,
#header-placeholder {
  z-index: 1000;
}

/* Desktop specific adjustments */
@media (min-width: 1025px) {
  /* Ensure content doesn't jump under sidebar */
  body.has-sidebar main,
  body.has-sidebar .main-content {
    margin-left: 0;
  }
  
  /* Adjust fixed positioned elements */
  body.has-sidebar .notification-center,
  body.has-sidebar .user-dropdown-menu {
    left: calc(50% + 140px); /* Center considering sidebar width */
  }
}

/* Animation keyframes */
@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Accessibility */
calculator-sidebar:focus-within {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Print styles - hide sidebar */
@media print {
  calculator-sidebar {
    display: none !important;
  }
  
  body.has-sidebar app-shell {
    margin-left: 0 !important;
  }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
  calculator-sidebar::part(sidebar) {
    background: #1e293b;
    border-right-color: #334155;
  }
  
  calculator-sidebar::part(backdrop) {
    background: rgba(0, 0, 0, 0.7);
  }
}

/* Smooth scrolling för sidebar content */
calculator-sidebar::part(content) {
  scroll-behavior: smooth;
}

/* Focus trap för keyboard navigation på tablet */
@media (max-width: 1024px) {
  calculator-sidebar[open] {
    isolation: isolate;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  calculator-sidebar::part(sidebar) {
    border-right-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  calculator-sidebar *,
  body.has-sidebar app-shell {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Loading state */
calculator-sidebar:not(:defined) {
  opacity: 0;
}

calculator-sidebar:defined {
  opacity: 1;
  transition: opacity 0.3s ease;
}
