/* --- modal.css --- */
/* 커스텀 모달 시스템 - CMS 디자인 통일 */

/* 모달 오버레이 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 9998;
    opacity: 0;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                backdrop-filter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(0px);
}

.modal-overlay.show {
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 1;
    backdrop-filter: blur(4px);
}

/* 모달 컨테이너 */
.modal-container {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(-30px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease;
}

.modal-overlay.show .modal-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* 모달 헤더 */
.modal-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

.modal-icon.success {
    color: var(--success-color);
}

.modal-icon.error {
    color: var(--danger-color);
}

.modal-icon.warning {
    color: var(--warning-color);
}

.modal-icon.info {
    color: var(--info-color);
}

.modal-icon.confirm {
    color: var(--primary-color);
}

.modal-title {
    font-size: var(--h3-font-size);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary-color);
    margin: 0;
}

/* 모달 바디 */
.modal-body {
    padding: 24px;
    color: var(--text-secondary-color);
    font-size: var(--body-font-size);
    line-height: var(--line-height-base);
    max-height: 400px;
    overflow-y: auto;
}

/* 모달 푸터 */
.modal-footer {
    padding: 16px 24px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    min-width: 80px;
}

/* 확인 모달 버튼 스타일 */
.modal-footer .btn-confirm {
    background-color: var(--primary-color);
    color: var(--text-on-primary-bg);
    border-color: var(--primary-color);
}

.modal-footer .btn-confirm:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.modal-footer .btn-cancel {
    background-color: var(--surface-color);
    color: var(--text-secondary-color);
    border: 1px solid var(--input-border-color);
}

.modal-footer .btn-cancel:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* 애니메이션 */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.7) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .modal-container {
        max-width: 95%;
        width: 95%;
    }
    
    .modal-header {
        padding: 20px 20px 12px 20px;
    }
    
    .modal-body {
        padding: 20px;
        font-size: var(--small-font-size);
    }
    
    .modal-footer {
        padding: 12px 20px 20px 20px;
        flex-direction: column-reverse;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* 키보드 포커스 스타일 */
.modal-footer .btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 스크롤 막기 */
body.modal-open {
    overflow: hidden;
}

/* --- AR 콘텐츠 모달 전용 스타일 --- */
/* 큰 모달 컨테이너 */
.ar-content-modal-large {
    max-width: 900px;
    width: 95%;
    animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(40px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* AR 스테이지 모달 - 거의 전체 화면 */
.ar-stage-modal-full {
    max-width: 96vw;
    width: 96vw;
    max-height: 94vh;
    height: 94vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.ar-stage-modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    max-height: none;
    min-height: 0;
}

.ar-stage-modal-body iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
}

/* 모달 닫기 버튼 */
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary-color);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotate(0deg);
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary-color);
    transform: rotate(90deg);
}

/* 인라인 입력 그룹 */
.input-group-inline {
    display: flex;
    gap: 8px;
}

.input-group-inline .form-control {
    flex: 1;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-group-inline .form-control:focus {
    transform: scale(1.02);
}

/* 폼 그룹 헤더 (라벨 + 버튼) */
.form-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.form-group-header label {
    margin-bottom: 0;
}

/* 설정 리스트 컨테이너 */
.config-list {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    background-color: var(--background-color);
    min-height: 80px;
}

/* 빈 상태 */
.empty-state {
    text-align: center;
    color: var(--text-secondary-color);
    font-size: var(--small-font-size);
    padding: 20px;
}

/* Animation 아이템 */
.animation-item {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
}

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

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

.animation-item-title {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary-color);
    font-size: var(--body-font-size);
}

.btn-remove-item {
    background-color: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: var(--small-font-size);
    cursor: pointer;
    transition: all var(--transition-speed-fast);
}

.btn-remove-item:hover {
    background-color: var(--danger-color);
    color: white;
}

/* Animation 필드 그룹 */
.animation-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.animation-field-full {
    grid-column: 1 / -1;
}

/* Asset 아이템 */
.asset-item {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

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

.asset-item-fields {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.asset-item-actions {
    display: flex;
    align-items: center;
}

/* Plane 아이템 */
.plane-item {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.plane-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-color: rgba(109, 152, 134, 0.3);
}

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

.plane-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: -16px -16px 12px -16px;
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.plane-item-header:hover {
    background-color: rgba(109, 152, 134, 0.05);
}

.plane-item-title {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary-color);
    font-size: var(--body-font-size);
}

.plane-toggle-icon {
    color: var(--text-secondary-color);
    font-size: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.plane-item.collapsed .plane-toggle-icon {
    transform: rotate(-90deg);
}

/* Plane 아이템 바디 - 애니메이션 준비 */
.plane-item-body {
    max-height: 1500px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.plane-item.collapsed .plane-item-body {
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px);
}

/* 완전히 숨김 (JavaScript가 애니메이션 후 적용) */
.plane-item-body.hidden {
    display: none;
}

.plane-item-body .form-group {
    margin-bottom: 12px;
}

.plane-item-body .form-group:last-child {
    margin-bottom: 0;
}

.plane-item-body .input-group-inline {
    display: flex;
    gap: 8px;
}

.plane-item-body .input-group-inline .form-control {
    flex: 1;
}

.form-text {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary-color);
    font-size: var(--small-font-size);
}

/* Plane 애니메이션 섹션 */
.plane-animation-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

.plane-animation-header {
    margin-bottom: 12px;
}

.plane-animation-header label {
    display: block;
    margin-bottom: 8px;
    font-weight: var(--font-weight-semibold);
}

.plane-animation-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.plane-preset-select {
    flex: 1;
    min-width: 140px;
    max-width: 220px;
    padding: 8px 32px 8px 12px !important;
    font-size: 13px !important;
    font-weight: 500;
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    border: 1px solid var(--border-color, #e2e8f0) !important;
    border-radius: 8px;
    color: var(--text-primary-color, #334155) !important;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.plane-preset-select:hover {
    border-color: var(--primary-color, #6d9886) !important;
    background-color: rgba(248, 250, 252, 1) !important;
}

.plane-preset-select:focus {
    outline: none;
    border-color: var(--primary-color, #6d9886) !important;
    box-shadow: 0 0 0 2px rgba(109, 152, 134, 0.15);
}

.plane-preset-select option {
    padding: 10px 12px;
}

.plane-anim-list {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    background-color: var(--background-color);
    min-height: 60px;
}

.plane-animation-card {
    background-color: var(--surface-color);
    border: 1px solid var(--primary-light);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.plane-animation-card:hover {
    box-shadow: 0 2px 8px rgba(109, 152, 134, 0.15);
    border-color: var(--primary-color);
}

.plane-animation-card:last-child {
    margin-bottom: 0;
}

.plane-anim-card-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.plane-anim-card-header .plane-anim-card-title {
    flex: 1 1 auto;
    min-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--font-weight-semibold);
    color: var(--primary-color);
    font-size: var(--small-font-size);
    line-height: 1.2;
    margin-top: -2px;
}

.plane-animation-card .btn-close-card {
    flex-shrink: 0;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    margin-left: auto;
    margin-top: 1px;
    background: none;
    border: none;
    font-size: 12px !important;
    line-height: 1;
    color: var(--text-secondary-color);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.plane-animation-card .btn-close-card:hover {
    background-color: var(--danger-light-bg);
    color: var(--danger-color);
}

.plane-anim-card-body .form-group {
    margin-bottom: 10px;
}

.plane-anim-card-body .form-group:last-child {
    margin-bottom: 0;
}

.plane-anim-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.plane-anim-values .form-group label {
    font-size: var(--small-font-size);
}

.plane-anim-values .form-group input[type="checkbox"] {
    width: auto;
    margin-right: 4px;
}

.plane-anim-card-body .form-group:has(.plane-anim-xyz-inputs) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.plane-anim-card-body .form-group:has(.plane-anim-xyz-inputs) label {
    white-space: nowrap;
    flex-shrink: 0;
}

.plane-anim-card-body .form-group:has(.plane-anim-xyz-inputs) .plane-anim-xyz-inputs {
    flex: 1;
    min-width: 0;
}

.plane-anim-xyz-inputs {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
}

.plane-anim-xyz-inputs input {
    flex: 1;
    min-width: 44px;
    box-sizing: border-box;
}

/* 작은 버튼 스타일 */
.btn-sm {
    padding: 6px 12px;
    font-size: var(--small-font-size);
}

/* 반응형 */
@media (max-width: 768px) {
    .ar-stage-modal-full {
        width: 100vw;
        max-width: 100vw;
        height: 95vh;
        max-height: 95vh;
    }

    .ar-content-modal-large {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .input-group-inline {
        flex-direction: column;
    }

    .animation-fields {
        grid-template-columns: 1fr;
    }

    .asset-item {
        flex-direction: column;
    }

    .asset-item-fields {
        grid-template-columns: 1fr;
    }

    .plane-item-body .input-group-inline {
        flex-direction: column;
    }

    .plane-animation-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .plane-preset-select {
        max-width: 100%;
    }

    .plane-anim-values {
        grid-template-columns: 1fr;
    }
}