/**
 * ============================================================
 * MODAL COMPONENTS (모달 시스템)
 * ============================================================
 *
 * 역할: 링크 편집, 이미지 크롭 등 모든 모달 컴포넌트
 *
 * 포함:
 * - 기본 모달 (overlay, container, header, body, footer)
 * - 이미지 크롭 모달 (Croppie 라이브러리 통합)
 * - 모바일 대응 (전체 화면, 슬라이드 업 애니메이션)
 *
 * 출처:
 * - dashboard-main.css (Lines 814-1030, 217 lines) - 기본 모달
 * - dashboard-main.css (Lines 1337-1475, 139 lines) - 크롭 모달
 *
 * 의존성:
 * - 1-foundation-variables.css (필수)
 *   - var(--border-color)
 *   - var(--text-color)
 *   - var(--light-text)
 *   - var(--primary-color)
 *   - var(--primary-hover)
 *   - var(--secondary-color)
 * - Croppie.js (이미지 크롭 모달)
 *
 * 추출 날짜: 2025-11-05
 * 추출자: Claude Code (css-separation-policy.md 준수)
 * ============================================================
 */

/* ====================== 모달 스타일 추가 ====================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--light-text);
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.3s;
    line-height: 1;
}

.modal-close:hover {
    background: #e9e9e9;
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
}

.modal-body .form-group {
    margin-bottom: 20px;
}

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

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 15px;
}

.modal-body input[type="text"],
.modal-body input[type="url"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
    background: #fafafa;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 46, 122, 0.1);
}

.modal-footer {
    padding: 16px 24px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #fafafa;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 80px;
}

.modal-btn-cancel {
    background: #f5f5f5;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.modal-btn-cancel:hover {
    background: #e9e9e9;
    border-color: #ccc;
}

.modal-btn-save {
    background: var(--primary-color);
    color: white;
}

.modal-btn-save:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 46, 122, 0.3);
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        margin: 0 auto;
        max-height: 90vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 20px;
    }

    .modal-footer {
        padding-top: 16px;
    }

    .modal-btn {
        flex: 1;
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .modal-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
        max-height: none;
        animation: modalSlideUp 0.3s ease;
    }

    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-body {
        max-height: calc(100vh - 160px);
        padding: 20px 20px 0;
    }

    .modal-header {
        padding: 20px 20px 16px;
    }

    .modal-footer {
        padding: 16px 20px 20px;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid var(--border-color);
    }
}

/* ====================== 이미지 크롭 모달 스타일 ====================== */
.crop-modal-container {
    max-width: 600px;
    width: 95%;
}

.crop-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: auto; /* 400px → auto: Croppie 크기에 맞춤 */
}

#croppie-container {
    width: 100%;
    min-height: auto; /* 400px → auto: 280×280 크기에 맞춤 */
    background: #fafafa;
    border-radius: 8px;
    padding: 20px;
    /* overflow: hidden 제거 - 슬라이더 보이게 */
}

/* 🔥 Croppie 기본 스타일 오버라이드 */
.croppie-container {
    width: 100%;
    height: auto !important;
}

.croppie-container .cr-boundary {
    background: #fafafa;
    margin: 0 auto;
}

.croppie-container .cr-slider-wrap {
    margin: 20px auto;  /* 원래대로 복구 */
    width: 85%;
    text-align: center;
}

.croppie-container .cr-slider {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.croppie-container .cr-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.croppie-container .cr-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* 크롭 컨트롤 버튼 */
.crop-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.crop-control-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.crop-control-btn:hover {
    background: var(--secondary-color);
    border-color: var(--primary-color);
}

.crop-control-btn:active {
    transform: scale(0.95);
}

.crop-control-btn i {
    width: 20px;
    height: 20px;
    color: var(--text-color);
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .crop-modal-container {
        max-width: 100%;
    }

    .crop-modal-body {
        min-height: 300px;
    }

    #croppie-container {
        min-height: 280px;
    }
}

@media (max-width: 480px) {
    .crop-modal-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .crop-modal-body {
        padding: 16px;
        min-height: calc(100vh - 160px);
    }

    #croppie-container {
        min-height: 250px;
    }

    .croppie-container .cr-slider-wrap {
        width: 90%;
    }
}
