/* ==================== 진단시스템 화면 스타일 ==================== */

/* 진단 사이드바 섹션 */
.sidebar-section {
    margin-bottom: 18px;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--menu-text);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 북마클릿 사용 안내 */
.bookmark-help-text {
    background: #FFF9E6;
    border: 1px solid #FFE8A3;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    font-size: 11px;
    line-height: 1.6;
}

.bookmark-help-text p {
    margin: 0;
    margin-bottom: 6px;
    color: #8B7355;
}

.bookmark-help-text p:last-child {
    margin-bottom: 0;
}

.bookmark-help-text strong {
    color: var(--primary);
    font-weight: 700;
}

/* 사이드바 구분선 */
.sidebar-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--menu-primary), transparent);
    margin: 16px 0 18px 0;
    opacity: 0.3;
}

.sidebar-bookmark-btn {
    display: block;
    width: 100%;
    padding: 11px;
    background: var(--primary);
    color: white;
    text-align: center;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: grab;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(106, 59, 255, 0.2);
    margin-top: 14px;
    margin-bottom: 4px;
}

.sidebar-bookmark-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(106, 59, 255, 0.3);
}

.sidebar-bookmark-btn:active {
    cursor: grabbing;
}

/* ==================== ✅ 진단시스템 내부 레이아웃 ==================== */

/* 진단 그리드 - 좌우 2분할 (1:1 비율) - 항상 고정! */
.diagnosis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr !important;
    gap: 16px;
    align-items: stretch;
}

/* 진단 섹션 */
.diagnosis-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 섹션 헤더 */
.diagnosis-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.section-title-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

/* 섹션 언더라인 */
.section-divider {
    height: 2px;
    background: linear-gradient(to right, var(--primary), transparent);
    margin-bottom: 16px;
    border-radius: 1px;
    flex-shrink: 0;
}

/* 섹션 콘텐츠 */
.diagnosis-section-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    min-height: 0;
}

/* ==================== ✅ 이름/날짜 표시 영역 ==================== */
.diagnosis-info-display {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text);
    min-height: 36px;
}

.diagnosis-info-name {
    font-weight: 700;
    color: var(--primary);
    font-size: 16px;
}

.diagnosis-info-date {
    color: var(--text-muted);
    font-size: 13px;
}

.diagnosis-info-date::before {
    content: "📅 ";
    opacity: 0.7;
}

/* ==================== 입력 테이블 ==================== */

.diagnosis-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.diagnosis-table th {
    background: var(--primary);
    color: white;
    padding: 9px 6px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
}

.diagnosis-table th:first-child {
    border-radius: 8px 0 0 8px;
}

.diagnosis-table th:last-child {
    border-radius: 0 8px 8px 0;
}

.diagnosis-table td {
    padding: 9px 6px;
    text-align: center;
    border-right: 1px solid var(--border);
    font-size: 12px;
}

.diagnosis-table td:last-child {
    border-right: none;
}

.diagnosis-table tr:first-child td {
    font-weight: 600;
    color: var(--text);
    background: var(--subtle);
}

.diagnosis-table input[type="number"] {
    width: 100%;
    padding: 7px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s;
    font-weight: 500;
}

.diagnosis-table input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(106, 59, 255, 0.15);
}

/* ==================== KPI 카드 (3개) ==================== */

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.result-box {
    background: var(--menu-primary);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    color: white;
}

.result-box.info {
    background: var(--primary);
}

.result-label {
    font-size: 11px;
    margin-bottom: 4px;
    opacity: 0.9;
}

.result-value {
    font-size: 32px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1.2;
}

/* Level Display에 스타일 추가 */
.level-stage {
    font-size: 14px;
    opacity: 0.85;
    margin-left: 3px;
}

/* ==================== 정보 텍스트 ==================== */

.info-text {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 10px;
    padding: 8px;
    background: var(--surface-muted);
    border-radius: 6px;
    text-align: center;
    flex-shrink: 0;
}

.info-text span {
    font-weight: 700;
    color: var(--primary);
    font-size: 16px;
}

/* ==================== 차트 컨테이너 ==================== */

.ratio-display {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    flex: 1;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

.ratio-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    flex-shrink: 0;
}

#dRecChartArea {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 12px;
    flex: 1;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

/* ==================== 난이도 조정 버튼 ==================== */

.target-control {
    text-align: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.target-btn {
    padding: 6px 10px;
    margin: 0 2px;
    border-radius: 7px;
    border: 2px solid;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--white);
}

.target-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.target-btn.active {
    box-shadow: 0 0 0 3px rgba(106, 59, 255, 0.2);
}

.target-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.target-btn.decrease {
    border-color: #F87171;
    color: #DC2626;
}

.target-btn.decrease:hover:not(:disabled) {
    background: #FEE2E2;
    border-color: #DC2626;
}

.target-btn.decrease.active {
    background: #FEE2E2;
    border-color: #DC2626;
}

.target-btn.neutral {
    border-color: #64748B;
    color: #475569;
}

.target-btn.neutral:hover:not(:disabled) {
    background: #F1F5F9;
    border-color: #475569;
}

.target-btn.neutral.active {
    background: #F1F5F9;
    border-color: #475569;
}

.target-btn.increase {
    border-color: #34D399;
    color: #059669;
}

.target-btn.increase:hover:not(:disabled) {
    background: #D1FAE5;
    border-color: #059669;
}

.target-btn.increase.active {
    background: #D1FAE5;
    border-color: #059669;
}

/* ==================== 추천 영역 ==================== */

#dRecContent {
    flex: 1;
    background: var(--white);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
}

.recommend-section {
    background: var(--white);
    border-radius: 8px;
    padding: 14px;
}

.recommend-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 14px;
}

.recommend-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 12px;
}

.recommend-item {
    background: var(--surface-muted);
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
}

.recommend-item-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.recommend-item-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

/* ==================== 히스토리 섹션 ==================== */

.items-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.clear-input-btn {
    padding: 6px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.clear-input-btn:hover {
    background: var(--subtle);
    border-color: var(--primary);
    color: var(--primary);
}

.diagnosis-history-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

/* 학생별 그룹 */
.history-student {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-muted);
}

.history-student-header {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    background: var(--subtle);
    transition: background 0.2s;
}

.history-student-header:hover {
    background: var(--surface);
}

.history-student-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.history-student-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.history-student-count {
    font-size: 11px;
    color: var(--text-muted);
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 8px;
}

.history-student-toggle {
    font-size: 12px;
    color: var(--primary);
    transition: transform 0.2s;
}

.history-student.open .history-student-toggle {
    transform: rotate(180deg);
}

/* 기록 목록 */
.history-records {
    display: none;
    padding: 8px;
    background: white;
}

.history-student.open .history-records {
    display: block;
}

/* 개별 기록 */
.history-record-item {
    padding: 8px 10px;
    margin-bottom: 4px;
    background: var(--bg);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.history-record-item:last-child {
    margin-bottom: 0;
}

.history-record-item:hover {
    background: var(--subtle);
    border-color: var(--primary);
    transform: translateX(2px);
}

.history-record-date {
    font-size: 12px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-record-date::before {
    content: "📅";
    font-size: 10px;
}

.history-record-summary {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    gap: 8px;
}

.history-record-summary span {
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ✅ 선택된 히스토리 항목 */
.history-record-item.selected {
    background: var(--subtle) !important;
    border-color: var(--primary) !important;
    border-width: 2px !important;
    box-shadow: 0 0 0 3px rgba(106, 59, 255, 0.15);
}

.history-record-item.selected .history-record-date {
    color: var(--primary);
    font-weight: 700;
}

.history-record-item.selected:hover {
    background: var(--subtle) !important;
    border-color: var(--primary) !important;
}

/* ==================== ✅ 진단 히스토리 버튼 스타일 ==================== */

/* items-actions 기본 스타일 유지 */
.items-section .items-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--subtle);
}

/* ✅ 3개 버튼 가로 배치 - 강력한 우선순위 */
.items-section .items-actions .diagnosis-history-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px;
    margin-bottom: 0;
    width: 100%;
}

/* 각 버튼 스타일 */
.diagnosis-history-buttons .action-btn {
    flex: 1;
    padding: 8px 6px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

/* 저장 버튼 - 파란색 */
.diagnosis-history-buttons .action-btn.save {
    background: #F0F8FF;
    color: #4169E1;
}

.diagnosis-history-buttons .action-btn.save:hover {
    background: #E6F3FF;
}

/* 수정 버튼 - 보라색 (빌드업과 동일) */
.diagnosis-history-buttons .action-btn.edit {
    background: #E8E2F5;
    color: var(--primary);
}

.diagnosis-history-buttons .action-btn.edit:hover {
    background: #DDD5ED;
}

/* 삭제 버튼 - 빨간색 (빌드업과 동일) */
.diagnosis-history-buttons .action-btn.delete {
    background: #FFE8EA;
    color: #DC5F6F;
}

.diagnosis-history-buttons .action-btn.delete:hover {
    background: #FFD5D9;
}

/* 버튼 비활성화 상태 */
.diagnosis-history-buttons .action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.diagnosis-history-buttons .action-btn:disabled:hover {
    transform: none;
    background: inherit;
}

/* ==================== 🖨️ 출력 최적화 CSS - 진단기 전용 완전 독립 ==================== */

@media print {
    /* 📄 사이드바와 우측 패널 숨김 - 진단기만 */
    #diagnosisScreen .sidebar,
    #diagnosisScreen .items-section {
        display: none !important;
    }
    
    /* 📐 메인 콘텐츠 - 진단기만 */
    #diagnosisScreen .main-content {
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }
    
    /* 📦 캘린더 섹션 - 진단기만 */
    #diagnosisScreen .calendar-section {
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 16px !important;
        margin: 0 !important;
        page-break-inside: avoid !important;
        overflow: visible !important;
        max-height: none !important;
    }
    
    /* 📰 헤더 - 진단기만 */
    #diagnosisScreen .header {
        padding: 10px 0 !important;
        margin-bottom: 12px !important;
        border-bottom: 2px solid var(--border) !important;
    }
    
    #diagnosisScreen .school-title {
        font-size: 18pt !important;
        font-weight: 700 !important;
    }
    
    /* ✅ 학생 정보 출력 시 표시 */
    #diagnosisScreen .diagnosis-info-display {
        display: flex !important;
        font-size: 11pt !important;
        margin-top: 6px !important;
    }
    
    #diagnosisScreen .diagnosis-info-name {
        font-size: 13pt !important;
    }
    
    #diagnosisScreen .diagnosis-info-date {
        font-size: 10pt !important;
    }
    
    /* 📅 캘린더 컨테이너 - 진단기만 */
    #diagnosisScreen .calendar-container {
        overflow: visible !important;
    }
    
    /* 진단 그리드 */
    #diagnosisScreen .diagnosis-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10mm !important;
        margin-top: 8px !important;
    }
    
    /* 섹션 - flex 제거 */
    #diagnosisScreen .diagnosis-section {
        page-break-inside: avoid !important;
        flex: none !important;
    }
    
    #diagnosisScreen .diagnosis-section-header {
        margin-bottom: 8px !important;
    }
    
    #diagnosisScreen .section-badge {
        width: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
    }
    
    #diagnosisScreen .section-title-text {
        font-size: 13pt !important;
    }
    
    #diagnosisScreen .section-divider {
        margin-bottom: 10px !important;
    }
    
    /* 섹션 콘텐츠 - flex 제거 */
    #diagnosisScreen .diagnosis-section-content {
        flex: none !important;
        gap: 10px !important;
        overflow: visible !important;
    }
    
    /* 테이블 */
    #diagnosisScreen .diagnosis-table {
        font-size: 9pt !important;
        margin-bottom: 10px !important;
    }
    
    #diagnosisScreen .diagnosis-table th {
        padding: 5px 4px !important;
        font-size: 9pt !important;
    }
    
    #diagnosisScreen .diagnosis-table td {
        padding: 5px 4px !important;
        font-size: 9pt !important;
    }
    
    #diagnosisScreen .diagnosis-table input[type="number"] {
        border: 1px solid #ccc !important;
        padding: 3px !important;
        font-size: 9pt !important;
    }
    
    /* KPI */
    #diagnosisScreen .result-grid {
        gap: 8px !important;
        margin-bottom: 10px !important;
    }
    
    #diagnosisScreen .result-box {
        padding: 8px !important;
    }
    
    #diagnosisScreen .result-value {
        font-size: 22pt !important;
    }
    
    #diagnosisScreen .result-label {
        font-size: 8pt !important;
    }
    
    /* 정보 텍스트 */
    #diagnosisScreen .info-text {
        font-size: 10pt !important;
        padding: 6px !important;
        margin-bottom: 8px !important;
    }
    
    /* 차트 - 높이 250px, flex 제거 */
    #diagnosisScreen .ratio-display,
    #diagnosisScreen #dRecChartArea {
        flex: none !important;
        border: 1px solid #ddd !important;
        padding: 8px !important;
        min-height: 250px !important;
        max-height: 250px !important;
    }
    
    #diagnosisScreen .ratio-title {
        font-size: 10pt !important;
        margin-bottom: 6px !important;
    }
    
    #diagnosisScreen .ratio-display svg,
    #diagnosisScreen #dRecChartArea svg {
        max-height: 220px !important;
    }
    
    /* 추천 섹션 */
    #diagnosisScreen .recommend-section {
        padding: 10px !important;
        border: 1px solid #ddd !important;
    }
    
    #diagnosisScreen .recommend-title {
        font-size: 11pt !important;
        margin-bottom: 8px !important;
    }
    
    #diagnosisScreen .recommend-grid {
        gap: 4px !important;
    }
    
    #diagnosisScreen .recommend-item {
        padding: 6px 4px !important;
    }
    
    #diagnosisScreen .recommend-item-value {
        font-size: 16pt !important;
    }
    
    #diagnosisScreen .recommend-item-label {
        font-size: 8pt !important;
    }
    
    /* 버튼 숨김 */
    #diagnosisScreen .target-control {
        display: none !important;
    }
    
    /* 색상 보존 */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
/* 학생 리스트 스타일은 lists.css로 이동되었습니다. */

/* 2개 버튼 레이아웃 조정 */
.diagnosis-history-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

/* 히스토리 아이템 - 버튼 스타일 */
.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(106, 59, 255, 0.15);
}

.history-item.selected {
    background: #f0ebff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(106, 59, 255, 0.2);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-date {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 3px;
    color: var(--text);
}

.history-item-info {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

.history-item-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.history-item-actions button {
    flex: 1;
    padding: 6px 10px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-apply-btn {
    background: var(--primary);
    color: white;
}

.history-apply-btn:hover {
    background: var(--primary-dark);
}

.history-delete-btn {
    background: var(--surface);
    color: var(--text-muted);
}

.history-delete-btn:hover {
    background: #dc3545;
    color: white;
}/* ==================== 아코디언 스타일 (진단/교재제작/수납/성적 공통) ==================== */

.student-accordion-group {
    margin-bottom: 8px;
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 13px;
    user-select: none;
}

.accordion-header:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(106, 59, 255, 0.3);
}

.accordion-icon {
    font-size: 12px;
    transition: transform 0.2s;
    width: 14px;
    text-align: center;
}

.accordion-title {
    flex: 1;
}

.accordion-content {
    padding: 4px 0;
    display: block;
}

/* 체크박스 아이템 (아코디언 내부) */
.accordion-content .checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 4px 0;
}

.accordion-content .checkbox-item:hover {
    background: var(--surface-muted);
    border-color: var(--primary);
    transform: translateX(2px);
}

.accordion-content .checkbox-item.selected {
    background: var(--primary);
    border-color: var(--primary-dark);
    color: white;
}

.accordion-content .checkbox-item.selected .item-label {
    color: white;
}

.accordion-content .checkbox-item.selected .item-label > div {
    color: white !important;
}

.accordion-content .item-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.accordion-content .item-label {
    flex: 1;
    cursor: pointer;
}

/* 진단 화면용 학생 목록 (아코디언 없는 단순 리스트도 지원) */
.diagnosis-student-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}