/* ==========================================================================
   Image Studio: Resize, Crop & Filter Styling
   ========================================================================== */

/* Embedded Image Wrapper inside document */
.doc-image-wrapper {
  position: relative;
  display: inline-block;
  user-select: none;
  box-sizing: border-box;
  margin: 10px 0;
  vertical-align: middle;
  transition: box-shadow 0.15s ease;
}

.doc-image-wrapper img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
}

/* Alignments */
.doc-image-wrapper.align-left {
  display: block;
  margin-right: auto;
  margin-left: 0;
}

.doc-image-wrapper.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.doc-image-wrapper.align-right {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

/* Text Wrapping Modes (Google Docs Style) */
.doc-image-wrapper.wrap-inline {
  display: inline-block;
  vertical-align: middle;
  clear: none;
  float: none;
}

.doc-image-wrapper.wrap-text {
  float: left;
  margin: 8px 16px 8px 0;
  clear: none;
}

.doc-image-wrapper.wrap-break {
  display: block;
  clear: both;
  margin: 14px auto;
}

.doc-image-wrapper.wrap-behind {
  position: relative;
  z-index: 0;
  opacity: 0.85;
}

.doc-image-wrapper.wrap-behind img {
  pointer-events: auto;
}

.doc-image-wrapper.wrap-front {
  position: relative;
  z-index: 10;
}

.doc-image-wrapper.doc-floating-image {
  position: absolute !important;
  margin: 0 !important;
  z-index: 35;
  cursor: move;
}

.doc-image-wrapper.moving {
  cursor: grabbing !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Selection outline & 8 resize handles (matching Slides orange theme) */
.img-selection-outline {
  display: none;
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 1.5px dashed #ea580c;
  border-radius: 1px;
  pointer-events: none;
}

.doc-image-wrapper.selected .img-selection-outline {
  display: block;
}

.img-handle {
  display: none;
  position: absolute;
  width: 9px;
  height: 9px;
  background: #ffffff;
  border: 1.5px solid #ea580c;
  border-radius: 1px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  z-index: 20;
  pointer-events: auto;
}

.doc-image-wrapper.selected .img-handle {
  display: block;
}

.img-handle.handle-nw { top: -8px; left: -8px; cursor: nwse-resize; }
.img-handle.handle-n  { top: -8px; left: calc(50% - 4.5px); cursor: ns-resize; }
.img-handle.handle-ne { top: -8px; right: -8px; cursor: nesw-resize; }
.img-handle.handle-e  { top: calc(50% - 4.5px); right: -8px; cursor: ew-resize; }
.img-handle.handle-se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.img-handle.handle-s  { bottom: -8px; left: calc(50% - 4.5px); cursor: ns-resize; }
.img-handle.handle-sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.img-handle.handle-w  { top: calc(50% - 4.5px); left: -8px; cursor: ew-resize; }

/* Rotator Handle (Circular Top Handle with orange stem line matching Slides) */
.img-rotator-stem {
  display: none;
  position: absolute;
  top: -26px;
  left: 50%;
  width: 1.5px;
  height: 26px;
  background-color: #ea580c;
  pointer-events: none;
  z-index: 20;
}

.doc-image-wrapper.selected .img-rotator-stem {
  display: block !important;
}

.img-handle.handle-rotator {
  display: none;
  position: absolute;
  top: -34px;
  left: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #ea580c;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, background-color 0.1s ease;
  z-index: 25;
  pointer-events: auto;
}

.doc-image-wrapper.selected .img-handle.handle-rotator {
  display: block !important;
}

.img-handle.handle-rotator:hover,
.img-handle.handle-rotator.active {
  background-color: #ffffff;
  border-color: #ea580c;
  transform: scale(1.25);
}

.img-handle.handle-rotator:active {
  cursor: grabbing;
}

[data-theme="dark"] .img-selection-outline {
  border-color: #f97316;
}

[data-theme="dark"] .img-handle {
  border-color: #f97316;
}

[data-theme="dark"] .img-rotator-stem {
  background-color: #f97316;
}

[data-theme="dark"] .img-handle.handle-rotator {
  border-color: #f97316;
}

[data-theme="dark"] .img-handle.handle-rotator:hover,
[data-theme="dark"] .img-handle.handle-rotator.active {
  border-color: #f97316;
}

/* Move overlay on wrapper body */
.img-move-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  cursor: grab;
  z-index: 5;
}

.img-move-overlay:active {
  cursor: grabbing;
}

.doc-image-wrapper.selected .img-move-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Move badge in center of image */
.img-move-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.img-move-overlay:hover .img-move-badge {
  opacity: 1;
  transform: scale(1.05);
}

/* Live Rotation Degree Tooltip */
.img-rotate-tooltip {
  position: absolute;
  top: -54px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 25;
  display: none;
  animation: fadeIn 0.1s ease-out;
}

.img-rotate-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -4px;
  border-width: 4px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

/* ==========================================================================
   Image Floating Action Toolbar
   ========================================================================== */
.image-floating-toolbar {
  position: fixed;
  z-index: 1045;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 10px 22px -4px rgba(0,0,0,0.2), 0 4px 6px -2px rgba(0,0,0,0.08);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  animation: imgToolbarPop 0.14s ease-out;
  max-width: calc(100vw - 340px);
  overflow: visible;
}

@keyframes imgToolbarPop {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.img-tb-handle {
  color: var(--text-muted, #94a3b8);
  font-size: 0.75rem;
  padding: 0 2px;
  cursor: grab;
}

.img-tb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main, #334155);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}

.img-tb-btn:hover {
  background: var(--bg-hover, #f1f5f9);
  color: var(--primary-color, #2563eb);
}

.img-tb-btn.btn-danger {
  color: #ef4444;
}

.img-tb-btn.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.img-tb-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color, #e2e8f0);
  margin: 0 2px;
}

.img-tb-angle-indicator {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary-color, #2563eb);
  background: var(--bg-hover, #eff6ff);
  border: 1px solid #bfdbfe;
  padding: 2px 6px;
  border-radius: 4px;
  user-select: none;
}

/* ==========================================================================
   Interactive Crop Dialog Styles
   ========================================================================== */
.crop-toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  background: var(--bg-toolbar, #f8fafc);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color, #e2e8f0);
}

.crop-tb-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}

.crop-ratio-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.crop-ratio-btn {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-main, #334155);
  cursor: pointer;
  transition: all 0.12s ease;
}

.crop-ratio-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.crop-ratio-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.crop-stage-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border-radius: 8px;
  padding: 16px;
  min-height: 380px;
  max-height: 520px;
  overflow: hidden;
  user-select: none;
}

.crop-canvas-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#crop-stage-img {
  max-width: 580px;
  max-height: 440px;
  display: block;
}

/* Draggable & Resizable Crop Mask */
.crop-box-overlay {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  box-sizing: border-box;
}

/* Rule of Thirds grid lines */
.crop-grid-rule-h1, .crop-grid-rule-h2 {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.crop-grid-rule-h1 { top: 33.33%; }
.crop-grid-rule-h2 { top: 66.66%; }

.crop-grid-rule-v1, .crop-grid-rule-v2 {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.crop-grid-rule-v1 { left: 33.33%; }
.crop-grid-rule-v2 { left: 66.66%; }

.crop-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #ffffff;
  border: 2px solid #0284c7;
  border-radius: 2px;
  z-index: 30;
}

.crop-handle.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.crop-handle.handle-n  { top: -6px; left: calc(50% - 5.5px); cursor: ns-resize; }
.crop-handle.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.crop-handle.handle-e  { top: calc(50% - 5.5px); right: -6px; cursor: ew-resize; }
.crop-handle.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.crop-handle.handle-s  { bottom: -6px; left: calc(50% - 5.5px); cursor: ns-resize; }
.crop-handle.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.crop-handle.handle-w  { top: calc(50% - 5.5px); left: -6px; cursor: ew-resize; }

/* ==========================================================================
   Filter Studio Dialog Styles
   ========================================================================== */
.filters-modal-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  min-height: 380px;
}

@media (max-width: 720px) {
  .filters-modal-grid {
    grid-template-columns: 1fr;
  }
}

.filters-preview-box {
  background: #0f172a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

#filter-stage-img {
  max-width: 100%;
  max-height: 360px;
  display: block;
  border-radius: 4px;
  transition: filter 0.15s ease;
}

.filters-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
  max-height: 400px;
}

.filters-panel-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #64748b);
  border-bottom: 1px solid var(--border-color, #f1f5f9);
  padding-bottom: 4px;
}

.filters-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-preset-chip {
  background: var(--bg-toolbar, #f8fafc);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-main, #334155);
  cursor: pointer;
  transition: all 0.12s ease;
}

.filter-preset-chip:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.filter-preset-chip.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.filter-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-slider-group .slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-main, #334155);
}

.filter-range-input {
  width: 100%;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ==========================================================================
   Google Docs-Style Image Options Sidebar
   ========================================================================== */
.image-options-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-surface, #ffffff);
  border-left: 1px solid var(--border-color, #e2e8f0);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.image-options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.image-options-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main, #0f172a);
}

.image-options-close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.image-options-close-btn:hover {
  background: var(--hover-bg, #f1f5f9);
  color: var(--text-main, #0f172a);
}

.image-options-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Sections */
.img-opt-section {
  background: var(--bg-surface, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 12px 14px;
}

.img-opt-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main, #1e293b);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.img-opt-section-title i {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
  transition: transform 0.15s ease;
}

/* 2x2 Numeric Inputs Grid */
.img-opt-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.img-opt-input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.img-opt-input-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}

.img-opt-spinbox {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 4px;
  background: var(--bg-surface, #ffffff);
  padding: 2px 6px;
  height: 28px;
}

.img-opt-spinbox input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main, #1e293b);
  outline: none;
  padding: 0;
}

.img-opt-spinbox span.unit {
  font-size: 0.74rem;
  color: var(--text-muted, #64748b);
  margin-left: 2px;
}

.img-opt-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main, #334155);
  margin-top: 6px;
  cursor: pointer;
}

.img-opt-checkbox-row input {
  accent-color: #2563eb;
  cursor: pointer;
}

/* Rotate Row */
.img-opt-rotate-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.img-opt-rotate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--bg-surface, #ffffff);
  color: var(--text-main, #334155);
  cursor: pointer;
  transition: all 0.12s ease;
}

.img-opt-rotate-btn:hover {
  background: var(--hover-bg, #f1f5f9);
  color: #2563eb;
  border-color: #93c5fd;
}

/* Text Wrapping Mode Cards */
.img-opt-wrap-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.img-opt-wrap-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 4px;
  border-radius: 6px;
  border: 1.5px solid var(--border-color, #e2e8f0);
  background: var(--bg-surface, #ffffff);
  cursor: pointer;
  transition: all 0.12s ease;
}

.img-opt-wrap-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.img-opt-wrap-card.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

.img-opt-wrap-icon {
  width: 44px;
  height: 38px;
  background: #f1f5f9;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
}

.img-opt-wrap-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-main, #334155);
  line-height: 1.2;
}

/* Recolor Dropdown & Swatches Popover */
.img-opt-recolor-selector {
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--bg-surface, #ffffff);
  color: var(--text-main, #1e293b);
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.img-opt-recolor-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.img-recolor-thumb-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}

.img-recolor-thumb-card:hover {
  background: var(--hover-bg, #f1f5f9);
  border-color: #93c5fd;
}

.img-recolor-thumb-card.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.img-recolor-preview-box {
  width: 58px;
  height: 58px;
  border-radius: 4px;
  overflow: hidden;
  background: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-recolor-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-recolor-thumb-name {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-main, #475569);
  margin-top: 3px;
  text-align: center;
}

/* Slider rows */
.img-opt-slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.img-opt-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-main, #334155);
}

.img-opt-slider-val-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  width: 44px;
  justify-content: flex-end;
}

/* Reset button in adjustments */
.img-opt-btn-reset {
  margin-top: 12px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 18px;
  padding: 4px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main, #334155);
  cursor: pointer;
  transition: all 0.12s ease;
}

.img-opt-btn-reset:hover {
  background: var(--hover-bg, #f1f5f9);
  border-color: #94a3b8;
}

/* Alt text box */
.img-opt-alt-textarea {
  width: 100%;
  height: 64px;
  font-size: 0.78rem;
  padding: 6px 8px;
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  resize: vertical;
  background: var(--bg-surface, #ffffff);
  color: var(--text-main, #0f172a);
  box-sizing: border-box;
}

/* Dark mode styling */
[data-theme="dark"] .image-options-sidebar {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .img-opt-section {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .img-opt-spinbox,
[data-theme="dark"] .img-opt-wrap-card,
[data-theme="dark"] .img-opt-recolor-selector,
[data-theme="dark"] .img-opt-recolor-menu,
[data-theme="dark"] .img-opt-rotate-btn,
[data-theme="dark"] .img-opt-btn-reset,
[data-theme="dark"] .img-opt-alt-textarea {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .img-opt-wrap-card.active {
  background: #1e3a8a;
  border-color: #3b82f6;
}

[data-theme="dark"] .image-floating-toolbar {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .filters-controls-panel {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .filter-preset-chip {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .crop-toolbar-row {
  background: #0f172a;
  border-color: #334155;
}

/* ==========================================================================
   Mobile & Small Screen Adaptation for Image Studio
   ========================================================================== */
@media screen and (max-width: 600px) {
  .image-options-sidebar {
    width: 100vw;
    max-width: 100vw;
    z-index: 2000;
  }

  .img-opt-grid-2x2 {
    grid-template-columns: 1fr 1fr;
  }

  .img-opt-recolor-menu {
    width: 250px;
  }
}


/* ==========================================================================
   MS Office Picture Styles Gallery (28 Presets)
   ========================================================================== */
.ms-picture-styles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 6px 2px;
}

.ms-picture-styles-grid.ms-grid-7col {
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.ms-pic-styles-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 470px;
  max-width: 92vw;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 10px;
  box-shadow: 0 20px 30px -5px rgba(0, 0, 0, 0.22), 0 8px 12px -4px rgba(0, 0, 0, 0.1);
  padding: 12px;
  z-index: 100050;
}

.ms-pic-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.ms-pic-clear-btn {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.ms-pic-clear-btn:hover {
  background: #eff6ff;
}

.ms-pic-style-thumb {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  min-height: 54px;
}

.ms-pic-style-thumb:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.ms-pic-style-thumb.active {
  background: rgba(37, 99, 235, 0.14);
  border-color: #2563eb;
}

.ms-pic-thumb-frame {
  width: 48px;
  height: 36px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   28 Picture Style Definitions (Applied to both thumbnails & document images)
   -------------------------------------------------------------------------- */

/* 1. Simple Frame, White */
.pic-style-simple-frame-white {
  border: 4px solid #ffffff !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28) !important;
  border-radius: 0px !important;
}

/* 2. Beveled Matte, White */
.pic-style-beveled-matte-white {
  border: 6px solid #ffffff !important;
  outline: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 0 3px rgba(0,0,0,0.2), 0 3px 6px rgba(0, 0, 0, 0.22) !important;
  border-radius: 0px !important;
}

/* 3. Metal Frame */
.pic-style-metal-frame {
  border: 6px solid #cbd5e1 !important;
  outline: 1px solid #64748b !important;
  box-shadow: inset 0 1px 2px #ffffff, 0 3px 7px rgba(0, 0, 0, 0.3) !important;
  border-radius: 0px !important;
}

/* 4. Drop Shadow Rectangle */
.pic-style-drop-shadow-rect {
  border: none !important;
  box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.42) !important;
  border-radius: 0px !important;
}

/* 5. Reflected Rounded Rectangle */
.pic-style-reflected-rounded-rect {
  border: none !important;
  border-radius: 10px !important;
  -webkit-box-reflect: below 2px linear-gradient(transparent 55%, rgba(255, 255, 255, 0.45));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18) !important;
}

/* 6. Soft Edge Rectangle */
.pic-style-soft-edge-rect {
  border: none !important;
  border-radius: 6px !important;
  -webkit-mask-image: radial-gradient(ellipse 90% 90% at 50% 50%, black 60%, transparent 100%);
  mask-image: radial-gradient(ellipse 90% 90% at 50% 50%, black 60%, transparent 100%);
}

/* 7. Double Frame, Black */
.pic-style-double-frame-black {
  border: 6px double #0f172a !important;
  background-color: #ffffff !important;
  padding: 2px !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3) !important;
}

/* 8. Thick Matte, Black */
.pic-style-thick-matte-black {
  border: 10px solid #0f172a !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.38) !important;
}

/* 9. Simple Frame, Black */
.pic-style-simple-frame-black {
  border: 4px solid #0f172a !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.32) !important;
}

/* 10. Beveled Oval, Black */
.pic-style-beveled-oval-black {
  border: 4px solid #0f172a !important;
  border-radius: 50% !important;
  box-shadow: 0 10px 14px -4px rgba(0, 0, 0, 0.42), inset 0 2px 4px rgba(255, 255, 255, 0.35) !important;
}

/* 11. Compound Frame, Black */
.pic-style-compound-frame-black {
  border: 3px solid #0f172a !important;
  outline: 3px solid #0f172a !important;
  outline-offset: 2px !important;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3) !important;
}

/* 12. Moderate Frame, Black */
.pic-style-moderate-frame-black {
  border: 6px solid #1e293b !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), inset 0 0 4px rgba(0,0,0,0.4) !important;
}

/* 13. Center Shadow Rectangle */
.pic-style-center-shadow-rect {
  border: none !important;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.55) !important;
}

/* 14. Snip Diagonal Corner, White */
.pic-style-snip-diag-white {
  border: 4px solid #ffffff !important;
  border-radius: 12px 0 12px 0 !important;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.3) !important;
}

/* 15. Snipped Corner, White Matte */
.pic-style-snip-diag-matte {
  border: 5px solid #ffffff !important;
  clip-path: polygon(0 0, 86% 0, 100% 14%, 100% 100%, 14% 100%, 0 86%);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

/* 16. Moderate Frame, White */
.pic-style-moderate-frame-white {
  border: 8px solid #ffffff !important;
  outline: 1px solid #cbd5e1 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

/* 17. Rotated, White */
.pic-style-rotated-white {
  border: 5px solid #ffffff !important;
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.35) !important;
  transform: rotate(-3.5deg);
}

/* 18. Perspective Shadow, White */
.pic-style-perspective-shadow-white {
  border: 4px solid #ffffff !important;
  box-shadow: -8px 8px 12px -2px rgba(0, 0, 0, 0.38) !important;
}

/* 19. Relaxed Perspective, White */
.pic-style-relaxed-perspective-white {
  border: 5px solid #ffffff !important;
  transform: perspective(500px) rotateX(18deg);
  box-shadow: 0 10px 16px -4px rgba(0, 0, 0, 0.38) !important;
}

/* 20. Soft Edge Oval */
.pic-style-soft-edge-oval {
  border: none !important;
  border-radius: 50% !important;
  -webkit-mask-image: radial-gradient(circle, black 52%, transparent 98%);
  mask-image: radial-gradient(circle, black 52%, transparent 98%);
}

/* 21. Beveled Rectangle */
.pic-style-beveled-rect {
  border-radius: 8px !important;
  border: 2px solid rgba(255, 255, 255, 0.65) !important;
  box-shadow: 
    inset 2px 2px 4px rgba(255, 255, 255, 0.6),
    inset -2px -2px 5px rgba(0, 0, 0, 0.35),
    0 5px 12px rgba(0, 0, 0, 0.32) !important;
}

/* 22. Bevel Perspective */
.pic-style-bevel-perspective {
  border-radius: 8px !important;
  border: 2px solid rgba(255, 255, 255, 0.5) !important;
  transform: perspective(500px) rotateY(-14deg) rotateX(6deg);
  box-shadow: 6px 8px 16px rgba(0, 0, 0, 0.4) !important;
}

/* 23. Reflected Perspective Right */
.pic-style-reflected-perspective-right {
  border: none !important;
  transform: perspective(500px) rotateY(-18deg);
  -webkit-box-reflect: below 2px linear-gradient(transparent 60%, rgba(255, 255, 255, 0.4));
  box-shadow: 4px 6px 14px rgba(0, 0, 0, 0.3) !important;
}

/* 24. Perspective Left, White */
.pic-style-perspective-left-white {
  border: 5px solid #ffffff !important;
  transform: perspective(500px) rotateY(16deg);
  box-shadow: -5px 6px 14px rgba(0, 0, 0, 0.35) !important;
}

/* 25. Reflected Beveled, Black */
.pic-style-reflected-beveled-black {
  border: 4px solid #334155 !important;
  border-radius: 8px !important;
  -webkit-box-reflect: below 2px linear-gradient(transparent 55%, rgba(255, 255, 255, 0.4));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35) !important;
}

/* 26. Reflected Beveled, White */
.pic-style-reflected-beveled-white {
  border: 4px solid #ffffff !important;
  outline: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  -webkit-box-reflect: below 2px linear-gradient(transparent 55%, rgba(255, 255, 255, 0.4));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25) !important;
}

/* 27. Metal Rounded Rectangle */
.pic-style-metal-rounded-rect {
  border: 5px solid #cbd5e1 !important;
  outline: 1px solid #94a3b8 !important;
  border-radius: 10px !important;
  box-shadow: inset 0 1px 3px #ffffff, 0 4px 10px rgba(0, 0, 0, 0.32) !important;
}

/* 28. Metal Oval */
.pic-style-metal-oval {
  border: 5px solid #cbd5e1 !important;
  outline: 1px solid #94a3b8 !important;
  border-radius: 50% !important;
  box-shadow: inset 0 2px 4px #ffffff, 0 5px 12px rgba(0, 0, 0, 0.35) !important;
}

/* Dark Mode Support for Picture Styles Popover */
[data-theme="dark"] .ms-pic-styles-popover {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .ms-pic-popover-header {
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .ms-pic-style-thumb:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: #60a5fa;
}

/* ==========================================================================
   MS Office Artistic Effects Gallery (23 Presets in 5x5 Grid + Adjust Tools)
   ========================================================================== */
.ms-artistic-effects-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 390px;
  max-width: 92vw;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 18px 28px -5px rgba(15, 23, 42, 0.24), 0 8px 12px -4px rgba(15, 23, 42, 0.1);
  padding: 10px 10px 6px 10px;
  z-index: 100060;
}

.ms-artistic-effects-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.ms-artistic-effects-grid.ms-artistic-sidebar-grid {
  gap: 5px;
}

.ms-artistic-thumb {
  background: #ffffff;
  border: 1.5px solid transparent;
  border-radius: 4px;
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  transition: all 0.14s ease;
  position: relative;
}

.ms-artistic-sidebar-grid .ms-artistic-thumb {
  min-height: 46px;
  padding: 3px 2px;
}

.ms-artistic-thumb:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
}

.ms-artistic-thumb.active {
  background: #f1f5f9;
  border: 1.5px solid #64748b;
  box-shadow: inset 0 0 0 1px #cbd5e1;
}

.ms-artistic-thumb-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.ms-artistic-popover-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.ms-artistic-options-link {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main, #1e293b);
  display: flex;
  align-items: center;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.12s ease;
}

.ms-artistic-options-link:hover {
  background: var(--bg-toolbar, #f1f5f9);
}

/* MS Office Adjust Stack Mini Menus (Change Picture / Reset Picture) */
.img-tb-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.ms-img-mini-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 195px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.22), 0 4px 10px rgba(15, 23, 42, 0.08);
  padding: 5px;
  z-index: 100070;
  white-space: nowrap;
}

.ms-img-mini-item {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 0.78rem;
  color: var(--text-main, #1e293b);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.ms-img-mini-item:hover {
  background: var(--bg-toolbar, #f1f5f9);
  color: #2563eb;
}

[data-theme="dark"] .ms-artistic-effects-popover,
[data-theme="dark"] .ms-img-mini-menu {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .ms-artistic-thumb {
  background: #0f172a;
}

[data-theme="dark"] .ms-artistic-thumb:hover {
  background: #1e293b;
  border-color: #60a5fa;
}

[data-theme="dark"] .ms-artistic-thumb.active {
  background: #1e293b;
  border-color: #93c5fd;
}

[data-theme="dark"] .ms-artistic-options-link,
[data-theme="dark"] .ms-img-mini-item {
  color: #e2e8f0;
}

[data-theme="dark"] .ms-artistic-options-link:hover,
[data-theme="dark"] .ms-img-mini-item:hover {
  background: #334155;
}

/* Slides Element Image Wrapper adjustments */
.slide-element .doc-image-wrapper {
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  position: relative !important;
  overflow: visible !important;
}

.slide-element .doc-image-wrapper img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  pointer-events: none !important;
}

/* Modals z-index elevation above sidebar */
#image-crop-modal,
#image-filters-modal,
#ms-compress-pictures-modal {
  z-index: 100050 !important;
}
