/* RadReport v3 - Radiology Writing Assistant Styles */

/* ========== Wrapper & Container ========== */
.radreport-wrapper {
    background: #f8fafc;
    padding: 1rem 1rem 2rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #334155;
    box-sizing: border-box;
    transition: background 0.3s, color 0.3s;
}
.radreport-wrapper *, .radreport-wrapper *::before, .radreport-wrapper *::after { box-sizing: border-box; }
.radreport-container { max-width: 1400px; margin: 0 auto; }

/* ========== Base Resets for Theme Conflicts ========== */
.radreport-wrapper svg {
    display: inline-block !important;
    max-width: none !important;
}
.radreport-wrapper button {
    font-family: inherit;
    line-height: inherit;
    box-shadow: none;
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
}
.radreport-wrapper button:focus {
    outline: none;
}

/* Specific SVG sizing to override theme CSS */
.radreport-icon-box svg, .radreport-btn-close svg { width: 24px !important; height: 24px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }
.radreport-btn-darkmode svg, .radreport-error-banner svg { width: 20px !important; height: 20px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }
.radreport-toolbar-btn svg { width: 16px !important; height: 16px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }
.radreport-btn-ghost svg { width: 14px !important; height: 14px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }
.radreport-btn-teal-gradient svg, .radreport-btn-analyze svg { width: 16px !important; height: 16px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }
.radreport-loading-icon svg, .radreport-modal-empty svg { width: 40px !important; height: 40px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }
.radreport-output-empty-icon svg { width: 32px !important; height: 32px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2 !important; }

/* ========== Header ========== */
.radreport-header { margin-bottom: 2rem; }
.radreport-header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.radreport-title-wrapper { display: flex; align-items: center; gap: 0.75rem; }
.radreport-icon-box {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    padding: 0.625rem; border-radius: 0.75rem;
    color: #fff; display: flex; align-items: center; justify-content: center;
}
.radreport-title {
    font-size: 1.875rem; font-weight: 700; margin: 0; line-height: 1.2; color: #0f172a;
}

/* Dark mode toggle */
.radreport-btn-darkmode {
    background: #e2e8f0; border: none; border-radius: 0.5rem;
    padding: 0.5rem; cursor: pointer; color: #475569; transition: all 0.2s;
}
.radreport-btn-darkmode:hover { background: #cbd5e1; color: #1e293b; }

/* ========== Error Banner ========== */
.radreport-error-banner {
    background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
    border-radius: 0.75rem; padding: 0.75rem 1rem; margin-bottom: 1.5rem;
    display: flex; align-items: flex-start; gap: 0.75rem;
}
.radreport-error-banner svg { color: #ef4444; flex-shrink: 0; margin-top: 2px; }
.radreport-error-title { font-weight: 600; color: #991b1b; margin: 0 0 0.125rem; font-size: 0.875rem; }
.radreport-error-msg { color: #ef4444; margin: 0; font-size: 0.8125rem; }

/* ========== Grid ========== */
.radreport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
@media (max-width: 1024px) { .radreport-grid { grid-template-columns: 1fr; } }

/* ========== Card ========== */
.radreport-card {
    background: #fff; border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    padding: 1.5rem; position: relative;
    display: flex; flex-direction: column; gap: 1rem;
}

/* ========== Section Header ========== */
.radreport-section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.radreport-section-title { font-size: 1.25rem; font-weight: 600; color: #0f172a; margin: 0; }
.radreport-header-actions { display: flex; align-items: center; gap: 0.5rem; position: relative; }

/* ========== Toast ========== */
.radreport-toast {
    position: absolute; top: -2.5rem; right: 0;
    padding: 0.375rem 0.75rem; border-radius: 0.5rem;
    color: #fff; font-size: 0.8125rem; font-weight: 500;
    white-space: nowrap; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ========== Formatting Toolbar ========== */
.radreport-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 0.5rem; border-radius: 0.5rem;
    background: #f8fafc; border: 1px solid #e2e8f0;
    margin-bottom: 0.5rem;
}
.radreport-toolbar-btn {
    display: flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; border: none; border-radius: 0.375rem;
    background: transparent; cursor: pointer; color: #475569; transition: all 0.15s;
    padding: 0;
}
.radreport-toolbar-btn:hover, .radreport-toolbar-btn:focus { 
    background: #e2e8f0; 
    color: #0f172a; 
    outline: none;
}
.radreport-toolbar-sep { width: 1px; height: 1.5rem; background: #e2e8f0; margin: 0 4px; }
.radreport-toolbar-dropdown { position: relative; }

/* ========== Editor ========== */
.radreport-editor {
    width: 100%; min-height: 32rem; max-height: 48rem;
    padding: 1rem; border: 1px solid #e2e8f0; border-radius: 0.5rem;
    background: #f8fafc; overflow-y: auto; transition: all 0.2s;
    font-family: Helvetica, Arial, sans-serif; font-size: 14.67px; line-height: 1.5;
    color: #0f172a; outline: none;
}
.radreport-editor:focus { border-color: #a855f7; box-shadow: 0 0 0 2px rgba(168,85,247,0.2); background: #fff; }
.radreport-editor:empty:before {
    content: attr(data-placeholder); color: #94a3b8; font-style: italic;
    pointer-events: none; display: block;
}
.radreport-editor ul, .radreport-editor ol { margin: 8px 0; padding-left: 24px; }
.radreport-editor li { margin: 4px 0; list-style-position: outside; }
.radreport-editor ul { list-style-type: disc; }
.radreport-editor ol { list-style-type: decimal; }
.radreport-editor div { margin: 0; padding: 0; min-height: 1.2em; }
.radreport-editor mark { border-bottom: 2px solid transparent; transition: all 0.2s ease; cursor: pointer; }
.radreport-editor mark:hover { filter: brightness(0.85); }
.radreport-editor mark[data-category="spelling"]:hover { border-bottom-color: rgb(59,130,246); }
.radreport-editor mark[data-category="grammar"]:hover { border-bottom-color: rgb(34,197,94); }
.radreport-editor mark[data-category="style"]:hover { border-bottom-color: rgb(234,179,8); }
.radreport-editor mark[data-category="semantic"]:hover { border-bottom-color: rgb(239,68,68); }

/* ========== Controls Row & Options ========== */
.radreport-controls-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.radreport-options-box {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.75rem; background: #f8fafc;
    border-radius: 0.5rem; border: 1px solid #e2e8f0;
}
.radreport-option-group { display: flex; align-items: center; gap: 0.5rem; }
.radreport-option-label { font-size: 0.75rem; font-weight: 600; color: #0f172a; margin: 0; cursor: pointer; }
.radreport-radio-group { display: flex; gap: 0.5rem; }
.radreport-radio-item { display: flex; align-items: center; gap: 0.375rem; cursor: pointer; font-size: 0.8125rem; color: #475569; }
.radreport-radio { width: 1rem; height: 1rem; cursor: pointer; accent-color: #a855f7; }
.radreport-option-divider { width: 1px; height: 1.5rem; background: #e2e8f0; }
.radreport-checkbox-item { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.radreport-checkbox { width: 1rem; height: 1rem; cursor: pointer; accent-color: #a855f7; border-radius: 0.25rem; }

/* ========== Editor Footer ========== */
.radreport-editor-footer {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;
}
.radreport-footer-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.radreport-api-counter { font-size: 0.7rem; color: #94a3b8; white-space: nowrap; }

/* ========== Buttons ========== */
.radreport-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 1rem; border: none; border-radius: 0.5rem;
    font-weight: 600; font-size: 0.8125rem; cursor: pointer; transition: all 0.2s;
    text-decoration: none; line-height: 1.4; text-align: center;
}
.radreport-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.radreport-btn svg { flex-shrink: 0; }
.radreport-btn-icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.radreport-btn-sm { padding: 0.25rem 0.75rem; font-size: 0.75rem; }

.radreport-btn-primary { background: #a855f7; color: #fff; }
.radreport-btn-primary:hover:not(:disabled) { background: #9333ea; }

.radreport-btn-ghost {
    background: #f1f5f9; color: #475569; padding: 0.375rem 0.75rem;
    border-radius: 0.5rem; transition: all 0.2s;
}
.radreport-btn-ghost:hover { background: #e2e8f0; color: #0f172a; transform: scale(1.03); }

.radreport-btn-ghost-lg { background: #f1f5f9; color: #0f172a; padding: 0.5rem 1.25rem; border-radius: 0.5rem; }
.radreport-btn-ghost-lg:hover { background: #e2e8f0; }

.radreport-btn-danger { background: #ef4444; color: #fff; }
.radreport-btn-danger:hover { background: #dc2626; }

.radreport-btn-success { background: #22c55e; color: #fff; }
.radreport-btn-success:hover { background: #16a34a; }

.radreport-btn-purple { background: #a855f7; color: #fff; }
.radreport-btn-purple:hover:not(:disabled) { background: #9333ea; }

.radreport-btn-teal-gradient { background: #0d9488; color: #fff; font-weight: 600; }
.radreport-btn-teal-gradient:hover:not(:disabled) { background: #0f766e; }

.radreport-btn-analyze {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #fff; font-weight: 600; padding: 0.5rem 1.5rem;
    box-shadow: 0 2px 8px rgba(168,85,247,0.3);
}
.radreport-btn-analyze:hover:not(:disabled) {
    background: linear-gradient(135deg, #9333ea, #4f46e5);
    transform: scale(1.03);
}

.radreport-btn-apply-all {
    width: 100%; padding: 0.625rem 1rem; border-radius: 0.5rem;
    background: linear-gradient(135deg, #22c55e, #059669);
    color: #fff; font-weight: 600; transition: all 0.2s;
}
.radreport-btn-apply-all:hover { background: linear-gradient(135deg, #16a34a, #047857); }

.radreport-btn-close {
    background: none; border: none; cursor: pointer; padding: 0.25rem;
    color: #64748b; border-radius: 0.5rem; transition: all 0.2s;
}
.radreport-btn-close:hover { color: #0f172a; background: #f1f5f9; }

/* Spin */
.radreport-spin { animation: radreport-spin 1s linear infinite; }
@keyframes radreport-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ========== Suggestions Panel ========== */
.radreport-suggestions-panel { display: flex; flex-direction: column; }

/* Category Tabs */
.radreport-category-tabs { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 0.5rem; }
.radreport-cat-tab {
    padding: 0.375rem 0.75rem; border: none; border-radius: 9999px;
    font-size: 0.75rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s;
}
.radreport-cat-tab.active { color: #fff; }

.radreport-cat-tab-all { background: #f3e8ff; color: #7c3aed; }
.radreport-cat-tab-all:hover { background: #e9d5ff; }
.radreport-cat-tab-all.active { background: #a855f7; color: #fff; }

.radreport-cat-tab-spelling { background: #dbeafe; color: #2563eb; }
.radreport-cat-tab-spelling:hover { background: #bfdbfe; }
.radreport-cat-tab-spelling.active { background: #3b82f6; color: #fff; }

.radreport-cat-tab-grammar { background: #dcfce7; color: #16a34a; }
.radreport-cat-tab-grammar:hover { background: #bbf7d0; }
.radreport-cat-tab-grammar.active { background: #22c55e; color: #fff; }

.radreport-cat-tab-style { background: #fef9c3; color: #a16207; }
.radreport-cat-tab-style:hover { background: #fef08a; }
.radreport-cat-tab-style.active { background: #eab308; color: #fff; }

.radreport-cat-tab-semantic { background: #fee2e2; color: #dc2626; }
.radreport-cat-tab-semantic:hover { background: #fecaca; }
.radreport-cat-tab-semantic.active { background: #ef4444; color: #fff; }

/* Suggestions List */
.radreport-suggestions-list {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.radreport-suggestions-empty {
    display: flex; align-items: center; justify-content: center;
    min-height: 12rem; text-align: center;
}
.radreport-suggestions-empty p { color: #94a3b8; font-size: 0.875rem; margin: 0; }

/* Suggestion Card */
.radreport-suggestion-card {
    padding: 1rem; border-radius: 0.5rem;
    border: 1px solid #e2e8f0; background: #f8fafc;
    transition: all 0.2s;
}
.radreport-suggestion-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-color: #cbd5e1; }
.radreport-suggestion-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.radreport-suggestion-actions { display: flex; gap: 0.25rem; }
.radreport-sug-accept, .radreport-sug-dismiss {
    width: 1.5rem; height: 1.5rem; border: none; border-radius: 0.25rem;
    cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; justify-content: center;
    background: transparent; transition: all 0.15s;
}
.radreport-sug-accept { color: #22c55e; }
.radreport-sug-accept:hover { background: rgba(34,197,94,0.15); }
.radreport-sug-dismiss { color: #ef4444; }
.radreport-sug-dismiss:hover { background: rgba(239,68,68,0.15); }

/* Category Badge */
.radreport-cat-badge {
    display: inline-block; padding: 0.125rem 0.5rem; border-radius: 9999px;
    font-size: 0.6875rem; font-weight: 600; text-transform: capitalize; color: #fff;
}
.radreport-cat-badge-spelling { background: #3b82f6; }
.radreport-cat-badge-grammar { background: #22c55e; }
.radreport-cat-badge-style { background: #eab308; }
.radreport-cat-badge-semantic { background: #ef4444; }

/* Suggestion Change */
.radreport-suggestion-change { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.8125rem; margin-bottom: 0.375rem; }
.radreport-sug-issue { text-decoration: line-through; color: #dc2626; }
.radreport-sug-arrow { color: #94a3b8; }
.radreport-sug-fix { font-weight: 500; color: #16a34a; }
.radreport-sug-explanation { font-size: 0.8125rem; color: #64748b; margin: 0; }

/* Apply All Wrap */
.radreport-apply-all-wrap { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #e2e8f0; }

/* ========== Highlight Tooltip ========== */
.radreport-highlight-tooltip {
    position: absolute; z-index: 999999;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 0.75rem;
    width: 300px; max-width: 90vw; pointer-events: auto;
}
.radreport-ht-header { margin-bottom: 0.5rem; }
.radreport-ht-badge {
    display: inline-block; padding: 0.125rem 0.5rem; border-radius: 9999px;
    font-size: 0.6875rem; font-weight: 600; text-transform: capitalize; color: #fff;
}
.radreport-ht-badge-spelling { background: #3b82f6; }
.radreport-ht-badge-grammar { background: #22c55e; }
.radreport-ht-badge-style { background: #eab308; }
.radreport-ht-badge-semantic { background: #ef4444; }
.radreport-ht-body { margin-bottom: 0.75rem; }
.radreport-ht-change { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.8125rem; margin-bottom: 0.375rem; }
.radreport-ht-issue { text-decoration: line-through; color: #dc2626; }
.radreport-ht-arrow { color: #94a3b8; }
.radreport-ht-suggestion { font-weight: 500; color: #16a34a; }
.radreport-ht-explanation { font-size: 0.8125rem; color: #64748b; margin: 0; }
.radreport-ht-actions { display: flex; gap: 0.375rem; }
.radreport-ht-arrow-pointer {
    position: absolute; width: 0.75rem; height: 0.75rem;
    background: #fff; border-left: 1px solid #e2e8f0; border-top: 1px solid #e2e8f0;
    transform: translateX(-50%) rotate(45deg); left: 50%;
    z-index: -1;
}

/* ========== Modal (shared) ========== */
.radreport-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 99999; padding: 1rem;
}
.radreport-modal-content {
    background: #fff; border-radius: 0.75rem;
    padding: 2rem; max-width: 42rem; width: 100%;
    max-height: 85vh; overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.radreport-modal-wide { max-width: 48rem; }
.radreport-modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; }
.radreport-modal-title { font-size: 1.5rem; font-weight: 700; color: #0f172a; margin: 0 0 0.25rem; }
.radreport-title-purple { color: #7c3aed; }
.radreport-title-teal { color: #0d9488; }
.radreport-modal-body { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 2rem; }
.radreport-modal-field { display: flex; flex-direction: column; gap: 0.5rem; }
.radreport-modal-label { font-size: 0.8125rem; font-weight: 700; color: #475569; margin: 0; }
.radreport-modal-text { padding: 1rem; border-radius: 0.75rem; font-size: 0.8125rem; font-family: 'Courier New', monospace; }
.radreport-modal-text-original { background: #fef2f2; border-left: 4px solid #ef4444; }
.radreport-modal-text-corrected { background: #f0fdf4; border-left: 4px solid #22c55e; }
.radreport-modal-text-explanation { background: #f8fafc; border-left: 4px solid #a855f7; font-family: inherit; }
.radreport-modal-footer { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: flex-end; border-top: 1px solid #e2e8f0; padding-top: 1.5rem; }

/* Modal Loading */
.radreport-modal-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 0; }
.radreport-modal-loading p { color: #0f172a; font-weight: 500; margin: 0; }
.radreport-loading-icon { padding: 1.5rem; border-radius: 50%; margin-bottom: 1rem; }
.radreport-loading-purple { background: #f5f3ff; color: #7c3aed; }
.radreport-loading-teal { background: #f0fdfa; color: #0d9488; }

/* Modal Empty */
.radreport-modal-empty { text-align: center; padding: 4rem 0; color: #64748b; }
.radreport-modal-empty svg { margin: 0 auto 1rem; }
.radreport-modal-empty p { margin: 0; }

/* ========== Tips ========== */
.radreport-tips-box {
    background: #f0fdfa; border-left: 4px solid #0d9488;
    padding: 1.5rem; border-radius: 0.75rem; margin-bottom: 2rem;
}
.radreport-tips-text { white-space: pre-wrap; font-size: 0.8125rem; color: #0f172a; line-height: 1.7; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .radreport-wrapper { padding: 0.5rem; }
    .radreport-title { font-size: 1.5rem; }
    .radreport-header-row { flex-direction: column; align-items: flex-start; }
    .radreport-editor { min-height: 20rem; }
    .radreport-controls-row { flex-direction: column; }
    .radreport-options-box { width: 100%; }
    .radreport-editor-footer { flex-direction: column; align-items: stretch; }
    .radreport-footer-right { justify-content: flex-end; }
    .radreport-modal-content { padding: 1.25rem; border-radius: 0.75rem; }
    .radreport-modal-footer { flex-direction: column; }
    .radreport-modal-footer .radreport-btn { width: 100%; }
    .radreport-category-tabs { gap: 0.25rem; }
    .radreport-cat-tab { font-size: 0.6875rem; padding: 0.25rem 0.5rem; }
}
