/* Modal close (X) button */
.rte-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #888;
   cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}
.rte-modal-close:hover {
    color: #c00;
}
/* Box Layout Styles */
.rte-box-row {
    display: flex;
}

.rte-box {
    min-width: 180px;
    min-height: 80px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
    word-break: break-word;
    color: #333;
}


.rte-box-content {
    min-height: 40px;
    resize: none;
    overflow: visible;
    word-break: break-word;
    padding: 1.2rem 1.2rem;
    background-color: rgb(213, 213, 170);
    border-color: rgb(147, 0, 0);
    border-style: solid;
    border-width: 2px;
    border-radius: 10px;
    color: #111;
}

.rte-box-content[contenteditable="true"] {
    outline: none;
}

.rte-title-box {

    font-size: 1.3em;
    font-weight: bold;
    text-align: center;
    margin: 1.5rem 0;
    color: #111;
}

@media (max-width: 768px) {
    .rte-box-row {
        flex-direction: column;
        gap: 0.75rem;
    }
/*.rte-box {
       background-color: #fff;
        min-width: 0;
        width: 100%;
        margin: 0.5rem 0;}*/
}
/* Rich Text Editor Styles */


.rte-wrapper {
    border: 1px solid #a6a6a6;
    border-radius: 0;
    background: #fff;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
}

.rte-toolbar {
    background: linear-gradient(to bottom, #ffffff 0%, #f1f3f5 100%);
    border-bottom: 1px solid #d1d1d1;
    padding: 0.4rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    align-items: center;
}

.rte-toolbar button {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 2px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
    min-width: 32px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: #333;
}

.rte-toolbar button svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: currentColor;
    align-self: flex-end;
    margin-bottom: 0;
    /* Fix for bottom alignment */
}


.rte-toolbar button:hover {
    background: rgba(0, 120, 215, 0.1);
    border-color: rgba(0, 120, 215, 0.3);
}

.rte-toolbar button.active {
    background: rgba(0, 120, 215, 0.2);
    border-color: rgba(0, 120, 215, 0.5);
    color: #0078d7;
}

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

.rte-toolbar button[data-cmd="bold"] {
    font-weight: bold;
}

.rte-toolbar button[data-cmd="italic"] {
    font-style: italic;
}

.rte-toolbar button[data-cmd="underline"] {
    text-decoration: underline;
}

.rte-toolbar button[data-cmd="justifyLeft"] img,
.rte-toolbar button[data-cmd="justifyCenter"] img,
.rte-toolbar button[data-cmd="justifyRight"] img,
.rte-toolbar button[data-cmd="justifyFull"] img {
    display: block;
    margin: 0 auto;
}

.rte-font-size-select {
    background: white;
    border: 1px solid #d1d1d1;
    border-radius: 2px;
    padding: 0.4rem 0.2rem;
    font-size: 0.85rem;
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    cursor: pointer;
    height: 28px;
    width: 60px !important;
    max-width: 60px;
    min-width: 60px;
    color: #333;
}

.rte-font-size-select:hover {
    background: rgba(0, 120, 215, 0.1);
    border-color: rgba(0, 120, 215, 0.3);
}

.rte-font-size-select:focus {
    outline: none;
    border-color: #0078d7;
}

.rte-heading-select {
    background: #f1f3f5;
    border: 1px solid #d1d1d1;
    border-radius: 2px;
    padding: 0.4rem 0.3rem;
    font-size: 0.85rem;
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    cursor: pointer;
    height: 28px;
    width: 95px !important;
    max-width: 95px;
    min-width: 95px;
    color: #333;
}

.rte-heading-select:hover {
    background: rgba(0, 120, 215, 0.1);
    border-color: rgba(0, 120, 215, 0.3);
}

.rte-heading-select:focus {
    outline: none;
    border-color: #0078d7;
}

.rte-font-family-select {
    background: white;
    border: 1px solid #d1d1d1;
    border-radius: 2px;
    padding: 0.4rem 0.3rem;
    font-size: 0.85rem;
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    cursor: pointer;
    height: 28px;
    width: 120px !important;
    max-width: 120px;
    min-width: 120px;
    color: #333;
}

.rte-font-family-select:hover {
    background: rgba(0, 120, 215, 0.1);
    border-color: rgba(0, 120, 215, 0.3);
}

.rte-font-family-select:focus {
    outline: none;
    border-color: #0078d7;
}

.rte-separator {
    width: 1px;
    background: #d1d1d1;
    margin: 0 0.3rem;
    height: 20px;
    align-self: center;
}

.rte-group {
    display: flex;
    gap: 0.25rem;
}

.rte-editor {
    min-height: 500px;
    padding: 2.5rem 3rem;
    outline: none;
    line-height: 1.5;
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    font-size: 11pt;
    background: #deb887;
    color: #333;
    /*overflow: visible;*/
}

.rte-editor:focus {
    background: #deb887;
}

/* Content Formatting */
.rte-editor h1 {
    font-size: 2rem;
    margin: 1rem 0 0.5rem;
    color: #333;
}

.rte-editor h2 {
    font-size: 1.5rem;
    margin: 1rem 0 0.5rem;
    color: #333;
}

.rte-editor h3 {
    font-size: 1.25rem;
    margin: 1rem 0 0.5rem;
    color: #333;
}

.rte-editor p {
    margin: 0.5rem 0;
}

.rte-editor ul,
.rte-editor ol {
    margin: 0.5rem 0;
    padding-left: 2rem;
}

.rte-editor li {
    margin: 0.25rem 0;
}

.rte-editor blockquote {
    border-left: 4px solid #4a4a9e;
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    font-style: italic;
}

.rte-editor a {
    color: #4a4a9e;
    text-decoration: underline;
}

.rte-editor img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem 0;
}

.rte-editor img.draggable-image {
    position: absolute;
    cursor: move;
    user-select: none;
    transition: all 0.2s;
    border: 1px solid transparent;
    z-index: 100;
}

.rte-editor img.draggable-image:hover,
.rte-editor img.draggable-image.selected {
    border: 1px solid #0078d7;
    box-shadow: 0 0 0 1px #0078d7;
}

.rte-editor img.draggable-image.selected::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 1px solid #0078d7;
    right: -4px;
    bottom: -4px;
    cursor: nwse-resize;
}

.rte-editor img.draggable-image.selected::before {
    content: '✕';
    position: absolute;
    top: -20px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #c00;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    z-index: 1001;
}

.rte-editor .draggable-textbox {
    position: absolute;
    user-select: text;
    box-sizing: border-box;
    border-color: rgb(147, 0, 0);
    border-style: solid;
    border-width: 1px;
    border-radius: 10px;
    z-index: 100;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: normal;
    min-height: 30px;
    height: auto;
    max-width: 50vw;
    overflow: visible;
}

.rte-editor .draggable-textbox .textbox-content {
    min-height: 100%;
    width: 100%;
    overflow: visible;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.rte-editor .draggable-textbox .textbox-content img {
    max-width: 100%;
    height: auto;
}

.rte-editor .draggable-textbox:hover,
.rte-editor .draggable-textbox.selected {
    border: 1px solid #0078d7;
    box-shadow: 0 0 0 1px #0078d7;
}

.rte-editor .draggable-textbox.selected::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 1px solid #0078d7;
    right: -4px;
    bottom: -4px;
    cursor: nwse-resize;
    pointer-events: none;
}

.rte-editor .draggable-textbox.selected::before {
    content: '✕';
    position: absolute;
    top: -20px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #c00;
    color: white;
    border-radius: 50%;
    display: block;
    text-align: center;
    line-height: 18px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.rte-editor code {
    background: #f4f4f4;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.rte-editor pre {
    background: #f4f4f4;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}

.rte-editor pre code {
    background: none;
    padding: 0;
}

.rte-editor hr {
    border: none;
    border-top: 2px solid #ddd;
    margin: 1.5rem 0;
}

.rte-editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.rte-editor table th,
.rte-editor table td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
}

.rte-editor table th {
    background: #f5f5f5;
    font-weight: bold;
}

/* Modal for Links and Images */
.rte-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.rte-modal.active {
    display: flex;
}

.rte-modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
   box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.rte-modal-content h3 {
    margin: 0 0 1rem;
    color: #2c3e50;
}

.rte-modal-content label {
    display: block;
    margin: 0.5rem 0 0.25rem;
    font-weight: bold;
    color: #555;
}

.rte-modal-content input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.rte-modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.rte-modal-actions button {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.rte-modal-actions .btn-primary {
    background: #4a4a9e;
    color: #fff;
}

.rte-modal-actions .btn-primary:hover {
    background: #3a3a7e;
}

.rte-modal-actions .btn-secondary {
    background: #ddd;
    color: #333;
}

.rte-modal-actions .btn-secondary:hover {
    background: #ccc;
}

/* Source Code View */
.rte-source {
    display: none;
    min-height: 300px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    border: none;
    outline: none;
    resize: vertical;
    width: 100%;
    box-sizing: border-box;
}

.rte-source.active {
    display: block;
}

.rte-source.active ~ .rte-editor {
    display: none;
}

/* Delete button for text box */
.rte-textbox-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 10;
  background: #f44336;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 16px;
  line-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.rte-textbox-delete-btn:hover {
  opacity: 1;
  background: #d32f2f;
}

/* Responsive */
@media (max-width: 768px) {
    .rte-toolbar {
        padding: 0.25rem;
    }
    
    .rte-toolbar button {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
        min-width: 32px;
    }
    
    .rte-editor {
        font-size: 0.95rem;
        padding: 0.75rem;
    }
}
