/* ================================================================
   KCT Comfort Widget — 우측 하단 플로팅 카드
   ================================================================ */

/* 컨테이너 — 우측 하단 고정 (데스크탑 기본 위치) */
#kct-comfort-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

/* 접힌 상태 — 동그란 아이콘 버튼 */
#kct-comfort-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#kct-comfort-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}
#kct-comfort-trigger:focus {
    outline: 3px solid rgba(74, 144, 226, 0.4);
    outline-offset: 2px;
}

/* 작은 텍스트 라벨 (아이콘 옆) — 처음 방문자 안내용 */
#kct-comfort-trigger-label {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    color: #333;
    padding: 6px 12px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    animation: kct-bob 2.5s ease-in-out infinite;
}
@keyframes kct-bob {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50%      { transform: translateY(-50%) translateX(-4px); }
}

/* 펼친 상태 — 카드 */
#kct-comfort-card {
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 60px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#kct-comfort-header {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#kct-comfort-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}
#kct-comfort-lang-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 8px;
}
#kct-comfort-lang-toggle:hover { background: rgba(255, 255, 255, 0.3); }
#kct-comfort-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

#kct-comfort-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* 도입 문구 */
.kct-intro {
    font-size: 14px;
    color: #555;
    margin: 0 0 12px;
    line-height: 1.5;
}

/* 카테고리 버튼 그리드 */
.kct-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.kct-cat-btn {
    background: #f4f6fa;
    border: 1px solid #e0e4ec;
    border-radius: 10px;
    padding: 10px 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    line-height: 1.3;
}
.kct-cat-btn:hover {
    background: #e8eef7;
    border-color: #4a90e2;
}
.kct-cat-btn:active { transform: scale(0.97); }

/* 자유 입력 영역 */
.kct-text-section {
    border-top: 1px solid #eee;
    padding-top: 12px;
    margin-top: 8px;
}
.kct-text-label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}
.kct-text-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 60px;
    border: 1px solid #d0d6e0;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}
.kct-text-input:focus {
    outline: none;
    border-color: #4a90e2;
}
.kct-submit-btn {
    width: 100%;
    margin-top: 8px;
    background: #4a90e2;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.kct-submit-btn:hover { background: #357abd; }
.kct-submit-btn:disabled { background: #b0bccd; cursor: not-allowed; }

/* 로딩 */
.kct-loading {
    text-align: center;
    padding: 30px 10px;
    color: #666;
    font-size: 14px;
}
.kct-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e0e4ec;
    border-top-color: #4a90e2;
    border-radius: 50%;
    animation: kct-spin 0.8s linear infinite;
    margin-bottom: 8px;
}
@keyframes kct-spin { to { transform: rotate(360deg); } }

/* 응답 결과 */
.kct-result { font-size: 14px; line-height: 1.55; color: #333; }
.kct-result-section {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eef0f4;
}
.kct-result-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.kct-result-label {
    font-size: 11px;
    font-weight: 700;
    color: #4a90e2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.kct-verse-ref {
    font-weight: 600;
    color: #2a5a8a;
    margin-bottom: 4px;
}
.kct-verse-text {
    font-style: italic;
    color: #444;
    padding-left: 10px;
    border-left: 3px solid #4a90e2;
}
.kct-comfort-msg, .kct-short-prayer { color: #444; }
.kct-short-prayer {
    background: #f7faff;
    padding: 10px 12px;
    border-radius: 8px;
    font-style: italic;
}

/* 찬송 오디오 플레이어 */
.kct-hymn-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}
.kct-hymn-audio {
    width: 100%;
    height: 40px;
    border-radius: 8px;
    outline: none;
}
.kct-hymn-audio::-webkit-media-controls-panel {
    background-color: #f4f6fa;
}
.kct-hymn-unavailable {
    background: #f4f6fa;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #777;
    text-align: center;
}

/* 다시하기 버튼 */
.kct-restart-btn {
    width: 100%;
    margin-top: 12px;
    background: transparent;
    color: #4a90e2;
    border: 1px solid #4a90e2;
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    cursor: pointer;
}
.kct-restart-btn:hover { background: #f0f5fc; }

/* 푸터 면책 */
.kct-disclaimer {
    margin-top: 10px;
    font-size: 11px;
    color: #999;
    text-align: center;
    line-height: 1.4;
}

/* 에러 */
.kct-error {
    background: #fff4f4;
    color: #b03030;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* 모바일 — 화면 폭 480 이하 (KCT Digital Usher Video와 충돌 방지)
   ────────────────────────────────────────────────────────────
   KCT의 .usher-video-col은 모바일에서 right:12px; bottom:12px;
   위치에 width 110-150px, height 160-220px의 fixed 영역을 차지함.
   추가로 .usher-welcome-bubble이 right:140px; bottom:18px에 나타날 수 있음.
   → 우리 위젯은 그 위로 충분히 떨어뜨려야 함 (대략 250px). */
@media (max-width: 480px) {
    #kct-comfort-widget {
        right: 12px !important;
        bottom: 250px !important; /* Usher Video(약 220px) + 여유 30px */
        left: auto !important;
        top: auto !important;
    }
    #kct-comfort-card {
        width: calc(100vw - 24px);
        /* 펼쳤을 때 위쪽이 화면 밖으로 나가지 않도록 최대 높이 제한
           (위젯 bottom 250 + 카드 자체 위로 펼침 + 상단 여유) */
        max-height: calc(100vh - 280px);
    }
    #kct-comfort-trigger-label { display: none; }
    .kct-categories { grid-template-columns: 1fr 1fr; }
}

/* 더 좁은 화면 (350px 이하) — 카드 높이 제한 완화 */
@media (max-width: 350px) {
    #kct-comfort-card {
        max-height: calc(100vh - 290px);
    }
}

/* 숨김 유틸 */
.kct-hidden { display: none !important; }
