/* ============================================================
   Science Virtual LAB — 공통 제안하기 모듈 (labs/common/feedback.css)
   💡 제안하기 버튼 + 글래스 모달 (visionOS 룩앤필)
   - 모든 실험실 페이지에서 labs/common/feedback.js 한 줄로 로드됩니다.
   - 다크/라이트 테마는 body.svl-fb-dark 클래스로 자동 동기화됩니다.
   ============================================================ */

/* ---------- 상단 우측 열기 버튼 (💡 제안하기) ---------- */
.svl-fb-btn {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    right: calc(20px + env(safe-area-inset-right));
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 15px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 20px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: bold;
    letter-spacing: -0.2px;
    color: #1c1c1e;
    background: rgba(255, 255, 255, .75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .10);
    cursor: pointer;
    white-space: nowrap;
    transition: transform .18s ease, box-shadow .18s ease, background .25s ease, color .25s ease;
}
.svl-fb-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(0, 0, 0, .14); }
.svl-fb-btn:active { transform: scale(.95); }
.svl-fb-btn .fb-open-icon { font-size: 15px; line-height: 1; }
body.svl-fb-dark .svl-fb-btn {
    background: rgba(40, 40, 44, .78);
    border-color: rgba(255, 255, 255, .16);
    color: #f2f2f7;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
}

/* 우측 상단 유틸 행([제안하기][야간 모드]) 안에 인라인으로 놓일 때 */
.svl-fb-btn.svl-fb-inline {
    position: static;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    z-index: auto;
    height: 40px;
    flex: 0 0 auto;
}

/* ---------- 메인 페이지(index.html) 상단 바 캡슐 버튼 (.feedback-nav-btn) ---------- */
.nav-tabs .feedback-nav-btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 15px;
    border: 1px solid #d9dee3;
    border-radius: 999px;
    background: #ffffff;
    color: #2c3e50;
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(44, 62, 80, 0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.nav-tabs .feedback-nav-btn:hover {
    background: #f6f9f8;
    border-color: #c8d2d8;
    color: #1a252f;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(44, 62, 80, 0.1);
}

.nav-tabs .feedback-nav-btn:active {
    transform: scale(0.97);
}

.nav-tabs .feedback-nav-btn .fb-open-icon {
    font-size: 15px;
    line-height: 1;
}

@media (max-width: 600px) {
    .nav-tabs .feedback-nav-btn .fb-open-label {
        display: none;
    }

    .nav-tabs .feedback-nav-btn {
        padding: 7px 10px;
    }
}

/* ---------- 반투명 블러 백드롭 ---------- */
.svl-fb-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(20, 22, 28, 0.30);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    -webkit-tap-highlight-color: transparent;
    font-family: 'SeoulNamsan', -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
}
.svl-fb-overlay.show { display: flex; animation: fb-fade .2s ease-out; }
@keyframes fb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fb-rise { from { opacity: 0; transform: translateY(16px) scale(.975); } to { opacity: 1; transform: none; } }

/* ---------- 모달 카드 ---------- */
.fb-card {
    position: relative;
    width: min(520px, 100%);
    max-height: min(88vh, 740px);
    display: flex;
    flex-direction: column;
    padding: 20px 22px 18px;
    border-radius: 26px;
    background: rgba(255, 255, 255, .80);
    border: 1px solid rgba(255, 255, 255, .72);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .24), 0 2px 8px rgba(0, 0, 0, .06);
    color: #1c1c1e;
    overflow: hidden;
    animation: fb-rise .28s cubic-bezier(.2, .9, .3, 1);
}
body.svl-fb-dark .fb-card {
    background: rgba(32, 32, 36, .88);
    border-color: rgba(255, 255, 255, .14);
    color: #f2f2f7;
}

.fb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.fb-head-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fb-title { font-size: 17px; font-weight: bold; letter-spacing: -0.3px; display: flex; align-items: center; gap: 7px; }
.fb-subtitle { font-size: 11.5px; font-weight: bold; color: #8e8e93; }
.fb-close {
    flex: 0 0 auto;
    width: 30px; height: 30px;
    border: none; border-radius: 50%;
    background: rgba(120, 120, 128, .14);
    color: #3a3a3c;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: background .16s ease, transform .16s ease;
}
.fb-close:active { transform: scale(.9); }
body.svl-fb-dark .fb-close { background: rgba(255, 255, 255, .14); color: #f2f2f7; }

/* 실험명 자동 뱃지 */
.fb-exp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 11px;
    border-radius: 12px;
    background: rgba(0, 122, 255, .10);
    border: 1px solid rgba(0, 122, 255, .16);
    font-size: 11.5px;
    font-weight: bold;
    color: #007aff;
    align-self: flex-start;
    max-width: 100%;
}
.fb-exp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.svl-fb-dark .fb-exp { background: rgba(10, 132, 255, .22); border-color: rgba(10, 132, 255, .4); color: #8fc6ff; }

/* 스크롤 영역 */
.fb-body {
    display: flex;
    flex-direction: column;
    gap: 13px;
    margin-top: 14px;
    padding-right: 2px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}
.fb-field { display: flex; flex-direction: column; gap: 7px; }
.fb-label { font-size: 11.5px; font-weight: bold; color: #6c6c70; display: flex; align-items: center; gap: 5px; }
.fb-req { font-size: 9.5px; color: #ff3b30; background: rgba(255, 59, 48, .1); padding: 1px 6px; border-radius: 7px; }
.fb-opt { font-size: 9.5px; color: #8e8e93; background: rgba(120, 120, 128, .12); padding: 1px 6px; border-radius: 7px; }
body.svl-fb-dark .fb-label { color: #aeaeb2; }

/* 작성자 구분 (세그먼트) */
.fb-seg { display: flex; gap: 4px; padding: 4px; border-radius: 15px; background: rgba(120, 120, 128, .12); }
.fb-seg-btn {
    flex: 1 1 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: bold;
    color: #3a3a3c;
    padding: 8px 4px;
    border-radius: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.fb-seg-btn.active { background: #ffffff; color: #007aff; box-shadow: 0 2px 8px rgba(0, 0, 0, .10); }
body.svl-fb-dark .fb-seg-btn { color: #e2e2e7; }
body.svl-fb-dark .fb-seg-btn.active { background: rgba(99, 99, 106, .95); color: #ffffff; }

/* 제안 유형 (칩) */
.fb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(120, 120, 128, .24);
    background: rgba(255, 255, 255, .6);
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    color: #3a3a3c;
    padding: 7px 11px;
    border-radius: 12px;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.fb-chip:active { transform: scale(.96); }
.fb-chip.active { background: #007aff; border-color: #007aff; color: #ffffff; box-shadow: 0 4px 12px rgba(0, 122, 255, .28); }
body.svl-fb-dark .fb-chip { background: rgba(60, 60, 66, .7); border-color: rgba(255, 255, 255, .16); color: #e5e5ea; }
body.svl-fb-dark .fb-chip.active { background: #0a84ff; border-color: #0a84ff; color: #ffffff; }

/* 입력 필드 */
.fb-textarea, .fb-input {
    width: 100%;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.6;
    color: #1c1c1e;
    background: rgba(255, 255, 255, .78);
    border: 1px solid rgba(120, 120, 128, .24);
    border-radius: 14px;
    padding: 11px 13px;
    resize: none;
    outline: none;
    user-select: text;
    -webkit-user-select: text;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.fb-textarea { min-height: 104px; }
.fb-input { height: 42px; }
.fb-textarea:focus, .fb-input:focus { border-color: #007aff; background: #ffffff; box-shadow: 0 0 0 3.5px rgba(0, 122, 255, .16); }
.fb-textarea::placeholder, .fb-input::placeholder { color: #9b9ba1; font-weight: 600; }
body.svl-fb-dark .fb-textarea, body.svl-fb-dark .fb-input {
    background: rgba(18, 18, 20, .72);
    border-color: rgba(255, 255, 255, .14);
    color: #f2f2f7;
}
body.svl-fb-dark .fb-textarea:focus, body.svl-fb-dark .fb-input:focus { background: rgba(18, 18, 20, .95); }
.fb-textarea.error, .fb-input.error {
    border-color: #ff3b30;
    box-shadow: 0 0 0 3.5px rgba(255, 59, 48, .14);
    animation: fb-shake .32s ease-in-out;
}
@keyframes fb-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}
.fb-counter { align-self: flex-end; font-size: 10.5px; font-weight: bold; color: #a1a1a6; margin-top: -2px; }

/* 오류 안내 */
.fb-error {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: bold;
    color: #ff3b30;
    background: rgba(255, 59, 48, .09);
    border-radius: 10px;
    padding: 8px 11px;
    line-height: 1.45;
}
.fb-error.show { display: flex; }

/* 하단 액션 */
.fb-actions { display: flex; gap: 8px; margin-top: 3px; }
.fb-btn-cancel {
    flex: 0 0 auto;
    padding: 12px 18px;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    color: #1c1c1e;
    background: rgba(120, 120, 128, .14);
    cursor: pointer;
    transition: background .16s ease, transform .16s ease;
}
.fb-btn-cancel:active { transform: scale(.97); }
.fb-btn-submit {
    flex: 1 1 auto;
    padding: 12px 18px;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: bold;
    color: #ffffff;
    background: linear-gradient(180deg, #0a84ff, #0071e3);
    box-shadow: 0 8px 20px rgba(0, 122, 255, .32);
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease;
}
.fb-btn-submit:active { transform: scale(.97); box-shadow: 0 4px 12px rgba(0, 122, 255, .3); }
body.svl-fb-dark .fb-btn-cancel { background: rgba(255, 255, 255, .14); color: #f2f2f7; }

/* 제출 완료 화면 */
.fb-success {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 9px;
    padding: 24px 8px 20px;
    animation: fb-rise .3s cubic-bezier(.2, .9, .3, 1);
}
.fb-card.done .fb-body, .fb-card.done .fb-exp { display: none; }
.fb-card.done .fb-success { display: flex; }
.fb-success-icon {
    width: 54px; height: 54px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 26px;
    background: rgba(52, 199, 89, .16);
    box-shadow: 0 0 0 8px rgba(52, 199, 89, .07);
    margin-bottom: 2px;
}
.fb-success-title { font-size: 16px; font-weight: bold; letter-spacing: -0.3px; }
.fb-success-msg { font-size: 13px; font-weight: bold; line-height: 1.65; color: #3a3a3c; word-break: keep-all; }
.fb-success-sub { font-size: 11px; font-weight: bold; color: #a1a1a6; }
body.svl-fb-dark .fb-success-msg { color: #d1d1d6; }

/* 토스트 */
.fb-toast {
    position: fixed;
    left: 50%;
    bottom: calc(110px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(8px);
    z-index: 1400;
    max-width: 84vw;
    padding: 10px 16px;
    border-radius: 14px;
    background: rgba(28, 28, 30, .9);
    color: #ffffff;
    font-family: 'SeoulNamsan', -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
.fb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 모바일 세로 ---------- */
@media (max-width: 900px) {
    .svl-fb-btn {
        width: auto !important;
        height: 34px !important;
        min-width: auto;
        padding: 0 11px !important;
        border-radius: 999px !important;
        flex: 0 0 auto;
        gap: 4px;
    }
    .svl-fb-btn .fb-open-label { display: inline !important; font-size: 11.5px; font-weight: bold; }
    .svl-fb-btn .fb-open-icon { font-size: 14px; }

    .svl-fb-overlay { padding: 12px; }
    .fb-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        padding: 16px 16px 14px;
        border-radius: 22px;
    }
    .fb-title { font-size: 15.5px; }
    .fb-subtitle { font-size: 10.5px; }
    .fb-exp { font-size: 10.5px; padding: 5px 9px; gap: 5px; }
    .fb-body { gap: 11px; margin-top: 11px; }
    .fb-label { font-size: 11px; }
    .fb-seg-btn { font-size: 11.5px; padding: 7px 2px; }
    .fb-chip { font-size: 11px; padding: 6px 9px; gap: 4px; }
    .fb-textarea { font-size: 13px; min-height: 92px; }
    .fb-input { font-size: 13px; }
    .fb-btn-cancel { padding: 11px 15px; font-size: 12.5px; }
    .fb-btn-submit { padding: 11px 15px; font-size: 13px; }
    .fb-success { padding: 20px 4px 16px; }
    .fb-success-msg { font-size: 12.5px; }
}

/* ---------- 모바일 가로 ---------- */
@media (max-height: 500px) and (orientation: landscape) {
    .svl-fb-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px;
        padding: 0 !important;
        border-radius: 50% !important;
        flex: 0 0 auto;
    }
    .svl-fb-btn .fb-open-label { display: none !important; }
    .svl-fb-btn .fb-open-icon { font-size: 12.5px; }

    .svl-fb-overlay { padding: 8px; }
    .fb-card {
        width: min(620px, 96vw) !important;
        max-width: 96vw !important;
        max-height: calc(100vh - 16px) !important;
        padding: 12px 14px 10px;
        border-radius: 18px;
    }
    .fb-title { font-size: 14px; }
    .fb-subtitle { display: none; }
    .fb-exp { margin-top: 6px; font-size: 10px; padding: 4px 8px; }

    /* 가로 모드: 세로 공간이 좁으므로 2단 배치로 한 화면에 담는다 */
    .fb-body {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
        grid-template-areas:
            "role    content"
            "type    content"
            "email   content"
            "error   error"
            "actions actions";
        column-gap: 12px;
        row-gap: 7px;
        align-content: start;
        align-items: start;
        margin-top: 8px;
        overflow-y: auto;
        min-height: 0;
    }
    .fb-body > .fb-field:nth-child(1) { grid-area: role; }
    .fb-body > .fb-field:nth-child(2) { grid-area: type; }
    .fb-body > .fb-field:nth-child(3) { grid-area: content; align-self: stretch; }
    .fb-body > .fb-field:nth-child(4) { grid-area: email; }
    .fb-body > .fb-error { grid-area: error; }
    .fb-body > .fb-actions { grid-area: actions; }
    .fb-body > .fb-field:nth-child(3) .fb-textarea { flex: 1 1 auto; min-height: 76px; }
    .fb-label { font-size: 10px; }
    .fb-seg { padding: 3px; }
    .fb-seg-btn { font-size: 10.5px; padding: 5px 2px; }
    .fb-chips { gap: 4px; }
    .fb-chip { font-size: 10px; padding: 5px 8px; }
    .fb-textarea { font-size: 12px; min-height: 62px; padding: 8px 10px; }
    .fb-input { font-size: 12px; height: 34px; padding: 7px 10px; }
    .fb-counter { font-size: 9.5px; }
    .fb-actions { gap: 6px; }
    .fb-btn-cancel, .fb-btn-submit { padding: 9px 14px; font-size: 12px; }
    .fb-success { padding: 12px 4px 8px; gap: 6px; }
    .fb-success-icon { width: 42px; height: 42px; font-size: 20px; }
    .fb-success-msg { font-size: 11.5px; }
    .fb-success-sub { font-size: 10px; }
    .fb-toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
