/* ============================================================
   AEO 콘텐츠 검사기 — 공통 + 결과 페이지 스타일
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100%;
}

/* ============================================================
   RESULT PAGE — 최상위 2열 Grid
   (_nav.html 고정 헤더 70px 만큼 상단 여백을 두고, 화면보다 콘텐츠가
    길어지면 body 스크롤로 자연스럽게 넘어가도록 height 대신 min-height 사용)
   ============================================================ */

.dashboard-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr;
    gap: 16px;
    min-height: calc(100vh - 140px);
    margin: 100px 0 40px;
    padding: 16px;
}

.col-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.row-score {
    flex: 0 0 auto;
    max-height: 24vh;
    overflow-y: auto;
    padding: 14px 20px;
}

/* row-editor: 남은 공간 전부 + 에디터 flex 체인의 시작점 */
.row-editor {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.col-sidebar {
    overflow-y: auto;
    min-height: 0;
    padding: 20px;
}

.box {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* ============================================================
   점수 영역
   ============================================================ */

.score-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    height: 100%;
}

.score-display {
    flex: 0 0 150px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 4px;
}

.score-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #9ca3af;
    margin-bottom: 6px;
}

.score-number-wrap {
    display: flex;
    align-items: baseline;
    gap: 3px;
    line-height: 1;
}

#final-score {
    font-size: 50px;
    font-weight: 900;
    color: #2563eb;
    transition: color 0.8s ease;
}

.score-unit {
    font-size: 18px;
    font-weight: 600;
    color: #6b7280;
}

#final-score.grade-high { color: #059669; }
#final-score.grade-mid  { color: #d97706; }
#final-score.grade-low  { color: #dc2626; }

.score-bar-wrap {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin-top: 12px;
    overflow: hidden;
}

.score-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb 0%, #06b6d4 100%);
    border-radius: 4px;
    transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.score-bar.grade-high { background: linear-gradient(90deg, #059669, #34d399); }
.score-bar.grade-mid  { background: linear-gradient(90deg, #d97706, #fbbf24); }
.score-bar.grade-low  { background: linear-gradient(90deg, #dc2626, #f87171); }

.score-sub {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
}

.score-divider {
    flex: 0 0 1px;
    align-self: stretch;
    background: #f3f4f6;
    margin: 0 4px;
}

.rationale-wrap {
    flex: 1 1 0;
    min-width: 0;
    overflow-y: auto;
}

.rationale-title {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.title-icon { font-size: 15px; }

.rationale-text {
    font-size: 13.5px;
    line-height: 1.85;
    color: #4b5563;
    white-space: pre-wrap;
    word-break: keep-all;
}

/* ============================================================
   에디터 헤더
   ============================================================ */

.editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.editor-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
}

.editor-badge {
    padding: 2px 10px;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.editor-badge.badge-wysiwyg {
    background: #f5f3ff;
    color: #7c3aed;
    border-color: #ddd6fe;
}


/* ============================================================
   에디터 모드 토글 버튼
   ============================================================ */

.editor-mode-toggle {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.mode-btn {
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    border: 1.5px solid #d1d5db;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.mode-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.mode-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* ============================================================
   에디터 컨테이너 — TinyMCE 플렉스 체인
   ============================================================ */

#result-editor {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#tinymce-editor-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* TinyMCE는 textarea 옆에 .tox-tinymce를 삽입 — flex 체인 연결 */
#tinymce-editor-wrap .tox.tox-tinymce {
    flex: 1 1 0;
    min-height: 0;
    border-radius: 8px;
    border-color: #e5e7eb;
}

#raw-code-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: none;
    flex-direction: column;
}

#raw-code-textarea {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    resize: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #1e293b;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
    outline: none;
    tab-size: 4;
}

#raw-code-textarea:focus {
    border-color: #2563eb;
    background: #fff;
}

/* ============================================================
   바로 수정 하이라이트 애니메이션
   ============================================================ */

@keyframes aeo-fix-applied {
    0%   { background-color: #fef9c3; outline: 2px solid #fde047; border-radius: 3px; }
    30%  { background-color: #dcfce7; outline: 2px solid #4ade80; border-radius: 3px; }
    70%  { background-color: #bbf7d0; outline: 2px solid #86efac; border-radius: 3px; }
    100% { background-color: transparent; outline: 2px solid transparent; }
}

.aeo-fix-highlight {
    animation: aeo-fix-applied 1.5s ease forwards;
    border-radius: 3px;
}

@keyframes aeoModalIn {
    from { opacity: 0; transform: scale(0.92) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   사이드바
   ============================================================ */

.sidebar-title {
    font-size: 16px;
    font-weight: 800;
    color: #111827;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}

.fix-section { margin-bottom: 24px; }

.fix-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
}

.fix-icon { font-size: 14px; }

.fix-subtitle {
    font-size: 10px;
    font-weight: 400;
    color: #9ca3af;
    margin-left: auto;
}

.text-warning { color: #d97706; }
.text-primary  { color: #2563eb; }

.fix-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fix-placeholder {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
    padding: 8px 0;
}

.manual-item {
    font-size: 12.5px;
    line-height: 1.65;
    color: #4b5563;
    padding: 10px 12px 10px 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid #d97706;
    border-radius: 6px;
    word-break: keep-all;
}

/* 바로 수정 버튼 */
.auto-fix-btn {
    width: 100%;
    text-align: left;
    padding: 11px 13px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 3px solid #2563eb;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.18s, transform 0.18s;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.auto-fix-btn:hover:not(:disabled) {
    background: #dbeafe;
    border-color: #93c5fd;
    transform: translateX(3px);
}

.auto-fix-btn:disabled {
    background: #f0fdf4;
    border-color: #86efac;
    border-left-color: #059669;
    cursor: not-allowed;
    transform: none;
    opacity: 0.85;
}

.auto-fix-btn .btn-icon {
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 1px;
}

.auto-fix-btn .btn-body { flex: 1; min-width: 0; }

.auto-fix-btn .btn-title {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: #1d4ed8;
    margin-bottom: 4px;
}

.auto-fix-btn:disabled .btn-title { color: #166534; }

.auto-fix-btn .btn-preview {
    display: block;
    font-size: 11px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auto-fix-btn:disabled .btn-preview { display: none; }

.btn-penalty {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    color: #059669;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 2px 7px;
    white-space: nowrap;
    align-self: center;
}

.auto-fix-btn:disabled .btn-penalty { display: none; }

/* AI 항목 구분 배지 */
.btn-ai-badge {
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 700;
    color: #7c3aed;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    padding: 1px 6px;
    white-space: nowrap;
    align-self: center;
}

.auto-fix-btn:disabled .btn-ai-badge { display: none; }

/* ============================================================
   모바일 대응 — 2열 그리드를 1열로 쌓기
   ============================================================ */

@media (max-width: 768px) {
    .dashboard-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        min-height: auto;
        margin: 90px 0 32px;
        padding: 12px;
        gap: 12px;
    }

    .col-main { min-height: 0; }

    .row-score {
        max-height: none;
        padding: 14px 16px;
    }

    .row-editor {
        min-height: 460px;
        padding: 14px;
    }

    .col-sidebar {
        max-height: none;
        padding: 16px;
    }

    .editor-header { flex-wrap: wrap; row-gap: 8px; }
    .editor-mode-toggle { margin-left: 0; }
}

@media (max-width: 480px) {
    .score-layout { flex-direction: column; align-items: stretch; }
    .score-display { flex: 0 0 auto; padding-top: 0; }
    .score-divider { width: 100%; height: 1px; flex: 0 0 1px; margin: 4px 0; }
    .mode-btn { padding: 5px 10px; font-size: 11.5px; }
}
