@charset "utf-8";

/* ========================================
   AI Chat Guest Page
   ======================================== */

/* 隱藏整個頁面的滾動條 */
html.aichat-page,
body.aichat-page {
    overflow: hidden !important;
    height: 100% !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

html.aichat-page::-webkit-scrollbar,
body.aichat-page::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* 為 guest 容器 - 整體版面往上 */
.aichat-guest-container {
    background: linear-gradient(135deg, #fff5ca 0%, #fffad9 100%);
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari 動態視窗高度 */
    height: 100vh;
    height: 100dvh;
    padding: 15px 0 10px;
    overflow: hidden !important;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.aichat-guest-container::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.aichat-guest-container .container {
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
}

/* 標題區域 - 縮小間距 */
.aichat-title {
    text-align: center;
    padding: 0.3rem 0;
    margin-bottom: 0.3rem;
    animation: bounceIn .8s ease-out;
}

.aichat-title img {
    max-width: 100%;
    height: auto;
    width: 180px;
    transition: transform .3s ease;
    display: block;
    margin: 0 auto;
}

@media (hover: hover) and (pointer: fine) {
    .aichat-title img:hover {
        transform: scale(1.05) rotate(-2deg);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* 按鈕區域 - 兩側分佈 */
.aichat-button-bar {
    display: none;
    padding: 0.3rem 0;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
    animation: slideDown .4s ease-out;
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.aichat-button-bar.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 切換模式按鈕 - 白底橘框溫暖風格 */
.aichat-btn-switch {
    padding: 4px 14px;
    border: 1.5px solid #F5A623;
    border-radius: 15px;
    background: #fff;
    color: #F5A623;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    display: inline-flex;
    align-items: center;
    /*gap: 6px;*/
    height: 30px;
    box-sizing: border-box;
}

.aichat-btn-switch:hover {
    background: rgba(245, 166, 35, 0.08);
    border-color: #E8941F;
    color: #E8941F;
}

.aichat-btn-switch:active {
    background: rgba(245, 166, 35, 0.15);
}

.aichat-btn-switch::before {
    content: '';
}

.aichat-btn-switch .btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* 儲存對話按鈕 - 橘色背景溫暖風格 */
.aichat-btn-save {
    padding: 4px 16px;
    border: none;
    border-radius: 15px;
    background: #F5A623;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
}

.aichat-btn-save:hover {
    background: #E8941F;
    box-shadow: 0 3px 12px rgba(245, 166, 35, 0.4);
}

.aichat-btn-save:active {
    background: #D98518;
}

.aichat-btn-save .btn-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-right: -8px;
    margin-top: -4px;
    margin-bottom: -4px;
}

.aichat-mode-label {
    padding: .5rem 1rem;
    background: #fff;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.aichat-mode-label.member {
    color: #06C755;
}

.aichat-mode-label.guest {
    color: #FF6B35;
}

.aichat-mode-label::before {
    margin-right: .3rem;
}

.aichat-mode-label.member::before {
    content: '👤';
}

.aichat-mode-label.guest::before {
    content: '💬';
}

/* Chat 容器 - 減少圓角，增加高度，防止 overflow */
.aichat-chat-container {
    background: #fff;
    border-radius: 12px;
    border: 3px solid #fff;
    box-shadow: 0 6px 16px rgba(255, 140, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: none;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 100px);
    height: calc(100dvh - 100px); /* iOS Safari 動態視窗高度 */
    animation: slideUp .6s ease-out;
    -webkit-overflow-scrolling: touch;
    /* 隱藏滾動條 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    flex: 1;
}

.aichat-chat-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

.aichat-chat-container.show {
    display: block;
}

.aichat-chat-container iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 載入動畫 */
.aichat-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 191, 59, 0.95);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
}

.aichat-loading-overlay.show {
    display: flex;
    animation: fadeIn .3s ease-out;
}

.aichat-loading-spinner {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.aichat-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.aichat-loading-text {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
   響應式設計
   ======================================== */

/* 極小手機版 (< 360px) */
@media (max-width: 359px) {
    .aichat-guest-container {
        padding: 0px 0 2px;
    }

    .aichat-title {
        padding: .2rem 0;
        margin-bottom: .2rem;
    }

    .aichat-title img {
        width: 140px;
    }

    .aichat-button-bar {
        gap: .3rem;
        padding: .2rem 0;
        margin-bottom: .2rem;
    }

    .aichat-btn-switch,
    .aichat-btn-save {
        font-size: .75rem;
        padding: 4px 10px;
        height: 28px;
    }

    .aichat-chat-container {
        height: calc(100vh - 95px);
        height: calc(100dvh - 95px);
        border-radius: 10px;
        border-width: 2px;
    }
}

/* 小手機版 (360px - 575px) */
@media (min-width: 360px) and (max-width: 575px) {
    .aichat-guest-container {
        padding: 0 0 4px;
    }

    .aichat-title {
        padding: .2rem 0;
        margin-bottom: .2rem;
    }

    .aichat-title img {
        width: 150px;
    }

    .aichat-button-bar {
        gap: .3rem;
        padding: .2rem 0;
        margin-bottom: .2rem;
    }

    .aichat-btn-switch,
    .aichat-btn-save {
        font-size: .8rem;
        padding: 4px 12px;
        height: 28px;
    }

    .aichat-chat-container {
        height: calc(100vh - 100px);
        height: calc(100dvh - 100px);
        border-radius: 10px;
        border-width: 2px;
    }
}

/* 平板版 (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .aichat-guest-container {
        padding: 0 0 5px;
    }

    .aichat-title img {
        width: 170px;
    }

    .aichat-chat-container {
        height: calc(100vh - 110px);
        height: calc(100dvh - 110px);
        border-radius: 12px;
    }
}

/* 桌面版 (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .aichat-guest-container {
        padding: 0 0 5px;
    }

    .aichat-title img {
        width: 180px;
    }

    .aichat-chat-container {
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
        border-radius: 12px;
    }
}

/* 大桌面版 (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .aichat-guest-container {
        padding: 0 0 5px;
    }

    .aichat-title img {
        width: 200px;
    }

    .aichat-chat-container {
        height: calc(100vh - 140px);
        height: calc(100dvh - 140px);
    }
}

/* 超大桌面版 (>= 1200px) */
@media (min-width: 1200px) {
    .aichat-guest-container {
        padding: 0 0 5px;
    }

    .aichat-title {
        margin-bottom: 0.5rem;
    }

    .aichat-button-bar {
        margin-bottom: 0.5rem;
    }

    .aichat-title img {
        width: 220px;
    }

    .aichat-chat-container {
        height: calc(100vh - 150px);
        height: calc(100dvh - 150px);
    }
}

/* 超超大桌面版 (>= 1400px) */
@media (min-width: 1400px) {
    .aichat-chat-container {
        height: calc(100vh - 160px);
        height: calc(100dvh - 160px);
    }
}

/* 橫屏模式調整 */
@media (orientation: landscape) and (max-height: 600px) {
    .aichat-guest-container {
        padding: 0 0 5px;
    }

    .aichat-title {
        padding: .2rem 0;
        margin-bottom: .3rem;
    }

    .aichat-title img {
        max-height: 40px;
        width: auto;
    }

    .aichat-button-bar {
        padding: .2rem 0;
        margin-bottom: .3rem;
    }

    .aichat-chat-container {
        height: calc(100vh - 100px);
    }
}

/* 手機橫屏 */
@media (max-width: 767px) and (orientation: landscape) {
    .aichat-chat-container {
        height: calc(100vh - 95px);
    }
}

/* 平板橫屏 */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .aichat-chat-container {
        height: calc(100vh - 120px);
    }
}

/* 減少動畫效果 (可訪問性) */
@media (prefers-reduced-motion: reduce) {
    .aichat-guest-container *,
    .aichat-loading-overlay * {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* 高解析度屏幕優化 */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    .aichat-title img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ========================================
   溫馨提醒區塊
   ======================================== */
.aichat-reminder {
    margin-top: 3px;
    text-align: center;
}

.aichat-reminder-text {
    color: #999;
    font-size: 0.75rem;
    line-height: 1.4;
    margin: 0;
}

.aichat-reminder-text a {
    color: #5b9bd5;
    text-decoration: underline;
}

.aichat-reminder-text a:hover {
    color: #4a8bc4;
}
