/* Right sidebar — Timezone picker (like Diagramforce stencil) */

.md-timezones {
  width: var(--sidebar-tz-width);
  min-width: var(--sidebar-tz-width);
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal), min-width var(--transition-normal);
  flex-shrink: 0;
}

.md-timezones--hidden {
  width: 0;
  min-width: 0;
  border-left: none;
}

.md-sidebar__header {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.md-sidebar__header-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.md-sidebar__close-btn {
  margin-left: auto;
}

.md-sidebar__header .md-sidebar__search {
  flex: 1;
  min-width: 0;
}

.md-sidebar__search {
  width: 100%;
  padding: 6px var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.md-sidebar__search::placeholder {
  color: var(--text-muted);
}

.md-sidebar__search:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring-primary);
}

.md-sidebar__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--spacing-xs) 0;
}

/* Scrollbar styling moved to layout.css (shared rules) */

/* Category headers */
.md-sidebar__category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: default;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  user-select: none;
}

.md-sidebar__category-count {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 400;
  background: var(--bg-app);
  padding: 2px 7px;
  border-radius: 10px;
}

/* Timezone items */
.md-sidebar__items {
  padding: 2px var(--spacing-sm) var(--spacing-sm);
  list-style: none;
}

.md-tz-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 5px var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.md-tz-item:hover {
  background: var(--sidebar-item-hover);
}

.md-tz-item--disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.md-tz-item--disabled:hover {
  background: transparent;
}

.md-tz-item--added {
  opacity: 0.6;
  cursor: pointer;
}

.md-tz-item--added:hover {
  opacity: 1;
  background: rgba(218, 78, 85, 0.06);
}

.md-tz-item--added.md-tz-item--protected {
  opacity: 0.5;
  cursor: default;
}

.md-tz-item--added.md-tz-item--protected:hover {
  background: transparent;
}

.md-tz-item__offset {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.md-tz-item__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.md-tz-item__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.md-tz-item__icon svg {
  width: 16px;
  height: 16px;
}

.md-tz-item__icon--add {
  color: var(--brand-blue);
}

.md-tz-item:hover .md-tz-item__icon--add {
  color: var(--brand-blue);
}

.md-tz-item__icon--added {
  color: var(--text-muted);
  opacity: 0.5;
}

.md-tz-item__icon--remove {
  color: var(--brand-red);
  cursor: pointer;
}

.md-tz-item--added:hover .md-tz-item__icon--remove {
  color: var(--brand-red);
  opacity: 1;
}

.md-tz-item__icon--edit {
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition-fast);
  cursor: pointer;
}

.md-tz-item:hover .md-tz-item__icon--edit {
  opacity: 0.6;
}

.md-tz-item__icon--edit:hover {
  opacity: 1 !important;
  color: var(--color-primary);
}

.md-tz-item__rename-input {
  width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--color-primary);
  border-radius: 3px;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  outline: none;
}

.md-tz-item__label-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 1px;
}

.md-tz-item__alias {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.md-tz-item__added-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Max clocks warning in sidebar */
.md-sidebar__max-warning {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-xs);
  color: var(--brand-red);
  font-weight: 600;
  text-align: center;
}

/* Left sidebar — Scripts panel */

.md-scripts {
  width: 0;
  min-width: 0;
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal), min-width var(--transition-normal), border var(--transition-fast);
  flex-shrink: 0;
}

.md-scripts--visible {
  width: var(--sidebar-scripts-width);
  min-width: var(--sidebar-scripts-width);
  border-right: 1px solid var(--border-color);
}

.md-scripts__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.md-scripts__title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-primary);
}

.md-scripts__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--spacing-sm);
}

/* Scrollbar styling moved to layout.css (shared rules) */

/* Notice banner */
.md-scripts__notice {
  background-color: rgba(246, 179, 85, 0.15);
  border: 1px solid var(--brand-amber);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  line-height: 1.5;
}

.md-scripts__notice--info {
  background-color: rgba(29, 115, 201, 0.1);
  border-color: var(--brand-blue);
}

/* Stale-IANA divergence: stronger red so practitioners notice before copying. */
.md-scripts__notice--warning {
  background-color: rgba(217, 53, 53, 0.12);
  border-color: #d93535;
}

.md-scripts__notice-btn {
  display: inline-block;
  margin-top: var(--spacing-xs);
  background: transparent;
  border: 1px solid var(--brand-blue);
  color: var(--text-primary);
  padding: 4px 10px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: var(--font-size-xs);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.md-scripts__notice-btn:hover {
  background: var(--brand-blue);
  color: white;
}

/* Script section */
.md-script-section {
  margin-bottom: var(--spacing-md);
}

.md-script-section__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-xs);
}

.md-script-section__content {
  position: relative;
  background: var(--bg-app);
  border-radius: var(--border-radius-sm);
  padding: var(--spacing-sm);
  border-left: 3px solid var(--brand-blue);
}

.md-script-section:nth-child(2) .md-script-section__content,
.md-script-section--ampscript .md-script-section__content {
  border-left-color: var(--brand-amber);
}

.md-script-section:nth-child(3) .md-script-section__content,
.md-script-section--ssjs .md-script-section__content {
  border-left-color: var(--brand-red);
}

.md-script-section__code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Syntax highlighting tokens */
.sh-keyword { color: #0550AE; font-weight: 700; }
.sh-string { color: #0A3069; }
.sh-comment { color: #6E7781; font-style: italic; }
.sh-number { color: #0550AE; }
.sh-function { color: #8250DF; }
.sh-variable { color: #953800; }
.sh-type { color: #0550AE; }
.sh-identifier { color: #0550AE; }
.sh-delimiter { color: #CF222E; font-weight: 700; }

[data-theme="dark"] .sh-keyword { color: #79C0FF; }
[data-theme="dark"] .sh-string { color: #A5D6FF; }
[data-theme="dark"] .sh-comment { color: #8B949E; }
[data-theme="dark"] .sh-number { color: #79C0FF; }
[data-theme="dark"] .sh-function { color: #D2A8FF; }
[data-theme="dark"] .sh-variable { color: #FFA657; }
[data-theme="dark"] .sh-type { color: #79C0FF; }
[data-theme="dark"] .sh-identifier { color: #79C0FF; }
[data-theme="dark"] .sh-delimiter { color: #FF7B72; }

.md-script-section__copy {
  position: absolute;
  top: var(--spacing-xs);
  right: var(--spacing-xs);
  background-color: var(--color-primary);
  color: white;
  border: none;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-family);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.md-script-section__copy:hover {
  opacity: 0.88;
}

.md-script-section__copy--copied {
  background-color: var(--brand-red) !important;
}

/* Drag handle for mobile — minimum 44px touch target (WCAG 2.5.5) */
.md-drag-handle {
  display: none;
  align-items: center;
  justify-content: center;
  height: var(--touch-target-min);
  cursor: ns-resize;
  touch-action: none;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.md-drag-handle::after {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-muted);
  opacity: 0.5;
}

/* Mobile sidebars — bottom panels */
@media (max-width: 768px) {
  .md-timezones {
    width: 100%;
    min-width: 100%;
    height: 25vh;
    height: 25dvh;
    border-left: none;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
  }

  .md-timezones--hidden {
    height: 0;
    min-width: 0;
    border-top: none;
  }

  .md-timezones .md-drag-handle {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--sidebar-bg);
  }

  .md-timezones--hidden .md-drag-handle {
    display: none;
  }

  /* Touch-friendly items */
  .md-sidebar__search {
    padding: 10px var(--spacing-md);
    font-size: var(--font-size-md);
  }

  .md-tz-item {
    padding: 10px var(--spacing-sm);
    min-height: var(--touch-target-min);
    font-size: var(--font-size-md);
  }

  /* Touch-friendly icon targets (WCAG 2.5.5) */
  .md-tz-item__icon {
    width: 24px;
    height: 24px;
    padding: 4px;
  }

  .md-tz-item__icon--edit {
    opacity: 0.5;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .md-sidebar__category-header {
    padding: 10px var(--spacing-md);
    min-height: 40px;
  }

  /* Scripts sidebar mobile — collapse when not visible, show at bottom */
  .md-scripts {
    height: 0;
    overflow: hidden;
    order: 10;
  }

  .md-scripts--visible {
    width: 100%;
    min-width: 100%;
    height: 40vh;
    height: 40dvh;
    border-right: none;
    border-top: 1px solid var(--border-color);
    position: relative;
    overflow: visible;
  }

  .md-scripts--visible .md-drag-handle {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--sidebar-bg);
  }
}
