/* ============================================================
   EduWrite AI – Custom Styles
   Supplements Tailwind CSS with editor-specific, animation,
   and component styles that are difficult or verbose in utility-first.
   ============================================================ */

/* ── Editor ──────────────────────────────────────────────────── */
[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
    font-style: italic;
}

#editor-content {
    outline: none;
    caret-color: #4f46e5;
}

#editor-content blockquote {
    border-left: 4px solid #818cf8;
    padding-left: 1rem;
    color: #4b5563;
    margin: 1rem 0;
    font-style: italic;
}

#editor-content a {
    color: #4f46e5;
    text-decoration: underline;
}

#editor-content h1 { font-size: 2rem; font-weight: 700; margin: 1.5rem 0 0.75rem; }
#editor-content h2 { font-size: 1.5rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
#editor-content h3 { font-size: 1.25rem; font-weight: 600; margin: 1rem 0 0.5rem; }
#editor-content h4 { font-size: 1.125rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }

#editor-content ul, #editor-content ol {
    padding-left: 1.5rem;
    margin: 0.75rem 0;
}
#editor-content ul { list-style-type: disc; }
#editor-content ol { list-style-type: decimal; }
#editor-content li { margin-bottom: 0.25rem; }

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

.ai-inserted {
    border-left: 3px solid #818cf8;
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 0.375rem 0.375rem 0;
}

/* ── AI Panel ────────────────────────────────────────────────── */
.ai-response-content h3,
.ai-response-content h4 {
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.ai-response-content ul,
.ai-response-content ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.ai-response-content li {
    margin-bottom: 0.25rem;
}

.ai-response-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.8125rem;
}

/* ── Floating Menu ───────────────────────────────────────────── */
#editor-floating-menu {
    animation: floatUp 0.15s ease-out;
}

@keyframes floatUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Toast Animations ────────────────────────────────────────── */
.toast-enter {
    animation: slideInRight 0.3s ease-out;
}

.toast-exit {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ── Skeleton Loading ────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.375rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Progress Ring Animation ─────────────────────────────────── */
svg circle {
    transition: stroke-dashoffset 1s ease-out;
}

/* ── Sidebar Active State ────────────────────────────────────── */
.sidebar-link.active {
    background-color: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
    font-weight: 500;
}

/* ── Data Table ──────────────────────────────────────────────── */
.data-table th {
    position: sticky;
    top: 0;
    background: #f9fafb;
    z-index: 5;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background: #f3f4f6;
}

/* ── Modal Backdrop ──────────────────────────────────────────── */
.modal-backdrop {
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    animation: scaleIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Print styles ────────────────────────────────────────────── */
@media print {
    nav, .sidebar, #editor-toolbar, #editor-floating-menu,
    #ai-panel, #ai-panel-overlay, .toast-container,
    .modal-backdrop, button { display: none !important; }

    #editor-content {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    body { background: white !important; }
}

/* ── Notification dot pulse ──────────────────────────────────── */
.notification-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Line Clamp ──────────────────────────────────────────────── */
.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;
}

/* ── Focus Ring Consistency ──────────────────────────────────── */
input:focus, textarea:focus, select:focus, [contenteditable]:focus {
    outline: none;
}

/* ── Scrollbar (supplemental) ────────────────────────────────── */
.thin-scrollbar::-webkit-scrollbar { width: 4px; }
.thin-scrollbar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.thin-scrollbar::-webkit-scrollbar-track { background: transparent; }
