/* Chat Page Styles */

.chat-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 100px var(--container-padding) 40px;
    min-height: calc(100vh - 60px);
}

.chat-wrapper {
    width: 100%;
    max-width: 800px;
    min-width: 0;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Chat Header with Category (통합된 헤더) */
.chat-header.chat-header-with-category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
}

.chat-header-left {
    flex: 1;
}

.chat-header-center {
    flex: 0 0 auto;
}

.chat-header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.category-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 100px;
}

.category-indicator.labor {
    color: var(--color-labor);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

.category-indicator.housing {
    color: var(--color-housing);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.category-indicator.consumer {
    color: var(--color-consumer);
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
}

.category-indicator.traffic {
    color: var(--color-traffic);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.chat-section .change-category-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-primary);
}

.chat-section .change-category-btn:hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-primary);
}

/* Chat Container for chat page */
.chat-section .chat-container {
    width: 100%;
    max-width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.chat-section .chat-messages {
    min-height: 450px;
    max-height: calc(100vh - 350px);
    height: 450px;
}

/* Chat Page Welcome & Examples */
.chat-section .chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    height: 100%;
    min-height: 400px;
}

.chat-section .welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
}

.chat-section .welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.chat-section .welcome-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    max-width: 400px;
    line-height: 1.5;
}

.chat-section .example-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.chat-section .welcome-examples {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 100%;
}

.chat-section .example-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.875rem;
    white-space: nowrap;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 100px;
    color: var(--color-primary-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-primary);
}

.chat-section .example-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

/* AI 메시지 단락 간격 개선 */
.chat-section .message-ai .message-content p {
    margin-bottom: 1.5em;
    line-height: 1.8;
}

.chat-section .message-ai .message-content p:last-child {
    margin-bottom: 0;
}

.chat-section .message-ai .message-content br {
    display: block;
    content: "";
    margin-bottom: 0.5em;
}

/* AI Notice */
.chat-ai-notice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 12px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.chat-ai-notice i {
    color: var(--color-gold);
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-ai-notice p {
    margin: 0;
}

/* 카카오 애드핏 광고 - chat 페이지 */
.chat-wrapper .adfit-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    min-height: 250px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.chat-wrapper .adfit-container ins {
    display: block !important;
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: var(--space-md);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(37, 99, 235, 0.95));
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    max-width: 600px;
    margin: 0 auto;
}

.pwa-install-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-install-icon i {
    color: white;
}

.pwa-install-text {
    flex: 1;
    color: white;
}

.pwa-install-text strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 4px;
}

.pwa-install-text p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.9;
}

.pwa-install-close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.pwa-install-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.pwa-install-close i {
    color: white;
}

/* Category Select Modal */
.category-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.category-modal.active {
    display: flex;
}

.category-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.category-modal-content {
    position: relative;
    max-width: 500px;
    width: 100%;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: var(--space-xl);
    z-index: 1;
}

.category-modal-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.category-modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

.category-modal-header p {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.category-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.category-modal-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: var(--space-lg) var(--space-md);
    font-family: var(--font-primary);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
}

.category-modal-btn:hover {
    transform: translateY(-2px);
}

.category-modal-btn.labor {
    color: var(--color-labor);
}
.category-modal-btn.labor:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.category-modal-btn.housing {
    color: var(--color-housing);
}
.category-modal-btn.housing:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.category-modal-btn.consumer {
    color: var(--color-consumer);
}
.category-modal-btn.consumer:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.category-modal-btn.traffic {
    color: var(--color-traffic);
}
.category-modal-btn.traffic:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.category-modal-btn-name {
    font-size: 1rem;
    font-weight: 600;
}

.category-modal-btn-desc {
    font-size: 0.8125rem;
    opacity: 0.7;
}

/* Responsive - 태블릿 */
@media (max-width: 768px) {
    .chat-section {
        padding: 70px var(--container-padding) 16px;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .chat-wrapper {
        gap: var(--space-md);
        height: calc(100vh - 86px);
        height: calc(100dvh - 86px);
    }

    .chat-section .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        max-height: none;
    }

    .chat-section .chat-messages {
        flex: 1;
        min-height: 0;
        max-height: none;
        height: auto;
    }

    .chat-section .chat-welcome {
        min-height: auto;
        padding: var(--space-lg) var(--space-md);
        flex: 1;
        justify-content: center;
    }

    .chat-section .welcome-examples {
        flex-direction: column;
        align-items: center;
        gap: var(--space-xs);
    }

    .chat-section .example-btn {
        width: auto;
        max-width: 100%;
        justify-content: center;
        white-space: normal;
        text-align: center;
    }

    /* 모바일에서 통합 헤더 스타일 */
    .chat-header.chat-header-with-category {
        flex-direction: column;
        gap: var(--space-xs);
        padding: var(--space-sm) var(--space-md);
    }

    .chat-header-left,
    .chat-header-right {
        flex: none;
        width: 100%;
        justify-content: center;
    }

    .chat-header-center {
        order: -1;
    }

    .chat-section .change-category-btn {
        margin-top: var(--space-xs);
    }

    .category-modal-grid {
        grid-template-columns: 1fr;
    }

    /* AI Notice 간소화 */
    .chat-ai-notice {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.8rem;
    }

    /* 모바일에서 "나", "AI" 아바타 숨김 */
    .message-avatar {
        display: none;
    }

    /* 광고 숨김 - 모바일에서 공간 확보 */
    .chat-wrapper .adfit-container {
        display: none;
    }

    /* 모바일 메뉴 스타일 */
    .nav-links, .nav-cta {
        display: none;
    }

    .nav-links.active {
        display: flex;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
        flex-direction: column;
        background: rgba(10, 15, 26, 0.98);
        backdrop-filter: blur(20px);
        padding: 2rem;
        padding-bottom: 100px;
        gap: 0.5rem;
        z-index: 99;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-links.active .nav-link {
        padding: 1rem;
        font-size: 1.1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-links.active .nav-divider {
        display: none;
    }

    .nav.scrolled .nav-links.active {
        top: 52px;
        height: calc(100vh - 52px);
        height: calc(100dvh - 52px);
    }

    .nav-mobile-toggle {
        display: flex;
    }

    .nav-mobile-toggle.active span:first-child {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-mobile-toggle.active span:last-child {
        transform: rotate(-45deg) translate(5px, -5px);
    }
}

/* 모바일 세로 모드 - 작은 화면 */
@media (max-width: 480px) {
    .chat-section {
        padding: 60px 12px 12px;
    }

    .chat-wrapper {
        gap: var(--space-sm);
        height: calc(100vh - 72px);
        height: calc(100dvh - 72px);
    }

    /* 네비게이션 컴팩트 */
    .chat-page .nav {
        padding: 8px 12px;
    }

    .chat-page .nav-logo .logo-text {
        font-size: 1.1rem;
    }

    /* 카테고리 헤더 더 작게 */
    .chat-category-header {
        padding: var(--space-xs) var(--space-sm);
        border-radius: 12px;
    }

    .category-indicator {
        font-size: 0.95rem;
    }

    .change-category-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* 채팅 컨테이너 풀 높이 */
    .chat-section .chat-container {
        border-radius: 16px;
    }

    .chat-section .chat-header {
        padding: var(--space-sm) var(--space-md);
    }

    .chat-section .chat-messages {
        padding: var(--space-sm);
    }

    /* 입력창 최적화 */
    .chat-input-container {
        padding: var(--space-sm);
    }

    .chat-input-wrapper {
        gap: 8px;
    }

    .chat-input-wrapper textarea {
        padding: 10px 14px;
        font-size: 16px; /* iOS 줌 방지 */
        min-height: 44px;
    }

    .chat-submit-btn {
        width: 44px;
        height: 44px;
    }

    .chat-disclaimer {
        font-size: 0.7rem;
        margin-top: 8px;
    }

    /* 메시지 스타일 */
    .message-content {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
    }

    .message-user {
        max-width: 85%;
    }

    .message-ai {
        max-width: 90%;
    }

    /* AI Notice 더 작게 */
    .chat-ai-notice {
        padding: 8px 12px;
        font-size: 0.75rem;
        border-radius: 8px;
        gap: 8px;
    }

    .chat-ai-notice i {
        width: 14px;
        height: 14px;
    }

    /* 웰컴 화면 최적화 */
    .chat-section .chat-welcome {
        padding: var(--space-md);
    }

    .chat-section .category-select {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .chat-section .category-btn {
        padding: var(--space-sm);
    }

    .chat-section .category-btn .icon-md {
        width: 24px;
        height: 24px;
    }

    .chat-section .category-name {
        font-size: 0.85rem;
    }

    .chat-section .category-desc {
        font-size: 0.7rem;
    }
}

/* 아주 작은 화면 (iPhone SE 등) */
@media (max-width: 375px) {
    .chat-section {
        padding: 56px 8px 8px;
    }

    .chat-wrapper {
        gap: 8px;
        height: calc(100vh - 64px);
        height: calc(100dvh - 64px);
    }

    .chat-category-header {
        padding: 8px 12px;
    }

    .category-indicator {
        font-size: 0.9rem;
    }

    .chat-section .chat-container {
        border-radius: 12px;
    }

    .chat-section .chat-messages {
        padding: 8px;
    }

    .chat-input-wrapper textarea {
        padding: 8px 12px;
    }

    .chat-ai-notice {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    /* 카테고리 버튼 더 작게 */
    .chat-section .category-select {
        gap: 6px;
    }

    .chat-section .category-btn {
        padding: 8px;
    }

    .chat-section .category-name {
        font-size: 0.8rem;
    }

    .chat-section .category-desc {
        display: none;
    }
}

/* 가로 모드 */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-section {
        padding: 50px 16px 8px;
    }

    .chat-wrapper {
        flex-direction: row;
        gap: var(--space-md);
        height: calc(100vh - 58px);
        height: calc(100dvh - 58px);
    }

    .chat-category-header {
        display: none;
    }

    .chat-section .chat-container {
        flex: 1;
    }

    .chat-section .chat-messages {
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }

    .chat-ai-notice {
        display: none;
    }
}
