@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; /* Solid background for sticky */
    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);
}

.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;
}

/* Editor Wrapper */
.tiptap-editor-wrapper {
    flex-grow: 1;
    position: relative;
    background: #f1f5f9; /* Gray background for doc view */
    display: flex;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

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

/* Basic Prosemirror Typography styles */
.ProseMirror {
    background: #ffffff;
    width: 210mm; /* A4 width */
    min-height: 100%;
    padding: 32px 48px;
    outline: none;
    color: #1e293b;
    line-height: 1.4;
    font-size: 14px;
    font-family: sans-serif;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); /* Page shadow */
    margin: 0 auto;
}

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

/* For Header/Footer fixed size editors */
.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: 8px 16px; /* More compact for Headers/Footers */
}

.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: 8px 12px;
    vertical-align: top;
    position: relative;
    word-break: break-word;
}

.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;
}


/* Layout Tables (Invisible) */
.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;
}
