/* ==================== type-manager.css ==================== */
/* 교재제작 화면과 동일한 레이아웃 스타일 */

/* 화면 전체 레이아웃 */
#typeManagerScreen {
    width: 100%;
    height: 100vh;
}

#typeManagerScreen.active {
    display: flex;
}

/* ========== 좌측 사이드바 (교재제작과 동일) ========== */
#typeManagerScreen .sidebar {
    width: 260px;
    background: var(--menu-bg);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: background-color 0.3s ease;
}

#typeManagerScreen .sidebar-header {
    padding: 18px;
    background: var(--primary);
    color: white;
    transition: background-color 0.3s ease;
}

#typeManagerScreen .sidebar-header h2 {
    font-size: 18px;
    margin: 0;
}

#typeManagerScreen .sidebar-content {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ========== 가운데 작업 영역 (교재제작과 동일) ========== */
#typeManagerScreen .main-content {
    flex: 1;
    padding: 20px;
    overflow: hidden; /* 스크롤은 내부 요소에서 처리 */
    display: flex;
    gap: 16px;
    min-height: 0; /* flex 아이템이 부모를 넘지 않도록 */
    align-items: stretch; /* 자식 요소들이 같은 높이를 가지도록 */
    max-height: 100vh; /* 화면 높이를 넘지 않도록 제한 */
    position: relative; /* 자식 요소 absolute 배치용 */
}

#typeManagerScreen .calendar-section {
    flex: 1;
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 0; /* flex 아이템이 부모를 넘지 않도록 */
}




/* ========== 우측 패널 (빌드업과 동일) ========== */
#typeManagerScreen .items-section {
    width: 260px;
    background: var(--white);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
}

/* ========== 학생 목록 (사이드바 내부) ========== */
.type-student-list {
    flex: 1;
    overflow-y: auto;
}

.type-student-item {
    padding: 10px 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.type-student-item:hover {
    background: var(--surface-muted);
    border-color: var(--primary);
}

.type-student-item.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.type-student-item.selected .student-name,
.type-student-item.selected .student-info {
    color: white;
}

.type-student-item .student-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.type-student-item .student-info {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========== 학년 목록 (편집툴 모드용) ========== */
.type-grade-item {
    padding: 10px 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.type-grade-item:hover {
    background: var(--surface-muted);
    border-color: var(--primary);
}

.type-grade-item.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.type-grade-item.selected .grade-name {
    color: white;
    font-weight: 600;
}

.type-grade-item .grade-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

/* ========== 작업 영역 헤더 ========== */
.type-work-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--subtle);
    flex-shrink: 0;
}

.type-work-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.type-student-badge {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    padding: 8px 16px;
    background: var(--surface);
    border-radius: 8px;
}

/* ========== 3열 그리드 ========== */
.type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ========== 유형 섹션 ========== */
.type-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

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

.type-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.type-section-count {
    font-size: 11px;
    color: var(--text-muted);
}

.type-section textarea {
    flex: 1;
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    font-family: '맑은 고딕', 'Malgun Gothic', 'Segoe UI', sans-serif;
    line-height: 1.7;
    background: var(--surface);
    color: #333;
    transition: all 0.2s;
    resize: none;
    overflow-y: auto;
    min-height: 0;
}

.type-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(106, 59, 255, 0.1);
}

.type-section-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.type-section-footer button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.type-section-footer button:first-child {
    background: #E8F5E9;
    color: #2E7D32;
}

.type-section-footer button:first-child:hover {
    background: #C8E6C9;
    transform: translateY(-1px);
}

.type-section-footer button:last-child {
    background: #FFEBEE;
    color: #C62828;
}

.type-section-footer button:last-child:hover {
    background: #FFCDD2;
    transform: translateY(-1px);
}

/* ========== 우측 패널 헤더 ========== */
.items-header {
    font-size: 16px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--subtle);
}

.items-header p {
    font-size: 11px;
    color: var(--text-muted);
    margin: 4px 0 0 0;
    font-weight: 400;
}

/* ========== 시중교재 아이템 ========== */
.type-textbook-list {
    flex: 1;
    overflow-y: auto;
}

.type-textbook-item {
    padding: 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.type-textbook-item .textbook-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.type-textbook-item .textbook-count {
    font-size: 11px;
    color: var(--text-muted);
}

.type-textbook-item .textbook-info {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.type-textbook-item .textbook-action {
    font-size: 18px;
    opacity: 0.6;
}

.type-textbook-item:hover .textbook-action {
    opacity: 1;
}

/* ========== 아코디언 스타일 ========== */
.student-accordion-group {
    margin-bottom: 8px;
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.accordion-header:hover {
    background: var(--surface-muted);
}

.accordion-icon {
    font-size: 12px;
    color: var(--text-muted);
}

.accordion-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

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

/* ========== 사이드바 푸터 ========== */
#typeManagerScreen .sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.btn-type-editor-tool {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-type-editor-tool:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-type-editor-tool.active {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(106, 59, 255, 0.3);
}

/* ========== 유형편집툴 모드 ========== */
#typeEditorToolMode {
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    overflow: hidden;
    flex-direction: column;
}

#typeEditorToolMode .editor-tool-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    align-items: stretch;
    overflow: hidden;
}

.editor-tool-left,
.editor-tool-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.editor-tool-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

.editor-tool-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: block;
}

.editor-tool-stats {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.editor-tool-textarea {
    flex: 1;
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
    background: var(--surface);
    color: #333;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.editor-tool-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(106, 59, 255, 0.1);
}

.btn-parse-curriculum {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-parse-curriculum:hover {
    background: var(--primary-dark);
}

.btn-toggle-editor-tool {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 110px;
    text-align: center;
}

.btn-toggle-editor-tool:hover {
    background: var(--primary-dark);
}

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

.editor-tool-header-label-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-tool-actions {
    display: flex;
    gap: 8px;
}

.btn-select-action {
    padding: 6px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-select-action:hover {
    background: var(--surface-muted);
    border-color: var(--primary);
}

.editor-tool-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    min-height: 0;
}

.editor-tool-empty-state {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.editor-tool-tree-item {
    margin-bottom: 4px;
}

.editor-tool-tree-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    user-select: none;
}

.editor-tool-tree-item-label:hover {
    background: var(--surface-muted);
}

.editor-tool-tree-item-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.editor-tool-tree-item-label .tree-icon {
    font-size: 12px;
    color: var(--text-muted);
    width: 16px;
    text-align: center;
    cursor: pointer;
}

.editor-tool-tree-item-label .tree-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.editor-tool-tree-item-label.major .tree-text {
    font-weight: 700;
    color: var(--primary);
}

.editor-tool-tree-item-label.middle .tree-text {
    font-weight: 600;
}

.editor-tool-tree-item-label.minor .tree-text {
    font-weight: 400;
}

.editor-tool-tree-item-label.type {
    padding-left: 20px;
}

.editor-tool-tree-item-label.type .tree-text {
    font-weight: 400;
    font-size: 12px;
    color: var(--text-muted);
}

.editor-tool-tree-children {
    margin-left: 24px;
    margin-top: 4px;
    border-left: 2px solid var(--border);
    padding-left: 8px;
}

.editor-tool-footer {
    display: flex;
    justify-content: flex-end;
}

.btn-copy-selected {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy-selected:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-copy-selected:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}