/* =====================================================================
   12. SIDEBAR DRAWER
   Left-side drawer for presentation history/navigation.
   ===================================================================== */

/* Backdrop scrim */
.m-sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 9499;
  background: transparent;
  pointer-events: none;
  transition: background 0.3s var(--ease);
}

.m-sidebar-scrim.active {
  background: rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

/* Drawer panel */
.m-sidebar-drawer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(300px, 85vw);
  z-index: 9500;
  background: var(--m-sidebar-bg);
  border-right: 1px solid var(--m-panel-border);
  box-shadow: var(--m-panel-shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease-spring);
  will-change: transform;
}

.m-sidebar-drawer.open {
  transform: translateX(0);
}

/* ── Collapsed strip (desktop only) ── */
.m-sidebar-strip {
  display: none; /* hidden on mobile, shown on desktop when collapsed */
}

/* ── Full sidebar content wrapper ── */
.m-sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

/* Sidebar header — clean, no border (matches desktop) */
.m-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 8px;
  padding-top: max(12px, calc(var(--m-safe-top) + 4px));
  flex-shrink: 0;
  white-space: nowrap;
}

.m-sidebar-header .logo-mark {
  width: 28px;
  height: 24px;
}

.m-sidebar-header .logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: -0.3px;
}

.m-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m-sidebar-close {
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--text-2);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.m-sidebar-close:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.m-sidebar-close:active {
  background: var(--bg-input-hover);
}

.m-sidebar-close svg {
  width: 20px;
  height: 20px;
}

/* Sidebar header actions — grey container like desktop */
.m-sidebar-header-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 2px;
}

.m-sidebar-header-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease;
}

.m-sidebar-header-btn:active {
  background: var(--bg-input);
  color: var(--text-0);
}

.m-sidebar-header-btn svg {
  width: 14px;
  height: 14px;
}

/* Desktop-only: collapse button hidden on mobile, + button hidden everywhere (redundant) */
#mNewPresHeaderBtn {
  display: none !important;
}
.m-sidebar-collapse-btn {
  display: none;
}

/* Sidebar resize handle (desktop only, hidden on mobile) */
.m-sidebar-resize-handle {
  display: none;
}

/* Folder more button */
.m-sidebar-folder-more {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: none;
  background: transparent;
  color: var(--text-3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
}

.m-sidebar-folder-more:active {
  background: var(--bg-input);
  opacity: 1;
}

.m-sidebar-folder-more svg {
  width: 14px;
  height: 14px;
}

/* New presentation button */
.m-sidebar-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 12px 16px;
  height: 44px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              color 0.15s var(--ease);
}

.m-sidebar-new-btn:hover {
  background: var(--bg-input-hover);
  border-color: var(--border-hover);
  color: var(--text-0);
}

.m-sidebar-new-btn:active {
  transform: scale(0.98);
}

.m-sidebar-new-btn svg {
  width: 16px;
  height: 16px;
}

/* Presentation list */
.m-sidebar-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  overscroll-behavior: contain;
}

.m-sidebar-list::-webkit-scrollbar {
  width: 3px;
}

.m-sidebar-list::-webkit-scrollbar-track {
  background: transparent;
}

.m-sidebar-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Individual presentation item */
.m-sidebar-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 32px;
  padding: 0;
  margin: 0 4px;
  cursor: pointer;
  border-left: none;
  border-radius: 6px;
  position: relative;
  transition: background 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

/* Sidebar item content wrapper */
.m-sidebar-item-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  position: relative;
  z-index: 1;
}

/* Three-dot menu button on sidebar items */
.m-sidebar-more-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: none;
  background: transparent;
  color: var(--text-3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
}

.m-sidebar-more-btn:active {
  background: var(--bg-input);
  opacity: 1;
}

.m-sidebar-more-btn svg {
  width: 16px;
  height: 16px;
}

.m-sidebar-item:active .m-sidebar-item-content {
  background: var(--bg-input-hover);
}

/* Active item */
.m-sidebar-item.active .m-sidebar-item-content {
  background: var(--accent-subtle);
}

.m-sidebar-item.active .m-sidebar-item-title {
  font-weight: 500;
  color: var(--text-0);
}

[data-theme="dark"] .m-sidebar-item.active .m-sidebar-item-content {
  background: var(--accent-subtle);
}

.m-sidebar-item-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.m-sidebar-item-icon svg {
  width: 16px;
  height: 16px;
}

.m-sidebar-item-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

/* Sidebar footer — clean, no border (matches desktop) */
.m-sidebar-footer {
  display: flex;
  align-items: center;
  padding: 8px;
  padding-bottom: max(8px, var(--m-safe-bottom));
  flex-shrink: 0;
  gap: 4px;
  margin-top: auto;
}

.m-sidebar-balance {
  font-size: 13px;
  font-weight: 425;
  color: var(--text-1);
  cursor: pointer;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.m-sidebar-balance:hover {
  color: var(--text-0);
  background: var(--bg-input);
  border-radius: 6px;
}

.m-sidebar-balance:active {
  color: var(--text-0);
}

/* Theme toggle — no push right, stays inline with other footer buttons */

.m-sidebar-footer-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border: none;
  background: none;
  color: var(--text-2);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.m-sidebar-footer-btn:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.m-sidebar-footer-btn:active {
  background: var(--bg-input-hover);
}

.m-sidebar-footer-btn svg {
  width: 18px;
  height: 18px;
}

/* Desktop-only elements */
.m-desktop-only { display: none; }
@media (min-width: 768px) {
  .m-desktop-only { display: inline-flex; }
}

/* ── Keyboard Shortcuts Modal ── */
.m-shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.m-shortcuts-overlay.open {
  opacity: 1;
  visibility: visible;
}
.m-shortcuts-card {
  background: var(--bg-solid);
  border: 1px solid var(--m-panel-border);
  border-radius: 16px;
  padding: 28px 32px 24px;
  min-width: 380px;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  position: relative;
}
.m-shortcuts-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 20px;
}
.m-shortcuts-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.m-shortcuts-close:hover {
  background: var(--m-msg-user-bg);
  color: var(--text-0);
}
.m-shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.m-shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.m-shortcut-label {
  font-size: 14px;
  color: var(--text-1);
}
.m-shortcut-keys {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.m-shortcut-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--m-msg-user-bg);
  border: 1px solid var(--m-panel-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  font-family: inherit;
  box-shadow: 0 1px 0 var(--m-panel-border);
}

/* ── Sidebar Sections ── */
.m-sidebar-section {
  margin-bottom: 0;
}

.m-sidebar-section + .m-sidebar-section {
  margin-top: 8px;
}

.m-sidebar-section-header {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 4px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.m-sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

.m-sidebar-section-badge {
  font-size: 10px;
  color: var(--text-2);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 8px;
}

.m-sidebar-section-chevron {
  width: 12px;
  height: 12px;
  margin-left: auto;
  color: var(--text-2);
  transition: transform 0.2s var(--ease);
}

.m-sidebar-section-chevron.collapsed {
  transform: rotate(-90deg);
}

.m-sidebar-section.collapsed .m-sidebar-section-chevron {
  transform: rotate(-90deg);
}

.m-sidebar-section-content.collapsed {
  display: none;
}

.m-sidebar-section.collapsed .m-sidebar-section-content {
  display: none;
}

.m-sidebar-section-empty {
  padding: 6px 12px 8px;
  font-size: 12px;
  color: var(--text-2);
  font-style: italic;
}


/* ── Date Groups ── */
.m-sidebar-date-group {
  /* Date group wrapper */
}

.m-sidebar-date-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  height: 24px;
}

.m-sidebar-date-header span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
}

.m-date-chevron {
  width: 8px;
  height: 8px;
  color: var(--text-2);
  transition: transform 0.2s var(--ease);
}

.m-date-chevron svg {
  width: 8px;
  height: 8px;
}

.m-sidebar-date-group.collapsed .m-date-chevron {
  transform: rotate(-90deg);
}

.m-sidebar-date-body {
  /* Items container inside date group */
}

.m-sidebar-date-group.collapsed .m-sidebar-date-body {
  display: none;
}

/* ── Admin: all users section ── */
[data-section="admin-users"] .m-sidebar-date-header {
  padding: 10px 12px 4px;
  height: auto;
  min-height: 20px;
}
[data-section="admin-users"] .m-sidebar-date-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  font-size: 11px;
  color: var(--accent, #6d9fff);
  font-weight: 600;
}
[data-section="admin-users"] .m-sidebar-item {
  padding: 4px 12px 4px 20px;
  min-height: 28px;
}
[data-section="admin-users"] .m-sidebar-item-title {
  font-size: 12px;
  line-height: 1.3;
}


/* ── Folders ── */
.m-sidebar-folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  margin: 0 4px;
  cursor: pointer;
  height: 32px;
  border-radius: 6px;
  transition: background 0.1s ease;
}

.m-sidebar-folder-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.m-sidebar-folder-header:active {
  background: var(--bg-input);
}

[data-theme="dark"] .m-sidebar-folder-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.m-sidebar-folder-icon {
  width: 16px;
  height: 16px;
  color: var(--text-2);
  flex-shrink: 0;
}

.m-sidebar-folder-name {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* chevron visibility controlled by _visual-toolbar.css */

.m-sidebar-folder-children {
  padding-left: 16px;
  overflow: hidden;
  transition: max-height 0.25s var(--ease), opacity 0.2s var(--ease);
  opacity: 1;
  position: relative;
}

/* Vertical indent guide line (VS Code style) */
.m-sidebar-folder-children::before {
  content: '';
  position: absolute;
  left: calc(4px + 14px);
  top: 0;
  bottom: 4px;
  width: 1px;
  background: var(--border);
  opacity: 0.5;
  z-index: 1;
  pointer-events: none;
}

/* Nested indent guide lines shift right */
.m-sidebar-folder-children .m-sidebar-folder-children::before {
  left: calc(4px + 12px);
}

.m-sidebar-folder-children.collapsed {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
}




/* ── Context Menu (Mobile Bottom Sheet) ── */
.m-context-backdrop,
.m-folder-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}

.m-context-backdrop.visible,
.m-folder-menu-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.m-context-menu {
  position: fixed;
  bottom: calc(8px + var(--m-safe-bottom));
  left: 8px;
  right: 8px;
  z-index: 9901;
  background: var(--m-sidebar-bg);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  transform: translateY(calc(100% + 8px + var(--m-safe-bottom)));
  transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.12),
    0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .m-context-menu {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.m-context-menu.visible {
  transform: translateY(0);
}

/* Drag handle — hidden (Apple action sheets have none) */
.m-context-menu::before {
  display: none;
}

/* Title — presentation name / folder name */
.m-context-title,
.m-context-menu-title {
  padding: 8px 20px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action items group */
.m-context-actions {
  padding: 4px 8px;
}

.m-context-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  font-size: 16px;
  font-weight: 450;
  letter-spacing: -0.01em;
  color: var(--text-0);
  background: transparent;
  border: none;
  border-radius: 12px;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease;
}

.m-context-menu-item:active {
  background: rgba(0, 0, 0, 0.06);
  transition: none;
}

[data-theme="dark"] .m-context-menu-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.m-context-menu-item .m-ctx-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  color: var(--text-1);
}

[data-theme="dark"] .m-context-menu-item .m-ctx-icon {
  background: rgba(255, 255, 255, 0.10);
}

.m-context-menu-item.danger .m-ctx-icon {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
}

[data-theme="dark"] .m-context-menu-item.danger .m-ctx-icon {
  background: rgba(239, 68, 68, 0.18);
}

.m-context-menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.m-context-menu-item.danger {
  color: #ef4444;
}

.m-context-separator {
  height: 1px;
  background: var(--m-panel-border);
  margin: 4px 20px;
}

.m-context-cancel {
  display: block;
  width: 100%;
  text-align: center;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-top: 1px solid var(--m-panel-border);
  margin-top: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.m-context-cancel:active {
  background: var(--bg-input);
}


