/* /opt/cashback/public/css/sidebar.css
   Sidebar (overlay + panel + header divider + accordion)
   ========================================================================== */

/* overlay */
body.sidebar-open {
  overflow: hidden;
}

.cabinet-sidebar {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: flex-end;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.45);
  z-index: 220;
}

/* OPEN */
.cabinet-sidebar--open {
  display: flex;
  animation: sidebarFadeIn 420ms cubic-bezier(0.16,1,0.3,1) both;
}

/* CLOSING */
.cabinet-sidebar--closing {
  display: flex;
  animation: sidebarFadeOut 360ms cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes sidebarFadeIn {
  from { background: rgba(0,0,0,0); }
  to   { background: rgba(0,0,0,0.45); }
}

@keyframes sidebarFadeOut {
  from { background: rgba(0,0,0,0.45); }
  to   { background: rgba(0,0,0,0); }
}

/* panel */
.cabinet-sidebar-panel {
  width: 320px;
  max-width: 90vw;

  height: calc(100% - (var(--sidebar-offset) + var(--safe-top)));
  margin-top: calc(var(--sidebar-offset) + var(--safe-top));

  background: var(--bg-elevated);
  border-left: 1px solid var(--border-soft);
  box-shadow: -12px 0 30px rgba(0,0,0,0.85);

  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;

  will-change: transform, opacity, filter;
}

.cabinet-sidebar--open .cabinet-sidebar-panel {
  animation: sidebarSlideIn 720ms cubic-bezier(0.16,1,0.3,1) both;
}

.cabinet-sidebar--closing .cabinet-sidebar-panel {
  animation: sidebarSlideOut 520ms cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes sidebarSlideIn {
  0%   { transform: translateX(84px); opacity: 0; filter: blur(10px); }
  55%  { opacity: 1; filter: blur(0px); }
  100% { transform: translateX(0); opacity: 1; filter: blur(0px); }
}

@keyframes sidebarSlideOut {
  0%   { transform: translateX(0); opacity: 1; filter: blur(0px); }
  100% { transform: translateX(84px); opacity: 0; filter: blur(10px); }
}

/* ===== HEADER: divider ===== */
.cabinet-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;

  position: relative;
  padding-bottom: 12px;
}

.cabinet-sidebar-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  height: 1px;
  background: rgba(255,255,255,0.10);
  box-shadow: 0 0.5px 0 rgba(0,0,0,0.35) inset;
  border-radius: 1px;
  opacity: 1;
}

.cabinet-sidebar-title {
  min-width: 0;
}

#cabinet-sidebar-close {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
}

/* body */
.cabinet-sidebar-body.sidebar-acc {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

/* =========================
   ACCORDION CARD
   ========================= */

.sidebar-acc-item {
  position: relative;
  z-index: 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  box-shadow:
    0 10px 22px rgba(0,0,0,0.28),
    0 0 0 0.5px rgba(255,255,255,0.02) inset;

  padding: 6px 12px;

  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 220ms cubic-bezier(0.16,1,0.3,1),
    transform 220ms cubic-bezier(0.16,1,0.3,1);
}

/* Hover ONLY when collapsed */
@media (hover: hover) and (pointer: fine) {
  .sidebar-acc-item:not(.is-open):hover {
    background: rgba(255,255,255,0.055);
    border-color: rgba(255,255,255,0.12);
    box-shadow:
      0 14px 28px rgba(0,0,0,0.34),
      0 0 0 0.5px rgba(255,255,255,0.03) inset;
    transform: translateY(-1px);
  }

  .sidebar-acc-item:not(.is-open):hover .sidebar-acc-btn-txt {
    color: rgba(245,245,247,0.99);
  }

  .sidebar-acc-item:not(.is-open):hover .sidebar-acc-btn-chev {
    opacity: 0.92;
    transform: translateY(0.5px);
  }
}

/* header button */
.sidebar-acc-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 4px 0;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  cursor: pointer;
  user-select: none;
  position: relative;
}

/* left group (icon + text) */
.sidebar-acc-btn-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* icon slot */
.sidebar-acc-btn-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.92;
  color: rgba(245,245,247,0.92);

  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;

  background-image: none;
}

.sidebar-acc-btn-ico--products { background-image: var(--menu-ico-products); }
.sidebar-acc-btn-ico--prices   { background-image: var(--menu-ico-prices); }
.sidebar-acc-btn-ico--stocks   { background-image: var(--menu-ico-stocks); }

.sidebar-acc-item[data-key="cashback"] .sidebar-acc-btn-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

/* title */
.sidebar-acc-btn-txt {
  font-size: 14px;
  font-weight: 600;
  color: rgba(245,245,247,0.96);
  line-height: 1.2;
  transition: color 180ms ease;
  min-width: 0;
}

/* divider under block title — only when open */
.sidebar-acc-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  height: 1px;
  background: rgba(255,255,255,0.10);
  box-shadow: 0 0.5px 0 rgba(0,0,0,0.35) inset;
  border-radius: 1px;

  opacity: 0;
  transition: opacity 180ms ease;
}

.sidebar-acc-item.is-open .sidebar-acc-btn::after {
  opacity: 1;
}

/* chevron */
.sidebar-acc-btn-chev {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  background-image: var(--caret-down);
  transition: transform 260ms cubic-bezier(0.16,1,0.3,1), opacity 180ms ease;
}

.sidebar-acc-item.is-open .sidebar-acc-btn-chev {
  background-image: var(--caret-up);
  transform: translateY(0.5px);
}

/* =========================
   ACCORDION OPEN
   ========================= */

.sidebar-acc-panel {
  overflow: hidden;

  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);

  pointer-events: none;
  padding-top: 0;

  transition:
    max-height 420ms cubic-bezier(0.16,1,0.3,1),
    opacity 220ms ease,
    transform 320ms cubic-bezier(0.16,1,0.3,1),
    padding-top 220ms ease;
}

.sidebar-acc-item.is-open .sidebar-acc-panel {
  max-height: 2000px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  padding-top: 10px;
}

.sidebar-acc-item.is-open {
  z-index: 1;
}

.sidebar-acc-item[data-key="api"].is-open {
  z-index: 4;
}

.sidebar-acc-item[data-key="api"].is-open .sidebar-acc-panel {
  max-height: min(70vh, 980px);
  overflow: visible;
  padding-right: 2px;
}

.sidebar-acc-item[data-key="prices"].is-open .sidebar-acc-panel,
.sidebar-acc-item[data-key="stocks"].is-open .sidebar-acc-panel {
  max-height: min(70vh, 980px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar-acc-item[data-key="prices"].is-open .sidebar-acc-panel::-webkit-scrollbar,
.sidebar-acc-item[data-key="stocks"].is-open .sidebar-acc-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sidebar-acc-item[data-key="api"].is-open .sidebar-acc-panel .sidebar-acc-panel-inner {
  overflow: visible;
}

.sidebar-acc-item[data-key="prices"].is-open .sidebar-acc-panel .sidebar-acc-panel-inner {
  max-height: none;
  overflow: visible;
  min-height: 0;
}

.sidebar-acc-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* placeholder content */
.sidebar-panel-muted {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(161,161,170,0.88);
}

.sidebar-panel-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(161,161,170,0.88);
}

/* sidebar text helpers */
.cabinet-sidebar .sidebar-panel-text.field-hint {
  display: block;
  white-space: normal;
  line-height: 1.35;
}

.cabinet-sidebar [data-cashback-percent-input]::-webkit-outer-spin-button,
.cabinet-sidebar [data-cashback-percent-input]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cabinet-sidebar [data-cashback-percent-input][type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.cabinet-sidebar .sidebar-panel-text.field-hint strong {
  color: rgba(245,245,247,0.96);
}

/* =========================
   HOVER / ACTIVE / FOCUS
   ========================= */

.sidebar-macos-row:hover .sidebar-macos-row-txt,
.sidebar-macos-row:hover .sidebar-macos-row-chev {
  color: rgba(161,161,170,0.95);
}

.sidebar-macos-row:active .sidebar-macos-row-txt,
.sidebar-macos-row:active .sidebar-macos-row-chev {
  color: rgba(161,161,170,0.85);
}

.sidebar-macos-row:focus-visible .sidebar-macos-row-txt,
.sidebar-macos-row:focus-visible .sidebar-macos-row-chev {
  color: rgba(161,161,170,1);
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cabinet-sidebar--open,
  .cabinet-sidebar--closing,
  .cabinet-sidebar--open .cabinet-sidebar-panel,
  .cabinet-sidebar--closing .cabinet-sidebar-panel {
    animation: none !important;
    transform: none !important;
    filter: none !important;
  }

  .sidebar-acc-item,
  .sidebar-acc-btn::after,
  .sidebar-acc-btn-chev,
  .sidebar-acc-panel,
  .sidebar-acc-btn-txt,
  .sidebar-macos-row-txt,
  .sidebar-macos-row-chev {
    transition: none !important;
    transform: none !important;
  }
}

/* API ready row */
.sidebar-ms-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}

.sidebar-ms-left {
  min-width: 0;
  display: flex;
  align-items: center;
}

.sidebar-ms-controls {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
