/* Custom styles for MR WriteWords */

#editor:focus, #documentHeader:focus, #documentFooter:focus {
    outline: none;
}

#editor img, #preview img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#editor img:hover {
    cursor: pointer;
    opacity: 0.9;
}

/* Image wrapper for resizing */
.image-wrapper {
    position: relative;
    display: inline-block;
    margin: 10px;
    vertical-align: middle;
    cursor: default;
}

.image-wrapper.selected {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.image-wrapper.selected img {
    opacity: 0.9;
    pointer-events: none;
}

.image-wrapper.selected {
    user-select: none;
    -webkit-user-select: none;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    background-color: #3b82f6;
    border: 2px solid white;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: none;
    z-index: 1001;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}

.image-wrapper.selected .resize-handle {
    display: block;
}

.resize-handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle-n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle-s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle-e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-handle-w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

/* Page layout - A4 size */
#documentWrapper, #previewWrapper {
    page-break-after: always;
}

/* Heading styles */
#editor h1 {
    font-size: 2em;
    font-weight: bold;
    margin: 0.67em 0;
}

#editor h2 {
    font-size: 1.5em;
    font-weight: bold;
    margin: 0.75em 0;
}

#editor h3 {
    font-size: 1.17em;
    font-weight: bold;
    margin: 0.83em 0;
}

#editor h4 {
    font-size: 1em;
    font-weight: bold;
    margin: 1em 0;
}

#editor h5 {
    font-size: 0.83em;
    font-weight: bold;
    margin: 1.17em 0;
}

#editor h6 {
    font-size: 0.67em;
    font-weight: bold;
    margin: 1.33em 0;
}

/* Lists */
#editor ul, #editor ol {
    margin: 1em 0;
    padding-left: 2em;
}

#editor li {
    margin: 0.25em 0;
}

/* Tables */
#editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

#editor table td, #editor table th {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

#editor table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

#editor table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1f2937;
}

::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Document list item styling */
.document-item {
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s, color 0.2s;
}

.document-item:not(.bg-blue-600):hover {
    background-color: #374151;
}

/* Toolbar button active state */
.toolbar-btn-active {
    background-color: #3b82f6 !important;
    color: white;
}

/* Page number styling */
.page-number {
    display: inline-block;
}

/* Header and Footer styling */
#documentHeader, #documentFooter, #previewHeader, #previewFooter {
    font-size: 0.875rem;
    color: #666;
}

#documentHeader:empty::before, #documentFooter:empty::before {
    content: ' ';
    display: inline-block;
}

/* Toast notifications */
#toastContainer {
    pointer-events: none;
}

#toastContainer > div {
    pointer-events: auto;
}

/* Modal animations */
#documentModal, #tableModal, #confirmModal {
    animation: fadeIn 0.2s ease-out;
}

#documentModal > div, #tableModal > div, #confirmModal > div {
    animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
