@charset "utf-8";

/* ========================================
   AI Chat Member 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;
}

/* 為 member 容器 - 整體版面往上 */
.aichat-member-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-member-container::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.aichat-member-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-history {
    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;
    height: 30px;
    box-sizing: border-box;
    text-decoration: none;
    white-space: nowrap;
}

.aichat-btn-history:hover {
    background: rgba(245, 166, 35, 0.08);
    border-color: #E8941F;
    color: #E8941F;
    text-decoration: none;
}

.aichat-btn-history:active {
    background: rgba(245, 166, 35, 0.15);
}

.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: #FF6B35;
}

.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-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    backdrop-filter: blur(4px);
}

.aichat-overlay.show {
    display: block;
    animation: fadeIn .3s ease-out;
}

.aichat-message-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 2rem 1.5rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    text-align: center;
    width: 90%;
    max-width: 400px;
    display: none;
    animation: popIn .3s ease-out;
}

.aichat-message-box.show {
    display: block;
}

.aichat-message-box h3 {
    margin: 0 0 1rem;
    color: #ff6b35;
    font-size: 1.3rem;
}

.aichat-message-box p {
    margin: 0 0 1.5rem;
    color: #666;
    line-height: 1.6;
    font-size: 1rem;
}

/* dialog 按鈕容器 - 手機版垂直排列 */
.aichat-message-box .dialog-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.aichat-message-box button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #FF8C42 0%, #FF6B35 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    width: 100%;
}

.aichat-message-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.aichat-message-box button.btn-secondary {
    background: #fff;
    color: #F5A623;
    border: 1.5px solid #F5A623;
}

.aichat-message-box button.btn-secondary:hover {
    background: rgba(245, 166, 35, 0.08);
    box-shadow: none;
    transform: translateY(-2px);
}

/* 桌面版 dialog 按鈕可以並排 */
@media (min-width: 576px) {
    .aichat-message-box {
        padding: 2.5rem 2rem;
        max-width: 450px;
    }
    
    .aichat-message-box .dialog-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .aichat-message-box button {
        width: auto;
        min-width: 120px;
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 載入動畫 */
.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-member-container {
        padding: 0 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 {
        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;
    }

    .aichat-message-box {
        max-width: 90%;
        padding: 1.5rem;
    }
}

/* 小手機版 (360px - 575px) */
@media (min-width: 360px) and (max-width: 575px) {
    .aichat-member-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 {
        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-member-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-member-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-member-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-member-container {
        padding: 0 0 5px;
    }

    .aichat-title {
        margin-bottom: 0.5rem;
    }

    .aichat-title img {
        width: 220px;
    }

    .aichat-button-bar {
        margin-bottom: 0.5rem;
    }

    .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-member-container {
        padding: 0 0 2px;
    }

    .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-member-container *,
    .aichat-loading-overlay *,
    .aichat-message-box * {
        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;
}

/* ========================================
   前導頁面樣式
   ======================================== */
.aichat-intro-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    flex: 1;
    min-height: calc(100vh - 150px);
}

.aichat-intro-card {
    background: #fff;
    border-radius: 25px;
    padding: 2.5rem 2rem;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 8px 30px rgba(255, 140, 0, 0.2);
}

.aichat-intro-title {
    color: #FF6B35;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.aichat-intro-subtitle {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 1.8rem;
    line-height: 1.7;
}

.aichat-intro-benefits {
    text-align: left;
    margin-bottom: 2rem;
    padding: 0 15px;
}

.aichat-intro-benefit {
    color: #555;
    font-size: 1rem;
    margin-bottom: 0.8rem;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
}

.aichat-intro-benefit .check {
    color: #4CAF50;
    margin-right: 8px;
    font-weight: bold;
}

.aichat-intro-login-btn {
    display: inline-block;
    background: linear-gradient(135deg, #06C755 0%, #00B900 100%);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 14px 45px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(6, 199, 85, 0.3);
}

.aichat-intro-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 199, 85, 0.4);
    color: #fff;
    text-decoration: none;
}

.aichat-intro-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.aichat-intro-remember input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #06C755;
}

.aichat-intro-remember label {
    color: #666;
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
}

.aichat-intro-guest-link {
    display: block;
    margin-top: 1.5rem;
    color: #999;
    font-size: 0.95rem;
    text-decoration: underline;
}

.aichat-intro-guest-link:hover {
    color: #777;
}
