/* ============ 모달 ============ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: var(--panel-bg);
    width: 85%;
    max-width: 900px;
    max-height: 85%;
    border-radius: 12px;
    border: 1px solid var(--accent);
    padding: 30px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    animation: modalSlideIn 0.3s ease;
}

.guide-content {
    max-width: 600px;
}

.guide-body {
    overflow-y: auto;
    padding-right: 10px;
    line-height: 1.6;
    color: var(--text-primary);
}

.guide-body h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.guide-body h3:first-child {
    margin-top: 0;
}

.guide-body ul {
    padding-left: 20px;
    margin-bottom: 20px;
}

.guide-body li {
    margin-bottom: 8px;
}

.guide-body strong {
    color: var(--text-gold);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
}

.modal-header-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 18px;
    overflow-y: auto;
    padding: 15px;
}

.modal-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition-speed);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.modal-item:hover {
    border-color: #666;
    background: #222;
}

.modal-item.selected {
    background: rgba(88, 155, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.modal-item.disabled {
    filter: grayscale(100%);
    opacity: 0.4;
    cursor: not-allowed;
    border-color: transparent;
}

.modal-item .name {
    display: block;
    font-size: 0.80rem;
    font-weight: 500;
}

.modal-item.selected .name {
    color: var(--accent);
    font-weight: 600;
}

.unselect-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    border-color: var(--error);
    background: rgba(255, 68, 68, 0.1);
}

.unselect-item:hover {
    border-color: var(--error);
    background: rgba(255, 68, 68, 0.2);
}

/* 모달 썸네일 */
.modal-thumb {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-thumb-fallback {
    display: none;
    font-size: 0.7rem;
    color: #aaa;
}

/* ============ 프리셋 팝업 ============ */
.preset-popup {
    display: none;
    position: absolute;
    width: 530px;
    max-height: 80vh;
    background: var(--panel-bg);
    border: 1px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 20px var(--accent-glow);
    z-index: 2000;
    flex-direction: column;
    padding: 5px;
    animation: popupSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 1023px) {
    .preset-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 95%;
        max-width: 620px;
        max-height: 90vh;
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.8), 0 20px 50px rgba(0, 0, 0, 0.9);
        animation: presetModalFade 0.3s ease;
    }
}

@keyframes presetModalFade {
    from {
        opacity: 0;
        transform: translate(-50%, -55%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.preset-popup.open {
    display: flex;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.popup-header-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent);
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 2px;
    scrollbar-width: thin;
}

.preset-slot {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all var(--transition-speed);
}

.preset-slot:hover {
    border-color: #555;
    background: #222;
}

.preset-row-first {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preset-row-second {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.preset-number {
    font-weight: bold;
    color: #888;
    font-size: 1.1rem;
    min-width: 35px;
}

.preset-icons {
    display: flex;
    gap: 8px;
}

.preset-icon {
    width: 44px;
    height: 44px;
    background: #000;
    border: 1px solid #333;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preset-icon[data-tooltip-forged="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.preset-icon img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.preset-name-wrap {
    flex: 1;
    display: flex;
    gap: 5px;
}

.preset-name-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.preset-name-input:focus {
    border-color: var(--accent);
}

.btn-preset-name-save {
    background: #333;
    color: white;
    border: 1px solid var(--border);
    padding: 0 3px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preset-name-save:hover {
    background: #444;
    border-color: var(--accent);
}

.preset-dmg-wrap {
    flex: 1;
    text-align: right;
    margin-right: 5px;
}

.preset-dmg {
    font-size: 0.9rem;
    font-weight: bold;
}

.preset-dmg.positive {
    color: var(--good);
}

.preset-dmg.negative {
    color: var(--error);
}

.preset-dmg.neutral {
    color: var(--text-muted);
}

.preset-actions {
    display: flex;
    gap: 7px;
}

.btn-preset {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 15px;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-preset.save {
    background: var(--good);
    color: black;
    font-weight: bold;
}

.btn-preset.load {
    background: var(--accent);
    color: black;
    font-weight: bold;
}

.btn-preset.clear {
    background: var(--error);
    font-weight: bold;
}

.btn-preset.save:hover {
    background: rgba(100, 255, 100, 0.2);
    border-color: var(--good);
}

.btn-preset.load:hover {
    background: rgba(88, 155, 255, 0.2);
    border-color: var(--accent);
}

.btn-preset.clear:hover {
    background: rgba(255, 100, 100, 0.2);
    border-color: var(--error);
}

.preset-slot.empty {
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ============ 사이드바 ============ */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--accent);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
    z-index: 2000;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-gold);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}

.sidebar-close:hover {
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.gear-sidebar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.sidebar-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

.sidebar-item.selected {
    border-color: var(--accent);
    background: rgba(88, 155, 255, 0.1);
}

.sidebar-item.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.sidebar-item-img {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 6px;
    padding: 4px;
}

.sidebar-item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-item-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.sidebar-item-name {
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.2;
    word-break: keep-all;
    height: 2.4em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-item-trait {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
    word-break: keep-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.unequip-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
    background: rgba(255, 68, 68, 0.1);
    border-color: var(--error);
}

.unequip-item:hover {
    border-color: var(--error);
    background: rgba(255, 68, 68, 0.2);
}

.sidebar-set-header {
    font-size: 0.95rem;
    color: var(--text-gold);
    margin-top: 25px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
    display: block;
    width: 100%;
}

.sidebar-set-header::before {
    display: none;
}

/* ============ 툴팁 ============ */
.app-tooltip {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    width: 320px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    font-size: 0.9rem;
    animation: tooltip-fade 0.15s ease-out;
    transform-origin: top left;
    display: none;
    flex-direction: column;
    gap: 10px;
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: none;
}

.app-tooltip::-webkit-scrollbar {
    display: none;
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.tooltip-section {
    margin-top: 10px;
}

.tooltip-icon {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--accent);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.tooltip-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tooltip-title-group {
    flex: 1;
}

.tooltip-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-gold);
}

.tooltip-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tooltip-label {
    font-size: 0.75rem;
    color: var(--accent);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.tooltip-stat-grid {
    display: flex;
    gap: 8px;
}

.tooltip-stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px;
    border-radius: 6px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.tooltip-stat-val {
    font-weight: 600;
}

.tooltip-desc {
    font-size: 0.85rem;
    line-height: 1.85;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    white-space: pre-line;
    word-break: keep-all;
}

.tooltip-traits {
    font-size: 0.85rem;
    line-height: 1.7;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    white-space: pre-line;
    word-break: keep-all;
}

.tooltip-set-info {
    font-size: 0.8rem;
    color: var(--good);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

/* 스킬 툴팁 전용 스타일 */
.tooltip-title {
    color: var(--accent);
    margin-bottom: 6px;
    font-size: 1.05rem;
    font-weight: bold;
}

.tooltip-bullet-point {
    margin-bottom: 2px;
}

.tooltip-bullet-marker {
    color: inherit;
}

.tooltip-bullet-marker.accent {
    color: var(--accent);
}

.tooltip-highlight {
    color: var(--accent);
    font-weight: bold;
}

.tooltip-muted {
    color: var(--text-muted);
}

/* ============ 디버프 버블 팝업 ============ */
.debuff-bubble-popup {
    position: absolute;
    z-index: 1000;
    background: rgba(15, 15, 15, 0.95);
    border: 1px solid rgba(0, 217, 255, 0.4);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
    transform-origin: top left;
    animation: popupFadeIn 0.15s ease-out forwards;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.bubble-item {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    user-select: none;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
}

.bubble-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 217, 255, 0.3);
}

.bubble-item.default-item {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-muted);
}

.bubble-item.default-item:hover {
    color: var(--text-primary);
}

.bubble-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.debuff-attribution-icon {
    position: absolute;
    bottom: -4px;
    left: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: #000;
    object-fit: cover;
    z-index: 10;
    pointer-events: none;
}

/* ============ 툴팁 트리거 태그 ============ */
.trigger-tag-container {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    vertical-align: middle;
}

.trigger-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
}

/* 트리거 값 기준 색상 */
.tag-phys {
    border-color: var(--skill-element-phys);
    color: var(--skill-element-phys);
}

.tag-arts {
    border-color: var(--skill-element-arts);
    color: var(--skill-element-arts);
}

.tag-heat {
    border-color: var(--skill-element-heat);
    color: var(--skill-element-heat);
}

.tag-elec {
    border-color: var(--skill-element-elec);
    color: var(--skill-element-elec);
}

.tag-cryo {
    border-color: var(--skill-element-cryo);
    color: var(--skill-element-cryo);
}

.tag-nature {
    border-color: var(--skill-element-nature);
    color: var(--skill-element-nature);
}

.tag-special {
    border-color: var(--accent);
    color: var(--accent);
}

.tag-synergy {
    border-color: #FFFA00;
    color: #FFFA00;
}

.tag-target {
    border-color: #ff4d4d;
    color: #ff4d4d;
}

.tag-trigger-type {
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.8);
}

/* ============ 반응형 (오버레이) ============ */
@media (max-width: 1024px) {
    .sidebar {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .gear-sidebar-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        padding: 15px;
        max-height: 90%;
    }

    .modal-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
        padding: 10px 5px;
    }

    .modal-item {
        padding: 15px 10px;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
}