/* ============================================================
   CONSULTATION PAGE STYLES
   ============================================================ */

.consultation-section {
    padding: 0 0 var(--space-xl) 0;
    /* padding-top은 아래 margin-top으로 대체 */
    margin-top: 100px;
    /* 상단 메뉴와의 간격 대폭 확보 */
    min-height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
}

.chat-interface {
    display: flex;
    flex-direction: column;
    height: 1000px;
    max-height: 92vh;
    padding: 0 !important;
    overflow: hidden;
}

/* Header */
.chat-header {
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    min-height: 70px;
    /* 헤더 높이 고정으로 안정감 부여 */
}

.chat-header__left {
    flex: 1;
    display: flex;
    align-items: center;
}

.chat-header__center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-header__right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.chat-header__title {
    font-size: var(--fs-h3);
    margin: 0;
    white-space: nowrap;
    color: var(--text-primary);
}

.chat-header__turn {
    background: rgba(124, 58, 237, 0.15);
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-size: var(--fs-small);
    color: var(--text-primary);
    border: 1px solid var(--border-purple);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.1);
}

.chat-header__badge {
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tier-guardian {
    background: var(--gradient-purple);
    color: white;
}

.tier-sentinel {
    background: var(--gradient-gold);
    color: #0a0e27;
}

/* ---- Session History ---- */
.chat-sessions-wrap {
    padding: 12px var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
}

.chat-sessions__title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.chat-sessions__title {
    font-size: var(--fs-small);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    white-space: nowrap;
}

.chat-sessions__desc {
    font-size: 12px;
    color: var(--text-muted, rgba(255,255,255,0.4));
    white-space: nowrap;
}

.chat-sessions__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-session-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: var(--radius-full);
    padding: 5px 10px 5px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.chat-session-item:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.5);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.chat-session-item.active {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--purple-light);
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.15);
}

.chat-session-item__delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted, rgba(255,255,255,0.35));
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all var(--transition);
}

.chat-session-item__delete:hover {
    background: rgba(255, 59, 48, 0.2);
    color: #ff3b3b;
}

/* ---- Consent Modal ---- */
.consent-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.consent-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
}

.consent-modal__content {
    position: relative;
    z-index: 1;
    max-width: 540px;
    width: 90%;
    padding: var(--space-3xl) var(--space-2xl) !important;
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.consent-modal__icon {
    font-size: 3.5rem;
    margin-bottom: var(--space-md);
}

.consent-modal__title {
    font-size: var(--fs-h3);
    color: var(--text-primary);
    margin: 0 0 var(--space-lg) 0;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.consent-modal__text {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0 0 var(--space-xl) 0;
    text-align: left;
}

.consent-modal__actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

.consent-modal__actions .btn {
    min-width: 140px;
    padding: 12px 24px;
}

/* ---- Tips Banner ---- */
.tips-banner {
    background: rgba(124, 58, 237, 0.08);
    border-bottom: 1px solid var(--border-subtle);
    padding: 10px var(--space-xl);
}

.tips-banner__content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tips-banner__title {
    font-weight: var(--fw-bold);
    color: var(--gold);
    white-space: nowrap;
}

.tips-banner__item {
    white-space: normal;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.chat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    /* 세로 배치로 변경 */
    gap: 8px;
}

.chat-msg--ai {
    align-self: flex-start;
    align-items: flex-start;
    /* 자식 요소 왼쪽 정렬 */
}

.chat-msg--user {
    align-self: flex-end;
    align-items: flex-end;
    /* 자식 요소 오른쪽 정렬 */
}

.chat-msg__bubble {
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: var(--fs-body);
    white-space: pre-wrap;
    /* 줄바꿈 및 공백 유지 */
    width: fit-content;
    /* 텍스트에 맞게 너비 조정 */
}

.chat-msg--ai .chat-msg__bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.chat-msg--user .chat-msg__bubble {
    background: var(--gradient-purple);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Info / System Messages */
.chat-msg--info {
    align-self: center;
    align-items: center;
    max-width: 90%;
    margin: var(--space-md) 0;
    width: 100%;
}

.chat-msg--info .chat-msg__bubble {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px dashed var(--border-subtle);
    font-size: var(--fs-small);
    text-align: center;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    margin: 0 auto;
    width: auto;
}

/* Suggestion Chips */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    padding-left: 2px;
}

.suggestion-chip {
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: var(--purple-light);
    padding: 6px 14px;
    /* 패딩 축소 */
    border-radius: var(--radius-full);
    font-size: 13px;
    /* 폰트 사이즈 살짝 축소 */
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    width: fit-content;
    /* 텍스트 너비에 맞춤 */
}

.suggestion-chip:hover {
    background: var(--gradient-purple);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

/* Input Area */
.chat-input-area {
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: linear-gradient(180deg, rgba(10, 14, 39, 0.6) 0%, rgba(10, 14, 39, 0.9) 100%);
}

.chat-input-wrap {
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    padding: 8px 8px 8px 20px;
    transition: all var(--transition);
}

.chat-input-wrap:focus-within {
    border-color: rgba(124, 58, 237, 0.5);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1), 0 4px 20px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.06);
}

.chat-input {
    flex: 1 1 0%;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 10px 0;
    color: var(--text-primary);
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    min-height: 44px;
    max-height: 120px;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-input:focus {
    outline: none;
}

.chat-input-area .btn--primary {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: var(--gradient-gold);
    color: #0a0e27;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(212, 175, 55, 0.3);
    transition: all var(--transition);
}

.chat-input-area .btn--primary:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.45);
}

/* Auth Guard & No Access */
.auth-guard,
.no-access {
    text-align: center;
    padding: var(--space-4xl) !important;
    max-width: 600px;
    margin: 40px auto;
}

.no-access__icon {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
}

.no-access__actions {
    margin-top: var(--space-xl);
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

/* Extension Banner */
.extension-banner {
    background: rgba(124, 58, 237, 0.2);
    border-top: 1px solid var(--border-purple);
    padding: var(--space-md) var(--space-xl);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.extension-banner__content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    color: var(--text-primary);
    font-size: var(--fs-small);
}

.btn--gold {
    background: var(--gradient-gold);
    color: #0a0e27;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.btn--gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.animate-slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Animations */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Utils */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.dots::after {
    content: '';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {

    /* 모바일에서 풀스크린 채팅 — 푸터 숨기기 */
    body.page-template-page-consultation .site-footer,
    body.page-template-page-consultation-php .site-footer,
    body:has(.consultation-section) .site-footer {
        display: none !important;
    }

    body.page-template-page-consultation .site-main,
    body.page-template-page-consultation-php .site-main,
    body:has(.consultation-section) .site-main {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        overflow: hidden;
    }

    .consultation-section {
        margin-top: 60px;
        padding: 0;
        min-height: calc(100vh - 60px);
        min-height: calc(100dvh - 60px);
    }

    .consultation-section .container {
        padding: 0;
        max-width: 100%;
    }

    /* 채팅 인터페이스 — 전체 화면 차지 */
    .chat-interface {
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
    }

    /* 채팅 헤더: 한 줄 — 최소 여백, 경계선 제거 */
    .chat-header {
        flex-wrap: nowrap;
        flex-shrink: 0;
        gap: 6px;
        padding: 2px var(--space-md);
        min-height: auto;
        border-bottom: none;
        background: transparent;
    }

    .chat-header__left {
        flex: 1;
    }

    .chat-header__center {
        flex: 0 0 auto;
    }

    /* 모바일에서 회원등급 배지 숨기기 */
    .chat-header__right {
        display: none;
    }

    .chat-header__title {
        font-size: 0.85rem;
    }

    .chat-header__turn {
        padding: 3px 8px;
        font-size: 10px;
        gap: 3px;
        white-space: nowrap;
    }

    /* 세션 히스토리 — 경계선/배경 제거 */
    .chat-sessions-wrap {
        flex-shrink: 0;
        padding: 2px var(--space-md);
        border-top: none;
        border-bottom: none;
        background: transparent;
    }

    .chat-sessions__title-row {
        margin-bottom: 2px;
        gap: 4px;
    }

    .chat-sessions__title {
        font-size: 11px;
    }

    .chat-sessions__desc {
        font-size: 9px;
    }

    .chat-sessions__list {
        gap: 4px;
    }

    .chat-session-item {
        font-size: 10px;
        padding: 2px 6px 2px 8px;
    }

    /* 팁 배너 — 최소 여백, 테두리 제거 */
    .tips-banner {
        flex-shrink: 0;
        padding: 3px var(--space-md);
        border-bottom: none;
    }

    .tips-banner__content {
        font-size: 10px;
        gap: 2px 8px;
        line-height: 1.3;
    }

    .tips-banner__title {
        font-size: 10px;
    }

    /* 메시지 영역 — 남은 공간 전부 차지 */
    .chat-messages {
        flex: 1;
        min-height: 0;
        padding: var(--space-sm) var(--space-md);
        padding-bottom: var(--space-md);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 채팅 입력 영역 — 하단 고정 */
    .chat-input-area {
        flex-shrink: 0;
        padding: var(--space-sm) var(--space-md);
        padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 8px));
        background: rgba(10, 14, 39, 0.98);
        border-top: 1px solid var(--border-subtle);
    }

    .chat-input-wrap {
        padding: 4px 4px 4px 14px;
        border-radius: 20px;
    }

    .chat-input {
        font-size: 0.9rem;
        min-height: 38px;
        padding: 8px 0;
    }

    .chat-input-area .btn--primary {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
}