/* Story Builder - Tooltip and Context Menu Styles */

/* Tippy.js theme overrides */
.tippy-box[data-theme~='story-format'] {
  background: white;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 0;
}

.tippy-box[data-theme~='story-format'] .tippy-arrow {
  color: white;
}

.tippy-box[data-theme~='story-format'] .tippy-content {
  padding: 0;
}

/* Format menu structure */
.format-menu {
  padding: 12px;
  min-width: 200px;
}

.format-section {
  margin-bottom: 6px;
  padding-bottom: 0;
}

.format-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.format-section label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.format-section select,
.format-section input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: white;
  font-size: 14px;
  transition: all 0.2s ease;
}

.format-section select:focus,
.format-section input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.format-section > input[type="color"]:not(.text-color-square) {
  width: 100%;
  height: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-section > input[type="color"]:not(.text-color-square):hover {
  border-color: var(--accent);
}

/* Checkbox styling for context menus */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-label span {
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
}

/* New checkbox wrapper style for color controls */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-wrapper label {
  font-size: 14px;
  cursor: pointer;
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  color: #333;
}

/* Enhanced color controls */
.color-control-group {
  margin-bottom: 12px;
}

.color-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.color-controls input[type="color"] {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
}

.color-controls input[type="color"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.color-controls input[type="range"] {
  flex: 1;
  min-width: 80px;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  appearance: none;
  cursor: pointer;
}

.color-controls input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.color-controls input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.color-controls input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.opacity-value {
  flex: 0 0 auto;
  width: 40px;
  text-align: right;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
}

.color-controls:has(input:disabled) {
  opacity: 0.6;
}

/* Format buttons row */
.format-row {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

/* Compact row for text color + B/I buttons */
.format-row-compact {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Small square text color input */
.text-color-square {
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.text-color-square:hover {
  border-color: var(--accent);
}

.format-btn {
  flex: 1;
  padding: 6px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
}

/* Square buttons in compact row */
.format-row-compact .format-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  flex: 0 0 32px;
}

.format-btn:hover {
  background: var(--muted);
  border-color: var(--ink-2);
}

.format-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.format-btn[data-style="bold"] {
  font-weight: 700;
}

.format-btn[data-style="italic"] {
  font-style: italic;
}

.format-btn[data-style="underline"] {
  text-decoration: underline;
}

/* Alignment buttons */
.align-icon {
  width: 16px;
  height: 16px;
  filter: brightness(0) saturate(100%) invert(27%) sepia(8%) saturate(928%) hue-rotate(169deg) brightness(91%) contrast(86%);
}

.format-btn:hover .align-icon {
  filter: brightness(0) saturate(100%) invert(100%);
}

.format-btn.active .align-icon {
  filter: brightness(0) saturate(100%) invert(100%);
}

/* List type button icons */
.format-btn[data-listtype] img {
  width: 18px;
  height: 18px;
}

/* Layer order buttons */
.order-btn {
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

.order-btn:hover {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
}

/* Order icon styling */
.order-icon {
  width: 24px;
  height: 24px;
  filter: brightness(0) saturate(100%) invert(27%) sepia(8%) saturate(928%) hue-rotate(169deg) brightness(91%) contrast(86%);
}

.order-icon-flip {
  transform: rotate(180deg);
}

.order-btn:hover .order-icon {
  filter: brightness(0) saturate(100%) invert(100%);
}

/* Quick action tooltips */
.tippy-box[data-theme~='story-hint'] {
  background: rgba(0,0,0,.8);
  color: white;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
}

.tippy-box[data-theme~='story-hint'] .tippy-arrow {
  color: rgba(0,0,0,.8);
}

/* Error/warning tooltips */
.tippy-box[data-theme~='story-error'] {
  background: var(--accent);
  color: white;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}

.tippy-box[data-theme~='story-error'] .tippy-arrow {
  color: var(--accent);
}

/* Preview settings menu theme */
.tippy-box[data-theme~='preview-settings'] {
  background: white;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 0;
}

.tippy-box[data-theme~='preview-settings'] .tippy-arrow {
  color: white;
}

.tippy-box[data-theme~='preview-settings'] .tippy-content {
  padding: 0;
}

.preview-settings-menu {
  padding: 8px 0;
  min-width: 120px;
}

.preview-settings-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  transition: background-color 0.2s;
}

.preview-settings-item:hover {
  background: var(--muted);
}

/* Export format menu theme */
.tippy-box[data-theme~='export-format'] {
  background: white;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 0;
}

.tippy-box[data-theme~='export-format'] .tippy-arrow {
  color: white;
}

.tippy-box[data-theme~='export-format'] .tippy-content {
  padding: 0;
}

.export-format-menu {
  padding: 8px 0;
  min-width: 120px;
}

.export-format-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  transition: background-color 0.2s;
}

.export-format-item:hover {
  background: var(--muted);
}

/* Dropdown menus */
.dropdown-menu {
  background: white;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  padding: 4px;
  min-width: 150px;
}

.dropdown-item {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-item:hover {
  background: var(--muted);
}

.dropdown-item.active {
  background: var(--accent);
  color: white;
}

.dropdown-divider {
  height: 1px;
  background: var(--muted);
  margin: 4px 0;
}

/* Rich text selection menu */
.rich-text-menu {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.rich-text-menu .format-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 600;
  flex: 0 0 32px;
  padding: 0;
  min-height: 32px;
}

.rich-text-menu .format-btn:hover {
  background: #eef0f3;
  border-color: #64748b;
}

.rich-text-menu .format-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

.rich-text-menu .menu-divider {
  width: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* Color picker in rich text selection menu */
.rich-text-menu .selection-color-picker {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 0 32px;
  padding: 0;
  background: none;
}

.rich-text-menu .selection-color-picker:hover {
  border-color: #64748b;
}