/* --- 빌드 플래너 페이지 레이아웃 --- */
/* [신규] 모달 활성 시 배경 스크롤 방지 */
body.modal-open {
    overflow: hidden;
}

.planner-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.planner-sidebar {
    display: none; /* 기본 숨김 */
    flex: 0 0 320px;
    max-height: calc(100vh - 100px);
    flex-direction: column;
}

.planner-sidebar .filter-section {
    flex-shrink: 0;
}

.item-type-filter {
    display: flex;
    margin-top: 15px;
    background-color: #333;
    border-radius: 5px;
    overflow: hidden;
}

.item-type-filter input {
    display: none;
}

.item-type-filter label {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}

.item-type-filter label:hover {
    background-color: #444;
}

.item-type-filter input:checked+label {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

#item-sub-filter-container {
    margin-top: 10px;
}

.item-sub-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.item-sub-filter input {
    display: none;
}

.item-sub-filter label {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: 1px solid #555;
    background-color: #333;
    color: #ccc;
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.2s;
    user-select: none;
}

.item-sub-filter label:hover {
    background-color: #444;
}

.item-sub-filter input:checked+label {
    background-color: #555;
    border-color: #888;
    color: white;
}


#item-library-list {
    flex-grow: 1;
    overflow-y: auto;
    background-color: #2a2a2a;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #444;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 600px;
    max-height: 600px;
}

#item-library-list .library-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    font-style: italic;
    user-select: none;
}

.library-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 4px;
    cursor: grab;
    transition: background-color 0.2s;
    border-left: 4px solid transparent;
}

.library-item:hover {
    background-color: #444;
}

.rarity-bg-planner.Common {
    background-image: linear-gradient(90deg, #e4f0f111, #333 100%);
    border-left-color: #e4f0f1;
}

.rarity-bg-planner.Rare {
    background-image: linear-gradient(90deg, #35fbfd11, #333 100%);
    border-left-color: #35fbfd;
}

.rarity-bg-planner.Epic {
    background-image: linear-gradient(90deg, #c85ef911, #333 100%);
    border-left-color: #c85ef9;
}

.rarity-bg-planner.Legendary {
    background-image: linear-gradient(90deg, #fe3e3511, #333 100%);
    border-left-color: #fe3e35;
}

.rarity-bg-planner.Unique,
.rarity-bg-planner.Character,
.rarity-bg-planner.Identity {
    background-image: linear-gradient(90deg, #f1b05011, #333 100%);
    border-left-color: #f1b050;
}

.library-item.category-border-Destruction {
    border-left-color: #c0392b;
}

.library-item.category-border-Life {
    border-left-color: #27ae60;
}

.library-item.category-border-Imagination {
    border-left-color: #2980b9;
}

.library-item.category-border-Flexible {
    border-left-color: #f39c12;
}


.library-item .item-icon,
.library-item .item-icon-wrapper {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.library-item .item-name {
    font-size: 0.9rem;
}


.planner-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.build-info-inputs {
    display: flex;
    gap: 15px;
}
.build-info-inputs input {
    flex: 1;
    padding: 10px;
    font-size: 1rem;
    background-color: #1e1e1e;
    border: 1px solid #555;
    border-radius: 5px;
    color: #e0e0e0;
}

.build-section {
    background-color: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #444;
}

.build-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #00aaff;
}

.build-selections {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.selection-box {
    border: 1px dashed #555;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 5px 10px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    border-radius: 5px;
}

.selection-box:hover {
    background-color: #333;
}

.selection-box .label {
    font-size: 0.8rem;
    color: #aaa;
    margin: auto;
}

.selection-box .selected-item-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.selection-box .selected-item-name {
    font-weight: bold;
}

.item-slot.highlight-dejavu,
.selection-box.highlight-dejavu,
.constellation-slot.highlight-dejavu {
    border: 2px solid #e67e22;
    box-shadow: 0 0 8px #e67e2266;
}
.item-slot.highlight-core,
.selection-box.highlight-core,
.constellation-slot.highlight-core {
    border: 2px solid #f1c40f;
    box-shadow: 0 0 8px #f1c40f66;
}

.planner-dropdown {
    position: absolute;
    max-height: 300px;
    overflow-y: auto;
    background-color: #3a3a3a;
    border: 1px solid #555;
    border-radius: 5px;
    z-index: 100;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #4f4f4f;
}

.dropdown-item .item-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

.dropdown-item .traveler-portrait-icon {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
}

.dropdown-item span {
    font-size: 0.9rem;
}


.memory-essence-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.memory-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.essence-slots-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.memory-slot-wrapper {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.item-slot {
    border: 1px dashed #555;
    border-radius: 5px;
    background-color: #1e1e1e;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.memory-slot {
    height: 80px;
    aspect-ratio: auto;
}

.item-slot.drag-over {
    background-color: #3c3c3c;
    border-color: #00aaff;
}

.item-slot.drop-invalid {
    border-color: #e74c3c;
    background-color: #c0392b22;
}


.equipped-item {
    width: 80%;
    height: 80%;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.memory-slot .equipped-item {
    height: 80%;
    width: auto;
    aspect-ratio: 1/1;
}

.constellation-slot .equipped-item {
    width: 70%;
    height: 70%;
}

.equipped-item .item-icon,
.equipped-item .item-icon-wrapper {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.equipped-item .remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

.equipped-item:hover .remove-btn {
    opacity: 1;
}

.constellation-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
}

.constellation-slot {
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: 1px solid #555;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.constellation-slot.slot-destruction {
    background-color: rgba(192, 57, 43, 0.3);
}

.constellation-slot.slot-life {
    background-color: rgba(39, 174, 96, 0.3);
}

.constellation-slot.slot-imagination {
    background-color: rgba(41, 128, 185, 0.3);
}

.constellation-slot.slot-flexible {
    background-color: rgba(243, 156, 18, 0.3);
}

.constellation-slot.drag-over {
    border-color: #fff;
    transform: scale(1.1);
}

/* --- 툴팁 스타일 개선 --- */
.planner-tooltip {
    position: fixed;
    background-color: rgba(10, 10, 10, 0.95);
    color: #fff;
    border-radius: 5px;
    border: 1px solid #555;
    max-width: 350px;
    z-index: 1010;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    
    /* Flexbox 레이아웃 적용 */
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
}

/* 툴팁 아이콘 */
.tooltip-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 4px;
}
.tooltip-icon-wrapper {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}
.tooltip-star-tint {
    width: 100%;
    height: 100%;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

/* 툴팁 내용 */
.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tooltip-content h4 {
    margin: 0;
    color: #f1c40f;
    font-size: 1.1rem;
    line-height: 1.3;
}

.tooltip-content p {
    margin: 0;
    color: #e0e0e0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.tooltip-cooldown {
    font-size: 0.85rem;
    color: #aaa;
}

.tooltip-cost {
    font-size: 0.85rem;
    color: #aaa;
}

.tooltip-extra-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #444;
    font-size: 0.85rem;
    color: #ccc;
}
.tooltip-extra-info strong {
    color: #00aaff;
}

.help-tooltip-trigger {
    cursor: help;
    margin-left: 8px;
    vertical-align: middle;
}

.help-tooltip-trigger svg {
    width: 16px;
    height: 16px;
    fill: #888;
    transition: fill 0.2s;
}

.help-tooltip-trigger:hover svg {
    fill: #00aaff;
}

.simple-tooltip-text {
    font-size: 0.95rem;
    color: #e0e0e0;
    padding: 2px 0;
}

#author-container {
    flex: 1;
    position: relative;
}
.author-display {
    display: none; /* JS로 제어 */
    padding: 10px;
    font-size: 1rem;
    background-color: #1e1e1e;
    border: 1px solid #555;
    border-radius: 5px;
    color: #ccc;
    box-sizing: border-box;
    width: 100%;
}

#save-link-modal-body h3 {
    margin-top: 0;
    margin-bottom: 8px;
    color: #00aaff;
}
#save-link-modal-body p {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 20px;
}
.link-container {
    margin-bottom: 15px;
}
.link-container label {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 5px;
}
.input-group {
    display: flex;
}
.link-input {
    flex-grow: 1;
    padding: 8px;
    background-color: #1e1e1e;
    border: 1px solid #555;
    color: #e0e0e0;
    border-radius: 4px 0 0 4px;
    font-size: 0.9rem;
}
.copy-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-weight: bold;
}
.copy-btn:hover {
    background-color: #0056b3;
}

/* 모바일 라이브러리 모달 스타일 */
#mobile-library-modal-content {
    display: flex;
    flex-direction: column;
}
/* [수정] 스크롤 문제 해결을 위한 Flexbox 구조 정의 */
#mobile-library-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; 
}
#mobile-library-wrapper .planner-sidebar {
    display: flex;
    flex: 1;
    max-height: none;
    width: 100%;
    /* [신규] 사이드바 자체도 Flexbox 컨테이너가 되도록 설정 */
    flex-direction: column;
    min-height: 0;
}
/* [신규] 필터 섹션은 크기 고정 */
#mobile-library-wrapper .filter-section {
    flex-shrink: 0;
}
#mobile-library-wrapper #item-library-list {
    flex-grow: 1;
    min-height: 0;
    /* [수정] 기존 min/max height 제거 */
}

/* [신규] 모바일 라이브러리 푸터 스타일 */
.modal-footer {
    flex-shrink: 0;
    padding: 10px;
    background-color: #222;
    border-top: 1px solid #555;
    display: flex;
    gap: 10px;
    justify-content: space-around;
}
.modal-footer button {
    flex-grow: 1;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid #666;
    background-color: #444;
    color: #ddd;
    border-radius: 5px;
    cursor: pointer;
}
.modal-footer button.remove-btn {
    background-color: #a1342a;
}
.modal-footer button.disabled {
    background-color: #333;
    color: #777;
    cursor: not-allowed;
}

.description-input {
    width: 100%;
    padding: 10px;
    font-size: 0.95rem;
    background-color: #1e1e1e;
    border: 1px solid #555;
    border-radius: 5px;
    color: #e0e0e0;
    font-family: sans-serif;
    box-sizing: border-box;
    resize: none; /* 기본적으로 크기 조절 비활성화 */
}

/* 빌드 플래너 모바일 최적화 */
@media (min-width: 993px) {
    .planner-sidebar {
        display: flex;
    }

    .description-input {
        min-height: 120px;
        resize: vertical; /* 데스크탑에서만 세로 조절 허용 */
    }
}

@media (max-width: 992px) {
    .planner-container {
        flex-direction: column;
    }
    .planner-main {
        width: 100%;
    }
    .item-slot, .selection-box, .equipped-item {
        cursor: pointer;
    }
    .selection-box:active, .item-slot:active {
        background-color: #333;
    }
    .constellation-grid {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
    .description-input {
        min-height: 80px;
    }
}

@media (max-width: 768px) {
    .build-selections,
    .memory-essence-container {
        grid-template-columns: repeat(2, 1fr);
    }
    .build-info-inputs {
        flex-direction: column;
    }
}