/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

body {
    font-family: 'Inter', sans-serif;
}

/* Custom scrollbar for a cleaner look */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Flash message animations */
@keyframes slide-in {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slide-out {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.animate-slide-in {
    animation: slide-in 0.3s ease-out forwards;
}

/* Enhanced keyboard navigation focus states */
*:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

/* Button focus states */
button:focus-visible,
input[type="submit"]:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

/* Input focus states */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 0px !important;
}

/* Link focus states */
a:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

/* Checkbox and radio focus states */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    *:focus-visible {
        outline-width: 4px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Rich Text Editor (Tiptap) Styles
   ========================================================================== */

/* ── Container ────────────────────────────────────────────────────── */
.rte-container {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.rte-container:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ── Toolbar ──────────────────────────────────────────────────────── */
.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0.375rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.rte-btn-group {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    overflow: hidden;
    background: white;
}

.rte-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.875rem;
    height: 1.875rem;
    padding: 0 0.375rem;
    border: none;
    border-right: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
    font-size: 0.8125rem;
}

.rte-btn:last-child {
    border-right: none;
}

.rte-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.rte-btn--active {
    background: #3b82f6 !important;
    color: white !important;
}

.rte-btn svg {
    flex-shrink: 0;
}

.rte-btn-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Editor area ──────────────────────────────────────────────────── */
.rte-editor-wrapper {
    min-height: 200px;
}

.tiptap-editor-content {
    min-height: 200px;
    padding: 0.75rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.625;
    color: #111827;
    outline: none;
}

/* Placeholder (via Tiptap Placeholder extension) */
.tiptap-editor-content p.is-editor-empty:first-child::before {
    color: #9ca3af;
    content: attr(data-placeholder);
    float: left;
    height: 0;
    pointer-events: none;
}

/* ── Typography inside editor ─────────────────────────────────────── */
.tiptap-editor-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0.75rem 0 0.5rem;
    line-height: 1.3;
}

.tiptap-editor-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0.625rem 0 0.375rem;
    line-height: 1.35;
}

.tiptap-editor-content h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
    line-height: 1.4;
}

.tiptap-editor-content p {
    margin: 0.25rem 0;
}

.tiptap-editor-content ul {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.tiptap-editor-content ol {
    list-style: decimal;
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.tiptap-editor-content li {
    margin: 0.125rem 0;
}

.tiptap-editor-content li p {
    margin: 0;
}

.tiptap-editor-content blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: #4b5563;
    font-style: italic;
}

.tiptap-editor-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.875em;
    color: #e11d48;
}

.tiptap-editor-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.875rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.tiptap-editor-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

.tiptap-editor-content a {
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
}

.tiptap-editor-content mark {
    background-color: #fef08a;
    border-radius: 2px;
    padding: 0 2px;
}

.tiptap-editor-content hr {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 1rem 0;
}

/* Text alignment */
.tiptap-editor-content [style*="text-align: center"] { text-align: center; }
.tiptap-editor-content [style*="text-align: right"] { text-align: right; }

/* ── Tables ───────────────────────────────────────────────────────── */
.tiptap-editor-content table,
.rich-text-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75rem 0;
    table-layout: fixed;
    overflow: hidden;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
}

.tiptap-editor-content th,
.rich-text-content th {
    background: #f9fafb;
    font-weight: 600;
    text-align: left;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #374151;
}

.tiptap-editor-content td,
.tiptap-editor-content th,
.rich-text-content td,
.rich-text-content th {
    border: 1px solid #d1d5db;
    padding: 0.5rem 0.75rem;
    vertical-align: top;
    min-width: 80px;
}

.tiptap-editor-content td > p,
.tiptap-editor-content th > p {
    margin: 0;
}

/* Selected cell highlight */
.tiptap-editor-content .selectedCell::after {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0; bottom: 0;
    background: rgba(59, 130, 246, 0.1);
    pointer-events: none;
    z-index: 2;
}

.tiptap-editor-content td, .tiptap-editor-content th {
    position: relative;
}

/* Table resize handle */
.tiptap-editor-content .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: -2px;
    width: 4px;
    background-color: #3b82f6;
    pointer-events: none;
}

.tiptap-editor-content.resize-cursor {
    cursor: col-resize;
}

/* ── Popup menus (emoji, table, spacing) ──────────────────────────── */
.emoji-picker-popup,
.table-menu-popup,
.spacing-menu-popup {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.emoji-picker-popup {
    padding: 0.75rem;
    width: 340px;
    max-height: 320px;
    overflow-y: auto;
}

.emoji-picker-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.emoji-category-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.375rem 0 0.125rem;
    border-top: 1px solid #f3f4f6;
}

.emoji-category-label:first-child {
    border-top: none;
    padding-top: 0;
}

.emoji-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.emoji-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    border: none;
    background: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.1s;
}

.emoji-btn:hover {
    background: #f3f4f6;
}

/* Popup menu (table, spacing) */
.popup-menu-inner {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    padding: 0.25rem 0;
}

.popup-menu-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.75rem 0.25rem;
}

.popup-menu-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    color: #374151;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.1s;
    white-space: nowrap;
}

.popup-menu-option:hover {
    background: #f3f4f6;
}

.popup-menu-option--danger {
    color: #dc2626;
}

.popup-menu-option--danger:hover {
    background: #fef2f2;
}

.popup-menu-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

.spacing-preview {
    font-size: 0.6875rem;
    color: #9ca3af;
    font-weight: 500;
    margin-left: auto;
}

/* ── Rich text content display (show pages) ───────────────────────── */
.rich-text-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0.75rem 0 0.5rem;
    line-height: 1.3;
}

.rich-text-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0.625rem 0 0.375rem;
    line-height: 1.35;
}

.rich-text-content h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
    line-height: 1.4;
}

.rich-text-content p {
    margin: 0.375rem 0;
}

.rich-text-content ul {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.rich-text-content ol {
    list-style: decimal;
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.rich-text-content li {
    margin: 0.25rem 0;
}

.rich-text-content blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: #4b5563;
    font-style: italic;
}

.rich-text-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, monospace;
    font-size: 0.875em;
    color: #e11d48;
}

.rich-text-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-family: ui-monospace, monospace;
    font-size: 0.875rem;
    overflow-x: auto;
}

.rich-text-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.rich-text-content a {
    color: #2563eb;
    text-decoration: underline;
}

.rich-text-content mark {
    background-color: #fef08a;
    border-radius: 2px;
    padding: 0 2px;
}

.rich-text-content hr {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 1rem 0;
}
