@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
    html {
        scroll-behavior: smooth;
    }
    body {
        font-family: 'Inter', sans-serif;
    }
}

@layer utilities {
    .hide-scrollbar::-webkit-scrollbar {
        display: none;
    }
    .hide-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Editor Toolbar */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    min-height: 42px;
}

#editor-wrapper.editor-fullscreen .editor-toolbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 0;
}

/* Floating Bubble Toolbar */
.floating-toolbar {
    position: absolute;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: #111827;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 50;
    pointer-events: auto;
    transform: translateX(-50%);
    white-space: nowrap;
}

.floating-toolbar.visible {
    display: flex;
}

.floating-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #d1d5db;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.12s;
}

.floating-toolbar button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.floating-toolbar button.active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.floating-toolbar .ft-separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
    flex-shrink: 0;
}

.floating-toolbar select {
    height: 28px;
    padding: 0 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

.floating-toolbar select option {
    background: #111827;
    color: #e5e7eb;
}

.editor-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #4b5563;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.editor-toolbar button:hover {
    background: #e5e7eb;
    color: #111827;
}

.editor-toolbar button.active {
    background: #111827;
    color: #ffffff;
}

.editor-toolbar button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.editor-toolbar select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.editor-toolbar select:focus {
    border-color: #111827;
    ring: 2px;
}

.editor-toolbar-separator {
    width: 1px;
    height: 24px;
    background: #d1d5db;
    margin: 0 6px;
    flex-shrink: 0;
}

.editor-toolbar-spacer {
    flex: 1;
}

/* ProseMirror / TipTap Editor */
.ProseMirror {
    outline: none;
    min-height: 400px;
    padding: 20px 24px;
    font-size: 15px;
    line-height: 1.75;
    color: #1f2937;
}

.ProseMirror > * + * {
    margin-top: 0.75em;
}

.ProseMirror p.is-editor-empty:first-child::before {
    color: #9ca3af;
    content: attr(data-placeholder);
    float: left;
    height: 0;
    pointer-events: none;
}

.ProseMirror h2 {
    font-size: 1.5em;
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
    color: #111827;
}

.ProseMirror h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 1.25em;
    margin-bottom: 0.5em;
    line-height: 1.4;
    color: #111827;
}

.ProseMirror h4 {
    font-size: 1.125em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.4em;
    color: #1f2937;
}

.ProseMirror h5 {
    font-size: 1em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.4em;
    color: #374151;
}

.ProseMirror h6 {
    font-size: 0.875em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.4em;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ProseMirror p {
    margin-bottom: 0.5em;
}

.ProseMirror strong {
    font-weight: 700;
}

.ProseMirror em {
    font-style: italic;
}

.ProseMirror u {
    text-decoration: underline;
}

.ProseMirror s {
    text-decoration: line-through;
}

.ProseMirror ul {
    list-style-type: disc;
    padding-left: 1.5em;
    margin-bottom: 0.75em;
}

.ProseMirror ol {
    list-style-type: decimal;
    padding-left: 1.5em;
    margin-bottom: 0.75em;
}

.ProseMirror li {
    margin-bottom: 0.25em;
}

.ProseMirror li > p {
    margin: 0;
}

.ProseMirror blockquote {
    border-left: 4px solid #111827;
    padding-left: 1em;
    margin-left: 0;
    margin-right: 0;
    font-style: italic;
    color: #4b5563;
    background: #f9fafb;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
}

.ProseMirror pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.ProseMirror code {
    background: #f3f4f6;
    color: #dc2626;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.ProseMirror pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.ProseMirror hr {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 1.5em 0;
}

.ProseMirror a,
.ProseMirror .editor-link {
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
}

.ProseMirror a:hover {
    color: #1d4ed8;
}

.ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.ProseMirror img:hover {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.ProseMirror figure {
    margin: 1em 0;
}

.ProseMirror figcaption {
    text-align: center;
    font-size: 0.875em;
    color: #6b7280;
    font-style: italic;
    margin-top: 8px;
}

/* Tables */
.ProseMirror table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    overflow: hidden;
}

.ProseMirror th,
.ProseMirror td {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    text-align: left;
    position: relative;
    min-width: 80px;
}

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

.ProseMirror .selectedCell::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(37, 99, 235, 0.1);
    pointer-events: none;
}

.ProseMirror .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: -2px;
    width: 4px;
    background: #2563eb;
    z-index: 10;
    cursor: col-resize;
}

/* Editor Wrapper */
#editor-wrapper {
    position: relative;
}

#editor-wrapper.editor-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    overflow-y: auto;
}

#editor-wrapper.editor-fullscreen #tiptap-editor {
    max-width: 800px;
    margin: 0 auto;
    min-height: calc(100vh - 50px);
}

/* Editor Modals */
.editor-modal-backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.editor-modal input[type="text"],
.editor-modal input[type="url"],
.editor-modal input[type="number"],
.editor-modal select,
.editor-modal textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.editor-modal input:focus,
.editor-modal select:focus,
.editor-modal textarea:focus {
    border-color: #111827;
    box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.1);
}

/* Amazon Affiliate Link Button Widget */
.amz-affiliate-cta-box {
    margin: 8px 0 1.5rem 0;
    z-index: 10;
}

.amz-affiliate-cta-box.align-right,
.amz-affiliate-cta-box.float-right {
    float: right;
    margin: 6px 0 1.5rem 1.5rem;
    clear: right;
    display: inline-block;
}

.amz-affiliate-cta-box.align-left,
.amz-affiliate-cta-box.float-left {
    float: left;
    margin: 6px 1.5rem 1.5rem 0;
    clear: left;
    display: inline-block;
}

.amz-affiliate-cta-box.align-center,
.amz-affiliate-cta-box.float-center {
    display: block;
    text-align: center;
    margin: 1.5rem auto;
    clear: both;
}

.amz-affiliate-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    background: #131921 !important;
    color: #ffffff !important;
    font-size: 0.9375rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    padding: 10px 22px !important;
    border-radius: 9999px !important;
    text-decoration: none !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22) !important;
    border: 2px solid #232f3e !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    font-family: inherit !important;
}

.amz-affiliate-btn:hover {
    background: #232f3e !important;
    border-color: #f97316 !important;
    color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3) !important;
    text-decoration: none !important;
}

.amz-affiliate-btn .amz-icon {
    font-size: 1.25rem !important;
    color: #f97316 !important;
    display: inline-block !important;
    line-height: 1 !important;
}

.amz-affiliate-btn .amz-btn-text {
    font-size: 0.9375rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    letter-spacing: 0.01em !important;
}

.amz-affiliate-btn .amz-arrow {
    font-size: 0.8125rem !important;
    color: #cbd5e1 !important;
    margin-left: 2px !important;
    transition: transform 0.15s ease, color 0.15s ease !important;
}

.amz-affiliate-btn:hover .amz-arrow {
    color: #f97316 !important;
    transform: translate(2px, -2px) !important;
}

.ProseMirror [data-amz-button],
.ProseMirror .amz-affiliate-cta-box {
    cursor: pointer;
    user-select: none;
}

.ProseMirror .amz-affiliate-cta-box a,
.ProseMirror .amz-affiliate-btn {
    pointer-events: none !important;
}

.ProseMirror [data-amz-button]:hover .amz-affiliate-btn,
.ProseMirror .amz-affiliate-cta-box:hover .amz-affiliate-btn {
    border-color: #f97316 !important;
}

.ProseMirror .ProseMirror-selectednode[data-amz-button] .amz-affiliate-btn,
.ProseMirror .ProseMirror-selectednode.amz-affiliate-cta-box .amz-affiliate-btn {
    outline: 2px solid #f97316 !important;
    outline-offset: 3px !important;
}

@media (max-width: 640px) {
    .amz-affiliate-cta-box.align-right,
    .amz-affiliate-cta-box.float-right,
    .amz-affiliate-cta-box.align-left,
    .amz-affiliate-cta-box.float-left {
        float: none !important;
        margin: 1.25rem auto !important;
        display: flex !important;
        justify-content: center !important;
        clear: both !important;
    }
}

/* Floating Amazon CTA Widget */
.floating-amz-wrapper {
    position: fixed;
    bottom: 84px;
    right: 24px;
    z-index: 9990;
    display: none;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
.floating-amz-wrapper.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.floating-amz-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    background: linear-gradient(135deg, #131921 0%, #232f3e 100%) !important;
    color: #ffffff !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    padding: 10px 18px 10px 12px !important;
    border-radius: 9999px !important;
    text-decoration: none !important;
    border: 1.5px solid #374151 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !important;
    white-space: nowrap !important;
}
.floating-amz-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36), 0 0 14px rgba(249, 115, 22, 0.45) !important;
    border-color: #f97316 !important;
    color: #ffffff !important;
    text-decoration: none !important;
}
.floating-amz-icon-wrap {
    width: 26px;
    height: 26px;
    background: #f97316;
    color: #131921;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    line-height: 1;
}
.floating-amz-text {
    color: #ffffff !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em;
}
.floating-amz-arrow {
    font-size: 0.75rem !important;
    color: #f97316 !important;
    transition: transform 0.2s ease;
}
.floating-amz-btn:hover .floating-amz-arrow {
    transform: translate(2px, -2px);
}
.floating-amz-close-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.85);
    color: #d1d5db;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.floating-amz-close-btn:hover {
    background: #111827;
    color: #ffffff;
    transform: scale(1.1);
}
@media (max-width: 640px) {
    .floating-amz-wrapper {
        bottom: 80px;
        right: 12px;
    }
    .floating-amz-btn {
        padding: 8px 14px 8px 10px !important;
        font-size: 0.8125rem !important;
        gap: 8px !important;
    }
    .floating-amz-icon-wrap {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }
    .floating-amz-text {
        font-size: 0.8125rem !important;
    }
}

