/* Rich Textarea Styles */
.rich-textarea {
  border: 1px solid var(--border-color, #E6E6E6);
  border-radius: 6px;
  background: var(--color-white, #ffffff);
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.rich-textarea:focus-within {
  border-color: var(--color-primary, #EF7310);
  box-shadow: 0 0 0 0.2rem rgba(239, 115, 16, 0.25);
}

.rich-toolbar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--light-gray, #F8F9FA);
  border-bottom: 1px solid var(--border-color, #E6E6E6);
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: var(--color-white, #ffffff);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color, #564B43);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.toolbar-btn:hover:not(:disabled) {
  background: var(--color-primary, #EF7310);
  color: var(--color-white, #ffffff);
  border-color: var(--color-primary, #EF7310);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.toolbar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color, #E6E6E6);
  margin: 0 8px;
}

.rich-editor {
  padding: 16px;
  outline: none;
  font-size: var(--font-regular, 16px);
  line-height: 1.6;
  color: var(--text-color, #564B43);
  font-family: var(--manrope-font, "Manrope"), sans-serif;
  overflow-y: auto;
  max-height: 400px;
}

.rich-editor:empty:before {
  content: attr(data-placeholder);
  color: #999;
  opacity: 0.7;
  pointer-events: none;
}

.rich-editor:focus {
  outline: none;
}

.rich-editor p {
  margin: 0 0 12px 0;
}

.rich-editor p:last-child {
  margin-bottom: 0;
}

.rich-editor ul, .rich-editor ol {
  margin: 0 0 12px 0;
  padding-left: 24px;
}

.rich-editor li {
  margin-bottom: 4px;
}

.rich-editor strong {
  font-weight: 700;
}

.rich-editor em {
  font-style: italic;
}

.rich-editor u {
  text-decoration: underline;
}

.rich-editor s {
  text-decoration: line-through;
}

.rich-editor h1, .rich-editor h2, .rich-editor h3 {
  margin: 16px 0 8px 0;
  font-weight: bold;
}

.rich-editor h1 {
  font-size: 2em;
}

.rich-editor h2 {
  font-size: 1.5em;
}

.rich-editor h3 {
  font-size: 1.25em;
}

.rich-editor a {
  color: var(--color-primary, #EF7310);
  text-decoration: underline;
}

.rich-editor a:hover {
  text-decoration: none;
}

/* Form integration styles */
.form-control.rich-textarea {
  padding: 0;
  height: auto;
}

.rich-textarea.is-invalid {
  border-color: var(--red-color, #dc3545);
}

.rich-textarea.is-invalid:focus-within {
  border-color: var(--red-color, #dc3545);
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* New toolbar elements */
.toolbar-select {
  height: 28px;
  border: 1px solid var(--border-color, #E6E6E6);
  border-radius: 4px;
  background: var(--color-white, #ffffff);
  font-size: 12px;
  padding: 0 8px;
  color: var(--text-color, #564B43);
  cursor: pointer;
  min-width: 85px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.toolbar-select:hover:not(:disabled) {
  border-color: var(--color-primary, #EF7310);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar-color {
  width: 28px !important;
  height: 28px !important;
  max-width: 50px;
  border: 1px solid var(--border-color, #E6E6E6);
  border-radius: 4px;
  cursor: pointer;
  background: var(--color-white, #ffffff);
  padding: 0 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  overflow: hidden;
}

.toolbar-color::-webkit-color-swatch-wrapper {
  padding: 0;
  border: none;
}

.toolbar-color::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
  margin: 2px;
}

.toolbar-color:hover:not(:disabled) {
  border-color: var(--color-primary, #EF7310);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.toolbar-color:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Link Modal */
.link-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.link-modal {
  background: var(--color-white, #ffffff);
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  min-width: 320px;
  max-width: 400px;
}

.link-modal h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-color, #564B43);
}

.link-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color, #E6E6E6);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
}

.link-input:focus {
  border-color: var(--color-primary, #EF7310);
  box-shadow: 0 0 0 0.2rem rgba(239, 115, 16, 0.25);
}

.link-modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.link-btn-apply, .link-btn-cancel {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.link-btn-apply {
  background: var(--color-primary, #EF7310);
  color: white;
}

.link-btn-apply:hover {
  background: var(--color-primary-dark, #d6640e);
}

.link-btn-cancel {
  background: var(--light-gray, #F1F5F9);
  color: var(--text-color, #564B43);
}

.link-btn-cancel:hover {
  background: var(--border-color, #E6E6E6);
}

/* Responsive styles */
@media (max-width: 768px) {
  .rich-toolbar {
    padding: 10px 12px;
    gap: 6px;
  }
  
  .toolbar-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .toolbar-select {
    height: 28px !important;
    font-size: 12px;
    min-width: 80px;
    padding: 0 6px !important;
  }
  
  .toolbar-color {
    width: 28px !important;
    height: 28px !important;
  }
  
  .toolbar-divider {
    height: 20px;
    margin: 0 6px;
  }
  
  .rich-editor {
    padding: 12px;
    font-size: var(--font-small, 14px);
  }
  
  .link-modal {
    margin: 16px;
    min-width: auto;
    max-width: calc(100vw - 32px);
  }
}