/* ============================================
   Note plugin — Modal & UI styles
   Light + Dark mode
============================================ */

/* -------- Modal overlay (shared by both pages) -------- */
#qa-note-popup,
.note-modal {
    display: none;
    position: fixed;
    z-index: 5119;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* -------- Modal dialog (shared) -------- */
#qa-note-center {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100%;
    padding: 60px 16px;
    box-sizing: border-box;
}
.qa-note-wrap,
.note-modal-content {
    width: 480px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.15), 0 4px 16px rgba(0,0,0,.08);
    padding: 24px;
    position: relative;
    animation: noteModalIn .2s ease-out;
}
@keyframes noteModalIn {
    from { opacity: 0; transform: translateY(-12px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.note-modal-content {
    margin: 60px auto;
}

/* -------- Modal header -------- */
.qa-note-wrap h3 {
    margin: 0 0 16px;
    font-size: 17px;
    font-weight: 600;
    color: #1e293b;
    padding-right: 30px;
}
.note-modal-content label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

/* -------- Close button -------- */
.qa-note-close,
.note-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    background: #f1f5f9;
    transition: all .15s;
}
.qa-note-close:hover,
.note-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* -------- Textarea -------- */
.qa-note-wrap textarea,
.note-modal-content textarea {
    width: 100%;
    height: 180px;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    resize: vertical;
    transition: border-color .15s, box-shadow .15s;
}
.qa-note-wrap textarea:focus,
.note-modal-content textarea:focus {
    outline: none;
    background: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

/* -------- Action buttons row -------- */
.qa-note-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* -------- Error message -------- */
.qa-note-error {
    display: none;
    margin-bottom: 12px;
    padding: 10px 14px;
    font-size: 13px;
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

/* -------- Buttons -------- */
.qa-note-actions .qa-form-tall-button,
.note-actions .qa-form-tall-button,
.note-modal-content .qa-form-tall-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border-radius: 7px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all .15s;
    min-width: 72px;
}
.qa-note-actions .qa-form-tall-button:hover,
.note-actions .qa-form-tall-button:hover,
.note-modal-content .qa-form-tall-button:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
/* Primary (Save/Update) */
.qa-note-actions .qa-form-tall-button-submit {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.qa-note-actions .qa-form-tall-button-submit:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}
/* Delete button on listing page */
.note-delete-btn.qa-form-tall-button {
    color: #b91c1c;
    border-color: #fca5a5;
    background: #fef2f2;
}
.note-delete-btn.qa-form-tall-button:hover {
    background: #fee2e2;
    border-color: #f87171;
}

/* ============================================
   Note block under question content
============================================ */
.qa-user-note .pdeleted-delete { display: none !important; }
.qa-user-note-wrapper { margin-top: 20px; }
.qa-user-note-divider { border: none; border-top: 1px solid #e2e8f0; margin: 12px 0; }
.qa-user-note-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    text-align: left;
    position: relative;
}
.qa-user-note-content {
    color: #475569;
    line-height: 1.6;
    font-size: 14px;
}

/* -------- Collapsible / toggle -------- */
.collapsible-note {
    max-height: 100px;
    overflow: hidden;
    position: relative;
    transition: max-height .3s ease;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.collapsible-note.expanded { max-height: none; }
.toggle-note-btn {
    margin-top: 6px;
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    padding: 0;
    font-size: 0.88em;
    font-weight: 500;
}
.toggle-note-btn:hover { text-decoration: underline; }

/* -------- Note block icon actions (top-right) -------- */
.qa-note-icon-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
    z-index: 2;
}
.qa-user-note-block:hover .qa-note-icon-actions {
    opacity: 1;
}
.qa-note-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    padding: 0;
    font-size: 0;
}
.qa-note-icon-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}
.qa-note-icon-delete:hover {
    background: #fef2f2;
    border-color: #f87171;
    color: #dc2626;
}
.qa-note-icon-info:hover {
    background: #eff6ff;
    border-color: #60a5fa;
    color: #2563eb;
}

/* ============================================
   User-notes listing page
============================================ */
.user-note {
    background: #f8fafc;
    border-left: 4px solid #cbd5e1;
    padding: 12px 14px;
    border-radius: 6px;
    margin-top: 1em;
}
.note-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============================================
   Responsive
============================================ */
@media (max-width: 768px) {
    .qa-note-wrap,
    .note-modal-content { width: 90vw !important; }
}

/* ============================================
   Dark mode
============================================ */

/* Overlay */
[data-theme="dark"] #qa-note-popup,
[data-theme="dark"] .note-modal {
    background: rgba(0, 0, 0, .6);
}

/* Modal dialog */
[data-theme="dark"] .qa-note-wrap,
[data-theme="dark"] .note-modal-content {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 4px 16px rgba(0,0,0,.25);
    color: #e2e8f0;
}
[data-theme="dark"] .qa-note-wrap h3 { color: #f1f5f9; }
[data-theme="dark"] .note-modal-content label { color: #f1f5f9; }

/* Close */
[data-theme="dark"] .qa-note-close,
[data-theme="dark"] .note-close {
    background: #334155;
    color: #94a3b8;
}
[data-theme="dark"] .qa-note-close:hover,
[data-theme="dark"] .note-close:hover {
    background: #475569;
    color: #f1f5f9;
}

/* Textarea */
[data-theme="dark"] .qa-note-wrap textarea,
[data-theme="dark"] .note-modal-content textarea {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] .qa-note-wrap textarea:focus,
[data-theme="dark"] .note-modal-content textarea:focus {
    background: #0f172a;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .2);
}

/* Error */
[data-theme="dark"] .qa-note-error {
    color: #fca5a5;
    background: #450a0a;
    border-color: #7f1d1d;
}

/* Note block */
[data-theme="dark"] .qa-user-note-divider { border-top-color: #334155; }
[data-theme="dark"] .qa-user-note-block {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
[data-theme="dark"] .qa-user-note-content { color: #94a3b8; }
[data-theme="dark"] .toggle-note-btn { color: #60a5fa; }

/* Note block icon actions */
[data-theme="dark"] .qa-note-icon-btn {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}
[data-theme="dark"] .qa-note-icon-btn:hover {
    background: #475569;
    border-color: #64748b;
    color: #f1f5f9;
}
[data-theme="dark"] .qa-note-icon-delete:hover {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fca5a5;
}
[data-theme="dark"] .qa-note-icon-info:hover {
    background: #1d4ed8;
    border-color: #3b82f6;
    color: #93c5fd;
}

/* User-note cards */
[data-theme="dark"] .user-note {
    background: #1e293b;
    border-left-color: #475569;
    color: #e2e8f0;
}
[data-theme="dark"] .collapsible-note { color: #94a3b8; }

/* Buttons */
[data-theme="dark"] .qa-note-actions .qa-form-tall-button,
[data-theme="dark"] .note-actions .qa-form-tall-button,
[data-theme="dark"] .note-modal-content .qa-form-tall-button {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] .qa-note-actions .qa-form-tall-button:hover,
[data-theme="dark"] .note-actions .qa-form-tall-button:hover,
[data-theme="dark"] .note-modal-content .qa-form-tall-button:hover {
    background: #475569;
    color: #f8fafc;
    border-color: #64748b;
}
/* Primary */
[data-theme="dark"] .qa-note-actions .qa-form-tall-button-submit {
    background: #2563eb;
    border-color: #3b82f6;
    color: #fff;
}
[data-theme="dark"] .qa-note-actions .qa-form-tall-button-submit:hover {
    background: #1d4ed8;
    border-color: #2563eb;
}
/* Delete (listing) */
[data-theme="dark"] .note-delete-btn.qa-form-tall-button {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}
[data-theme="dark"] .note-delete-btn.qa-form-tall-button:hover {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fecaca;
}
