/* components/sidebar-right/sidebar-right.css */
/* Right Drawer Sidebar Component - Overlay drawer */
/* Shares design philosophy with sidebar-internal-right */

/* ========================================
   SIDEBAR RIGHT CONTAINER
   ======================================== */

.c-sidebar-right {
  /* Shared sidebar properties - using CSS custom properties for flexibility */
  --sidebar-header-padding: var(--ds-space-l);
  --sidebar-title-font-size: var(--ds-font-size-l);
  --sidebar-close-size: 40px;
  --sidebar-content-padding: var(--ds-space-l);
  --sidebar-section-title-font-size: var(--ds-font-size-m);
  --sidebar-section-title-color: var(--ds-color-text);
  --sidebar-section-title-border: 1px solid var(--ds-color-border);

  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--nav-sidebar-drawer-width, 400px);
  min-width: var(--nav-sidebar-drawer-min-width, 320px);
  max-width: var(--nav-sidebar-drawer-max-width, 600px);
  background: var(--ds-color-surface);
  border-left: 1px solid var(--ds-color-border);
  display: flex;
  flex-direction: column;
  z-index: calc(var(--nav-z-modal) - 1);
  transform: translateX(100%);
  transition: transform var(--ds-duration-normal) var(--ds-ease-out);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  overflow-x: hidden;
  overflow-y: auto;
}

/* Visible state */
.c-sidebar-right--visible {
  transform: translateX(0);
}

/* Data attribute states */
[data-cms-layout-sidebar-right][data-cms-layout-sidebar-right-open="true"] {
  transform: translateX(0);
}

[data-cms-layout-sidebar-right][data-cms-layout-sidebar-right-open="false"] {
  transform: translateX(100%);
}

/* ========================================
   BACKDROP
   ======================================== */

.c-sidebar-right-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  /* backdrop-filter removed for performance - it causes severe lag during animations */
  z-index: calc(var(--nav-z-modal) - 2);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ds-duration-normal) var(--ds-ease-out),
              visibility var(--ds-duration-normal) var(--ds-ease-out);
}

.c-sidebar-right-backdrop--visible {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   SIDEBAR RIGHT HEADER
   ======================================== */

.c-sidebar-right__header {
  /* Shared header pattern with sidebar-internal-right */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sidebar-header-padding);
  min-height: var(--nav-topbar-height);
  border-bottom: 1px solid var(--ds-color-border);
  flex-shrink: 0;
  background: var(--ds-color-surface);
}

.c-sidebar-right__title {
  /* Shared title pattern */
  margin: 0;
  font-size: var(--sidebar-title-font-size);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--ds-color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Close button now uses shared c-button component - no custom styles needed */

/* ========================================
   SIDEBAR RIGHT CONTENT
   ======================================== */

.c-sidebar-right__content {
  /* Shared content pattern */
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sidebar-content-padding);
  overscroll-behavior: contain;
}

/* When simplebar is active, remove padding from parent and add to content */
.c-sidebar-right__content[data-simplebar-scroll] {
  padding: 0;
}

.c-sidebar-right__content .simplebar-scroll-content {
  padding: var(--sidebar-content-padding);
}

/* Custom scrollbar */
.c-sidebar-right__content::-webkit-scrollbar {
  width: 8px;
}

.c-sidebar-right__content::-webkit-scrollbar-track {
  background: var(--ds-color-surface-raised);
  border-radius: var(--ds-radius-m);
}

.c-sidebar-right__content::-webkit-scrollbar-thumb {
  background: var(--ds-color-border-strong);
  border-radius: var(--ds-radius-m);
  border: 2px solid var(--ds-color-surface-raised);
}

.c-sidebar-right__content::-webkit-scrollbar-thumb:hover {
  background: var(--ds-color-text-weaker);
}

/* ========================================
   SIDEBAR RIGHT FOOTER
   ======================================== */

.c-sidebar-right__footer {
  padding: var(--ds-space-l);
  border-top: 1px solid var(--ds-color-border);
  background: var(--ds-color-surface-raised);
  flex-shrink: 0;
}

.c-sidebar-right__footer-actions {
  display: flex;
  gap: var(--ds-space-m);
  justify-content: flex-end;
}

/* ========================================
   SIDEBAR RIGHT RESIZER
   ======================================== */

.c-sidebar-right__resizer {
  /* Shared resizer pattern */
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: transparent;
  transition: background var(--ds-duration-fast) var(--ds-ease-out);
  z-index: 20;
  user-select: none;
  -webkit-user-select: none;
}

.c-sidebar-right__resizer:hover,
.c-sidebar-right__resizer:active,
.c-sidebar-right__resizer:focus {
  background: var(--ds-color-accent);
}

.c-sidebar-right__resizer:focus-visible {
  outline: none;
  background: var(--ds-color-accent);
}

/* Shared resizing state pattern */
body.is-resizing-sidebar-right {
  cursor: ew-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.is-resizing-sidebar-right * {
  pointer-events: none !important;
}

body.is-resizing-sidebar-right .c-sidebar-right__resizer {
  pointer-events: auto !important;
  background: var(--ds-color-accent) !important;
}

/* ========================================
   CONTENT SECTIONS
   ======================================== */

.c-sidebar-right__section {
  /* Shared section pattern */
  margin-bottom: var(--ds-space-xl);
}

.c-sidebar-right__section:last-child {
  margin-bottom: 0;
}

.c-sidebar-right__section-title {
  /* Shared section title pattern with customization */
  margin: 0 0 var(--ds-space-m) 0;
  font-size: var(--sidebar-section-title-font-size);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--sidebar-section-title-color);
  padding-bottom: var(--ds-space-s);
  border-bottom: var(--sidebar-section-title-border);
}

.c-sidebar-right__section-content {
  position: relative;
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

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

.c-sidebar-right--animating-in {
  animation: slideInRight var(--ds-duration-normal) var(--ds-ease-out);
}

.c-sidebar-right--animating-out {
  animation: slideOutRight var(--ds-duration-normal) var(--ds-ease-out);
}

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

@media (max-width: 768px) {
  .c-sidebar-right {
    width: 100vw;
    max-width: 100vw;
    min-width: 100vw;
  }
  
  .c-sidebar-right__resizer {
    display: none;
  }
  
  .c-sidebar-right__header {
    padding: var(--ds-space-m);
  }
  
  .c-sidebar-right__content {
    padding: var(--ds-space-m);
  }
  
  .c-sidebar-right__footer {
    padding: var(--ds-space-m);
  }
}

@media (max-width: 480px) {
  .c-sidebar-right__title {
    font-size: var(--ds-font-size-m);
  }
  
  .c-sidebar-right__close {
    width: 36px;
    height: 36px;
  }
}

/* ========================================
   DARK THEME
   ======================================== */

[data-theme="dark"] .c-sidebar-right {
  background: var(--ds-color-surface);
  border-left-color: var(--ds-color-border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .c-sidebar-right-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .c-sidebar-right__header {
  background: var(--ds-color-surface);
  border-bottom-color: var(--ds-color-border);
}

[data-theme="dark"] .c-sidebar-right__footer {
  background: var(--ds-color-surface-raised);
  border-top-color: var(--ds-color-border);
}

/* ========================================
   FOCUS TRAP
   ======================================== */

.c-sidebar-right[aria-modal="true"]:focus {
  outline: none;
}

/* ========================================
   PREVENT BODY SCROLL
   ======================================== */

body.has-sidebar-right-open {
  overflow: hidden;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .c-sidebar-right,
  .c-sidebar-right-backdrop {
    display: none !important;
  }
}