.program-mapping-container {
    margin: 20px 0;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;
}

.program-mapping-spreadsheet {
    min-height: 300px;
    border: 1px solid #ddd;
}

/* jspreadsheet 커스텀 스타일 */
.jexcel > thead > tr > td {
    background-color: #f8f9fa;
    font-weight: bold;
}

.jexcel > tbody > tr > td {
    padding: 8px;
    vertical-align: middle;
}

.jexcel > tbody > tr > td[data-column="3"] {  /* is_active 컬럼 */
    text-align: center;
}

.jexcel > tbody > tr:hover > td {
    background-color: #f5f5f5;
}

.program-mapping-widget {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.mapping-container {
    width: 100%;
    position: relative;
}

.toggle-units-btn,
.toggle-textbooks-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
}

.toggle-units-btn.sticky,
.toggle-textbooks-btn.sticky {
    position: fixed;
    top: 20px;
}

.toggle-units-btn:hover,
.toggle-textbooks-btn:hover {
    background: #f0f7ff;
    border-color: #90caf9;
}

.units-container {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 250px;
    height: 60vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    cursor: move;
    -webkit-user-select: none;
    user-select: none;
}

.units-container.visible {
    display: flex;
}

.units-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    cursor: move;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.units-header h3 {
    font-size: 0.95rem;
    margin: 0;
}

.close-units-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-units-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.search-container {
    padding: 0.75rem 1rem;
    position: relative;
    border-bottom: 1px solid #e0e0e0;
}

.search-container input {
    font-size: 1rem;
    padding: 0.3rem 0.5rem;
    ::placeholder {
        color: #999999;
    }
}

.unit-search {
    width: 100%;
    padding: 0.5rem;
    padding-right: 2rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.unit-search:focus {
    outline: none;
    border-color: #90caf9;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.search-icon {
    position: absolute;
    right: 2.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

h3 {
    color: #333;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.units-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: #f8f9fa;
}

.no-results {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    text-align: center;
    width: 100%;
    padding: 1rem;
}

.unit-item {
    padding: 0.5rem;
    margin: 0.4rem 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    cursor: move;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.unit-item:hover {
    background: #f0f7ff;
    border-color: #90caf9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.unit-item.dragging {
    opacity: 0.5;
    background: #e3f2fd;
}

.unit-item.hidden {
    display: none;
}

.unit-thumbnail {
    width: 36px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.unit-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 유닛 목록 썸네일 플레이스홀더 */
.unit-thumbnail .thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.unit-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.textbook-name {
    color: #666;
    font-size: 0.75em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unit-name {
    color: #333;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mapping-grid {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.grid-header, .grid-row {
    display: grid;
    grid-template-columns: 100px repeat(7, 1fr);
    width: 100%;
    min-width: 0;
}

.grid-cell {
    padding: 0.5rem;
    border: 1px solid #eeeeee;
    text-align: center;
    min-height: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fafafa;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.header {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.weekday {
    background: #f8f9fa;
}

.weekend {
    background-color: #fff3f3;
}

.week-number {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.drop-zone {
    width: 100%;
    height: 100%;
    min-height: 80px;
    max-height: 80px;
    padding: 0.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.drop-zone.dragover {
    background-color: #ebf5ff;
    border: 1px dashed #4dabf7;
}

/* 요일 헤더 dragover 스타일 */
.grid-cell.weekday.dragover {
    background-color: #e3f2fd;
    border: 1px dashed #42a5f5;
    cursor: copy;
}

.mapped-unit {
    padding: 0;
    margin: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 70px;
    max-height: 70px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    overflow: hidden;
}

.mapped-unit:hover {
    border-color: #90caf9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mapped-unit .unit-thumbnail {
    width: 36px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mapped-unit .unit-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 이미지 플레이스홀더 스타일 */
.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 4px;
}

/* 다양한 색상 변형 (유닛 ID 기반으로 선택 가능) */
.thumbnail-placeholder.color-1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.thumbnail-placeholder.color-2 {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.thumbnail-placeholder.color-3 {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.thumbnail-placeholder.color-4 {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.thumbnail-placeholder.color-5 {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.thumbnail-placeholder.color-6 {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #555;
}

.mapped-unit .unit-info {
    flex-grow: 1;
    min-width: 0;
    max-width: calc(100% - 40px); /* 썸네일 너비와 간격 고려 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    text-align: left;
    padding-right: 0.5rem;
    overflow: hidden;
}

.mapped-unit .textbook-name {
    color: #666;
    font-size: 0.75em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
    max-width: 100%;
}

.mapped-unit .unit-name {
    color: #333;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mapped-unit .remove-mapping {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(0,0,0,0.1);
    color: #666;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 1;
}

.mapped-unit .remove-mapping:hover {
    background: rgba(0,0,0,0.2);
    color: #333;
    transform: scale(1.1);
}

.weekend .mapped-unit {
    background: #fff;
    border-color: #ffcdd2;
}

.weekend .mapped-unit:hover {
    background: #fff5f5;
    border-color: #ef9a9a;
}

.drop-zone {
    margin-bottom: 0 !important;
}
.w-form-width {
    max-width: 100% !important;
}
#panel-program_mappings-content .w-field__wrapper {
    max-width: 100% !important;
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
}

.loading-indicator .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #d32f2f;
    text-align: center;
    padding: 1rem;
}
.mapping-grid .grid-header {
    background-color: var(--w-color-secondary);
    height: 60px;
    display: grid;
    grid-template-columns: 100px repeat(7, 1fr);
    align-items: center;
    width: 100%;
}

.mapping-grid .grid-cell.header {
    background-color: var(--w-color-secondary);
    border-top: 0px;
    border-bottom: 0px;
    border-left: 0.5px solid rgba(255, 255, 255, 0.5);
    border-right: 0.5px solid rgba(255, 255, 255, 0.5);
    font-weight: 600;
    color: white;
    height: 60px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.grid-cell.drop-zone {
    background-color: #ffffff;
}

.grid-cell.drop-zone.weekend {
    background-color: #fff8f8;
}

.mapping-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.controls-left {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.buttons-group {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.week-controls {
    display: flex;
    gap: 0.5rem;
}

.add-week-btn,
.remove-week-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-week-btn:hover {
    background: #e8f5e9;
    border-color: #81c784;
}

.remove-week-btn:hover {
    background: #ffebee;
    border-color: #e57373;
}

.add-week-btn svg,
.remove-week-btn svg {
    width: 16px;
    height: 16px;
}

.controls-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.save-mapping-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-mapping-btn:hover {
    background: #e3f2fd;
    border-color: #64b5f6;
    color: #1976d2;
}

.save-mapping-btn svg {
    width: 16px;
    height: 16px;
}

.save-mapping-btn.saving {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* 저장 성공/실패 알림 스타일 */
.mapping-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem;
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.mapping-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.mapping-notification.success {
    background: #4caf50;
}

.mapping-notification.error {
    background: #f44336;
}

.mapping-notification.warning {
    background: #ff9800;
}

.mapping-notification.info {
    background: #2196f3;
}

.mapped-unit .unit-content {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    height: 100%;
    padding: 0.2rem;
    transition: all 0.2s ease;
    overflow: hidden;
}

.mapped-unit .unit-content:hover {
    background: #f5f5f5;
    border-radius: 4px;
}

.mapped-unit .unit-content:active {
    background: #e3f2fd;
}

/* 교재 컨테이너 스타일 */
.textbooks-container {
    position: fixed;
    top: 50%;
    right: 20px; /* 왼쪽이 아닌 오른쪽에 배치 (유닛 컨테이너와 동일) */
    transform: translateY(-50%);
    width: 250px; /* 유닛 컨테이너와 동일한 너비 */
    height: 60vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    cursor: move;
    -webkit-user-select: none;
    user-select: none;
}

.textbooks-container.visible {
    display: flex;
}

.textbooks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    cursor: move;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.textbooks-header h3 {
    font-size: 0.95rem;
    margin: 0;
}

.close-textbooks-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-textbooks-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.textbooks-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: #f8f9fa;
}

.textbook-item {
    padding: 0.7rem;
    margin: 0.5rem 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    cursor: move;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.textbook-item:hover {
    background: #f0f7ff;
    border-color: #90caf9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.textbook-item.dragging {
    opacity: 0.5;
    background: #e3f2fd;
}

.textbook-item.hidden {
    display: none;
}

.textbook-thumbnail {
    width: 50px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.textbook-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 교재 썸네일 플레이스홀더 */
.textbook-thumbnail .thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.textbook-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.textbook-name {
    color: #333;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.textbook-description {
    color: #666;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.textbook-units-count {
    color: #2196F3;
    font-size: 0.75rem;
    font-weight: 500;
}

/* 버튼 그룹 스타일 */
.buttons-group {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.toggle-textbooks-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
}

.toggle-textbooks-btn.sticky {
    position: fixed;
    top: 20px;
}

.toggle-textbooks-btn:hover {
    background: #f0f7ff;
    border-color: #90caf9;
}

/* 선택된 유닛 스타일 */
.mapped-unit.selected {
    outline: 3px solid #2196f3;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(33, 150, 243, 0.2);
    background: linear-gradient(135deg, #e3f2fd 0%, #fff 100%);
    position: relative;
}

.mapped-unit.selected::before {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: rgba(33, 150, 243, 0.9);
    color: white;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

/* 모두 선택 버튼 스타일 */
.select-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.select-all-btn:hover {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1976d2;
}

.select-all-btn svg {
    width: 16px;
    height: 16px;
}

/* 선택 삭제 버튼 스타일 */
.delete-selected-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.delete-selected-btn:hover {
    background: #ffebee;
    border-color: #f44336;
    color: #d32f2f;
}

.delete-selected-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.delete-selected-btn:disabled:hover {
    background: #f5f5f5;
    border-color: #ddd;
    color: #999;
}

.delete-selected-btn svg {
    width: 16px;
    height: 16px;
}

/* 알림 타입별 스타일 */
.mapping-notification.warning {
    background: #ff9800;
}

.mapping-notification.info {
    background: #2196f3;
}

.mapping-notification.success {
    background: #4caf50;
}

.mapping-notification.error {
    background: #f44336;
}
/* 유닛 툴팁 스타일 */
.unit-tooltip {
    position: fixed;
    z-index: 10000;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 200px;
    max-width: 300px;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    font-size: 13px;
}

.unit-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-header {
    padding: 10px 14px;
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
}

.tooltip-header strong {
    font-weight: 600;
}

.tooltip-body {
    padding: 12px 14px;
}

.tooltip-row {
    display: flex;
    margin-bottom: 8px;
}

.tooltip-row:last-child {
    margin-bottom: 0;
}

.tooltip-label {
    color: #666;
    font-weight: 500;
    min-width: 50px;
    flex-shrink: 0;
}

.tooltip-value {
    color: #333;
    word-break: break-word;
}

.tooltip-footer {
    padding: 8px 14px;
    background: #f5f5f5;
    border-radius: 0 0 8px 8px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #888;
    text-align: center;
}
