/* ==========================================================================
   Sandhu Group - Textfarbe, Textmarker, Schriftgröße & Feste Toolbar CSS
   ========================================================================== */

/* 1. Composer Toolbar Container (in .textBubble direkt über dem Textfeld) */
.sandhu-composer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px 6px;
  margin: -6px -12px 8px -12px;
  background-color: var(--background-secondary, #f8fafc);
  border-bottom: 1px solid var(--border-alt, #e2e8f0);
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  z-index: 10;
  position: relative;
}

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

/* Button Groups & Dividers */
.sandhu-tb-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  position: relative;
}

.sandhu-tb-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background-color: var(--border-alt, #cbd5e1);
  margin: 0 4px;
  opacity: 0.8;
}

[data-theme="dark"] .sandhu-tb-sep {
  background-color: #475569;
}

/* Base Toolbar Button */
.sandhu-tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 2px 6px;
  background: transparent;
  color: var(--text-normal, #334155);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

[data-theme="dark"] .sandhu-tb-btn {
  color: #e2e8f0;
}

.sandhu-tb-btn:hover {
  background-color: var(--background-modifier-hover, #e2e8f0);
  color: #0f172a;
}

[data-theme="dark"] .sandhu-tb-btn:hover {
  background-color: #334155;
  color: #ffffff;
}

.sandhu-tb-btn:active {
  transform: translateY(1px);
}

/* Specific button styles */
.sandhu-btn-clear {
  color: #dc2626 !important;
}

.sandhu-tb-icon-a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  position: relative;
}

.sandhu-color-bar {
  display: block;
  width: 13px;
  height: 3px;
  margin-top: 1px;
  border-radius: 1px;
}

.sandhu-tb-icon-marker {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 13px;
  line-height: 1;
  position: relative;
}

.sandhu-marker-bar {
  display: block;
  width: 14px;
  height: 3px;
  margin-top: 1px;
  border-radius: 1px;
}

.sandhu-tb-arrow {
  font-size: 9px;
  margin-left: 3px;
  opacity: 0.7;
}

/* Style & Font Size Select Dropdowns */
.sandhu-style-select,
.sandhu-fontsize-select {
  height: 26px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-normal, #334155);
  background-color: var(--background-primary, #ffffff);
  border: 1px solid var(--border-alt, #cbd5e1);
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}

[data-theme="dark"] .sandhu-style-select,
[data-theme="dark"] .sandhu-fontsize-select {
  background-color: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

.sandhu-style-select:hover,
.sandhu-fontsize-select:hover {
  border-color: #94a3b8;
}

/* 2. Color & Highlight Popovers in Toolbar */
.sandhu-tb-popover-wrapper {
  position: relative;
  display: inline-block;
}

.sandhu-tb-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1000;
  min-width: 180px;
  padding: 8px;
  background-color: var(--background-primary, #ffffff);
  border: 1px solid var(--border-alt, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .sandhu-tb-popover {
  background-color: #0f172a;
  border-color: #334155;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.sandhu-tb-popover.hide {
  display: none !important;
}

.sandhu-popover-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.sandhu-palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-items: center;
}

.sandhu-palette-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.sandhu-palette-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #3b82f6;
}

.sandhu-marker-remove {
  background-color: #f1f5f9 !important;
  color: #ef4444 !important;
  font-size: 12px;
  font-weight: 700;
  border-color: #cbd5e1 !important;
}

.sandhu-palette-custom {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px dashed #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: #f8fafc;
}

[data-theme="dark"] .sandhu-palette-custom {
  background-color: #1e293b;
  border-color: #64748b;
}

.sandhu-palette-custom input[type="color"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.sandhu-custom-picker-icon {
  font-size: 12px;
}

/* ==========================================================================
   3. Completely Disable Floating Selection Bubble Menu
   The user does not want any floating popup appearing when selecting text.
   ========================================================================== */
.js-bubbleMenu,
.bubble-menu-container,
.bubble-menu {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  transform: scale(0) !important;
  height: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
}

/* Hide "Nächstes in Übersicht" option from secondary action menu */
.js-secondaryActionLabel[data-type="closeNextInOverview"],
li.js-secondaryAction:has([data-type="closeNextInOverview"]) {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sandhu-composer-toolbar {
    padding: 4px;
    gap: 2px;
  }
  .sandhu-tb-btn {
    min-width: 24px;
    height: 24px;
    padding: 2px 4px;
    font-size: 12px;
  }
}

/* ==========================================================================
   4. Harmonized Typography across the entire Email Composer
   Ensures that text typed anywhere in the composer defaults to Arial 14px, #222222,
   while allowing explicit font-size or formatting overrides.
   ========================================================================== */
.richtext-content,
.richtext-content[contenteditable] {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 14px;
  line-height: 1.5 !important;
  color: #222222;
}

[data-theme="dark"] .richtext-content,
[data-theme="dark"] .richtext-content[contenteditable] {
  color: #f1f5f9;
}

/* Ensure all text nodes, divs, and paragraphs share the default typography */
.richtext-content > div:not(.signature):not([data-signature]):not([style*="font-size"]),
.richtext-content p:not([style*="font-size"]),
.richtext-content li:not([style*="font-size"]),
.richtext-content td:not([style*="font-size"]),
.richtext-content th:not([style*="font-size"]) {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 14px;
  line-height: 1.5 !important;
}

/* Explicit font-size styles on child elements take priority */
.richtext-content [style*="font-size"] {
  line-height: 1.5 !important;
}

/* Consistent, clean spacing for paragraphs and lines */
.richtext-content p {
  margin: 0 0 8px 0 !important;
  line-height: 1.5 !important;
}

.richtext-content div {
  line-height: 1.5 !important;
}

.richtext-content p:last-child {
  margin-bottom: 0 !important;
}

/* Empty lines (Enter key or <br>) */
.richtext-content p:empty,
.richtext-content div:empty,
.richtext-content p > br:only-child,
.richtext-content div > br:only-child {
  line-height: 1.5 !important;
}

/* Headings retain appropriate proportions */
.richtext-content h1 {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 20px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  margin: 12px 0 6px 0 !important;
}

.richtext-content h2 {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  margin: 10px 0 6px 0 !important;
}

.richtext-content h3 {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  margin: 8px 0 4px 0 !important;
}

/* Quoted text in replies */
.richtext-content blockquote {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  color: #475569 !important;
  border-left: 3px solid #cbd5e1 !important;
  padding: 4px 10px !important;
  margin: 8px 0 !important;
}

[data-theme="dark"] .richtext-content blockquote {
  color: #94a3b8 !important;
  border-left-color: #475569 !important;
}
