@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono&family=Montserrat:wght@400;500;600&family=Open+Sans:wght@400;500;600&family=Playfair+Display:wght@400;500;600&family=Roboto:wght@400;500;700&display=swap');

.tiptap-container {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
}

.tiptap-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.tiptap-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-right: 1px solid #e2e8f0;
}

.tiptap-toolbar-group:last-child {
    border-right: none;
}

.tiptap-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tiptap-toolbar button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f8fafc;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: tooltipFadeIn 0.15s ease;
}

.tiptap-toolbar button[title]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1e293b;
    z-index: 1000;
    pointer-events: none;
    animation: tooltipFadeIn 0.15s ease;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tiptap-toolbar button:hover {
    background: #f1f5f9;
    color: #0f172a;
    transform: translateY(-1px);
}

.tiptap-toolbar button:active {
    transform: translateY(1px);
}

.tiptap-toolbar button.active {
    background: #e0e7ff;
    color: #4f46e5;
    font-weight: 500;
}

.tiptap-toolbar button .material-symbols-outlined {
    font-size: 20px;
}

.tiptap-font-select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    padding-right: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.tiptap-font-select:hover, .tiptap-font-select:focus {
    border-color: #94a3b8;
}

.tiptap-font-family-select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    padding-right: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 140px;
}

.tiptap-font-family-select:hover, .tiptap-font-family-select:focus {
    border-color: #94a3b8;
}

.tiptap-color-button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tiptap-color-button:hover {
    background: #e2e8f0;
}

.tiptap-color-button span {
    font-size: 18px;
    color: #475569;
}

.tiptap-color-indicator {
    width: 16px;
    height: 3px;
    border-radius: 2px;
    margin-top: -2px;
    border: 1px solid rgba(0,0,0,0.1);
}

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

.tiptap-editor-wrapper {
    flex-grow: 1;
    position: relative;
    background: #f1f5f9;
    display: flex;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.tiptap-container.tiptap-body .tiptap-editor-wrapper {
    min-height: 70vh;
}

.ProseMirror {
    background: #ffffff;
    width: 210mm;
    min-height: 100%;
    padding: 96px;
    box-sizing: border-box;
    outline: none;
    color: #1e293b;
    line-height: 1.4;
    white-space: pre-wrap;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin: 0 auto;
}

.tiptap-editor-outer-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.tiptap-editor-outer-wrapper.tiptap-fixed-height {
    overflow: hidden;
}

.tiptap-editor-outer-wrapper.tiptap-fixed-height .tiptap-editor-wrapper {
    padding: 0;
    overflow: hidden;
}

.tiptap-editor-outer-wrapper.tiptap-fixed-height .ProseMirror {
    min-height: unset !important;
    height: 100% !important;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    width: 100%;
    padding: 19px 96px;
}

.ProseMirror > *:first-child {
    margin-top: 0;
}

.ProseMirror > *:last-child {
    margin-bottom: 0;
}

.ProseMirror p {
    margin: 0 0 8px 0;
}

.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3,
.ProseMirror h4 {
    margin-top: 0;
    margin-bottom: 0.5em;
    line-height: 1.2;
    color: #0f172a;
}

.ProseMirror ul,
.ProseMirror ol {
    padding-left: 2rem;
    margin: 1rem 0;
}

.ProseMirror table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    table-layout: fixed;
    border-radius: 4px;
    overflow: hidden;
}

.ProseMirror th,
.ProseMirror td {
    border: 1px solid #e2e8f0;
    padding: 3px 5px;
    vertical-align: top;
    position: relative;
    word-break: break-word;
    box-sizing: border-box;
}

.ProseMirror th {
    background-color: #f8fafc;
    font-weight: 600;
}

.ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.ProseMirror a {
    color: #3b82f6;
    text-decoration: underline;
    cursor: pointer;
}


.tiptap-layout-table {
    border: none !important;
    margin: 1em 0;
}

.tiptap-layout-table td {
    border: none !important;
    background: transparent !important;
}

.ProseMirror table.tiptap-layout-table {
    border: none !important;
}

.ProseMirror table.tiptap-layout-table td {
    border: none !important;
}

.ProseMirror .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: -2px;
    width: 4px;
    background-color: #4f46e5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.ProseMirror .selectedCell:after {
    z-index: 2;
    position: absolute;
    content: "";
    left: 0; right: 0; top: 0; bottom: 0;
    background: rgba(79, 70, 229, 0.08);
    pointer-events: none;
}

.ProseMirror.resize-cursor {
    cursor: ew-resize;
    cursor: col-resize;
}

.ProseMirror table td:hover .column-resize-handle,
.ProseMirror table th:hover .column-resize-handle {
    opacity: 1;
}

.ProseMirror .image-resizer {
    display: inline-block;
    position: relative;
    line-height: 0;
}

.ProseMirror .image-resizer__handler {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #4f46e5;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 100;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ProseMirror .image-resizer__handler--tl { top: -6px; left: -6px; cursor: nwse-resize; }
.ProseMirror .image-resizer__handler--tr { top: -6px; right: -6px; cursor: nesw-resize; }
.ProseMirror .image-resizer__handler--bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.ProseMirror .image-resizer__handler--br { bottom: -6px; right: -6px; cursor: nwse-resize; }