/* ==================== 東方術數風格 CSS（精緻版）==================== */

/* 深墨色漸層背景 */
body {
    margin: 0;
    padding: 0;
    font-family: 'Microsoft YaHei', '微軟正黑體', 'STKaiti', 'KaiTi', serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1410 50%, #2d2416 100%);
    min-height: 100vh;
    color: #f5f5dc;
    position: relative;
    overflow-x: hidden;
}

/* 水墨背景效果（增強版）*/
.ink-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(200, 16, 46, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(212, 175, 55, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(200, 16, 46, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: inkFlow 20s ease-in-out infinite;
}

/* 水墨流動動畫 */
@keyframes inkFlow {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* 太極符號裝飾 */
body::after {
    content: '☯';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30rem;
    color: rgba(212, 175, 55, 0.02);
    z-index: 0;
    pointer-events: none;
    animation: taichiRotate 60s linear infinite;
}

@keyframes taichiRotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* 主容器 */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* 標題區（增強版）*/
.header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2.5rem;
    background:
        linear-gradient(135deg,
            rgba(200, 16, 46, 0.25) 0%,
            rgba(212, 175, 55, 0.18) 50%,
            rgba(200, 16, 46, 0.25) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><text x="50%" y="50%" font-size="60" text-anchor="middle" dominant-baseline="middle" opacity="0.05" fill="%23d4af37">☯</text></svg>');
    border: 3px double #d4af37;
    border-radius: 15px;
    box-shadow:
        0 0 40px rgba(200, 16, 46, 0.4),
        inset 0 0 30px rgba(212, 175, 55, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.8s ease-out, headerGlow 3s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

/* 標題光暈動畫 */
@keyframes headerGlow {

    0%,
    100% {
        box-shadow:
            0 0 40px rgba(200, 16, 46, 0.4),
            inset 0 0 30px rgba(212, 175, 55, 0.15),
            0 8px 32px rgba(0, 0, 0, 0.6);
    }

    50% {
        box-shadow:
            0 0 50px rgba(200, 16, 46, 0.6),
            inset 0 0 40px rgba(212, 175, 55, 0.25),
            0 8px 32px rgba(0, 0, 0, 0.6);
    }
}

/* 標題裝飾線 */
.header::before,
.header::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg,
            transparent 0%,
            #d4af37 50%,
            transparent 100%);
}

.header::before {
    top: 1rem;
}

.header::after {
    bottom: 1rem;
}

.header h1 {
    color: #c8102e;
    font-size: 2.8rem;
    margin: 0;
    text-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(200, 16, 46, 0.5);
    letter-spacing: 0.4rem;
    font-weight: bold;
    position: relative;
}

/* 標題太極裝飾 */
.header h1::before {
    content: '☯ ';
    color: #d4af37;
    font-size: 1.2em;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.8);
}

.header h1::after {
    content: ' ☯';
    color: #d4af37;
    font-size: 1.2em;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.8);
}

.header .subtitle {
    color: #d4af37;
    font-size: 1.2rem;
    margin: 1rem 0 0 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.2rem;
}

/* 歡迎卡片（竹簡風格增強）*/
.welcome-card {
    background:
        linear-gradient(180deg,
            rgba(42, 35, 25, 0.98) 0%,
            rgba(35, 28, 20, 1) 100%),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 10px,
            rgba(212, 175, 55, 0.03) 10px,
            rgba(212, 175, 55, 0.03) 11px);
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.8),
        inset 0 2px 0 rgba(212, 175, 55, 0.4),
        inset 0 -2px 0 rgba(200, 16, 46, 0.3);
    animation: slideIn 0.8s ease-out;
    position: relative;
}

/* 卡片邊角裝飾 */
.welcome-card::before,
.welcome-card::after {
    content: '◆';
    position: absolute;
    color: #d4af37;
    font-size: 1.5rem;
    opacity: 0.6;
}

.welcome-card::before {
    top: 1rem;
    left: 1rem;
}

.welcome-card::after {
    bottom: 1rem;
    right: 1rem;
}

.welcome-card h2 {
    color: #d4af37;
    border-left: 5px solid #c8102e;
    padding-left: 1.5rem;
    margin-top: 0;
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    position: relative;
}

.welcome-card h2::before {
    content: '◈';
    position: absolute;
    left: -0.3rem;
    color: #c8102e;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.welcome-card p {
    line-height: 2;
    color: #f5f5dc;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

.welcome-card strong {
    color: #d4af37;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
}

/* 表格樣式（古籍風格）*/
.service-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: rgba(20, 15, 10, 0.9);
    border: 3px solid #d4af37;
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(212, 175, 55, 0.1);
}

.service-table th {
    background: linear-gradient(135deg,
            rgba(200, 16, 46, 0.5) 0%,
            rgba(200, 16, 46, 0.7) 100%);
    color: #d4af37;
    font-weight: bold;
    padding: 1.2rem;
    border-bottom: 3px solid #d4af37;
    text-align: left;
    font-size: 1.1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.1rem;
}

.service-table td {
    padding: 1.2rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    color: #f5f5dc;
    background: rgba(42, 35, 25, 0.3);
    transition: all 0.3s ease;
}

.service-table tr:hover td {
    background: rgba(200, 16, 46, 0.25);
    color: #fff;
    transform: scale(1.01);
}

.hint {
    color: #d4af37;
    font-style: italic;
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(212, 175, 55, 0.1);
    border-left: 4px solid #d4af37;
    border-radius: 5px;
}

/* 聊天容器 */
.chat-container {
    min-height: 200px;
    overflow-y: auto;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background:
        linear-gradient(180deg,
            rgba(42, 35, 25, 0.6) 0%,
            rgba(35, 28, 20, 0.7) 100%);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 15px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
    display: none;
    /* 一開始隱藏 */
}

/* 有訊息時顯示 */
.chat-container.has-messages {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

/* 聊天訊息（增強版）*/
.message {
    margin-bottom: 2rem;
    padding: 1.8rem;
    border-radius: 12px;
    animation: messageSlide 0.5s ease-out;
    white-space: pre-wrap;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* 用戶訊息 - 朱砂印章風格 */
.message.user {
    background:
        linear-gradient(135deg, #c8102e 0%, #a00d26 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50"><circle cx="25" cy="25" r="20" fill="none" stroke="%23d4af37" stroke-width="1" opacity="0.2"/></svg>');
    color: #f5f5dc;
    border: 3px solid #d4af37;
    box-shadow:
        0 6px 20px rgba(200, 16, 46, 0.6),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
    margin-left: 10%;
    font-weight: 500;
}

.message.user::before {
    content: '◉';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: #d4af37;
    font-size: 1.5rem;
    opacity: 0.6;
}

/* AI 訊息 - 古卷風格 */
.message.bot {
    white-space: normal;
    background:
        linear-gradient(180deg,
            rgba(42, 35, 25, 0.98) 0%,
            rgba(35, 28, 20, 1) 100%);
    border: 3px solid rgba(212, 175, 55, 0.6);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(212, 175, 55, 0.1);
    color: #f5f5dc;
    margin-right: 10%;
    border-left: 5px solid #c8102e;
}

.message.bot::before {
    content: '卜';
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    color: #c8102e;
    font-size: 1.8rem;
    font-weight: bold;
    opacity: 0.4;
}

/* Markdown 樣式優化 */
.message.bot strong {
    color: #ffd700;
    font-weight: bold;
    border-bottom: 1px dashed rgba(255, 215, 0, 0.4);
    padding: 0 2px;
}

.message.bot p {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.message.bot p:last-child {
    margin-bottom: 0;
}

.message.bot br {
    display: none;
}

.message.bot ol,
.message.bot ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.message.bot li {
    margin-bottom: 0.5rem;
    position: relative;
    list-style-type: decimal;
}

.message.bot ul li {
    list-style-type: disc;
}

.message.bot h1,
.message.bot h2,
.message.bot h3 {
    color: #d4af37;
    margin: 1.5rem 0 0.8rem 0;
    border-left: 4px solid #c8102e;
    padding-left: 1rem;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* 輸入區域（增強版）*/
.input-area {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

#userInput {
    flex: 1;
    padding: 1.2rem;
    background:
        linear-gradient(180deg,
            rgba(20, 15, 10, 0.95) 0%,
            rgba(15, 10, 5, 1) 100%);
    border: 3px solid rgba(212, 175, 55, 0.6);
    border-radius: 10px;
    color: #f5f5dc;
    font-size: 1.1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 140px;
    box-shadow:
        inset 0 2px 10px rgba(0, 0, 0, 0.6),
        0 4px 15px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

#userInput:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow:
        0 0 20px rgba(212, 175, 55, 0.5),
        inset 0 2px 10px rgba(0, 0, 0, 0.6);
    transform: scale(1.01);
}

#userInput::placeholder {
    color: rgba(245, 245, 220, 0.4);
}

/* 送出按鈕（古符印章風格）*/
.send-btn {
    padding: 1.2rem 2.5rem;
    background:
        linear-gradient(135deg, #8b0000 0%, #5a0000 100%),
        repeating-linear-gradient(45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px);
    color: #f5f5dc;
    border: 4px double #d4af37;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow:
        0 6px 20px rgba(139, 0, 0, 0.8),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        inset 0 -2px 5px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.2rem;
}

/* 古符紋理效果 */
.send-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 30% 30%, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(212, 175, 55, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: 0;
}

.send-btn:hover::before {
    width: 300px;
    height: 300px;
}

.send-btn:hover {
    background:
        linear-gradient(135deg, #a00000 0%, #6a0000 100%),
        repeating-linear-gradient(45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px);
    transform: translateY(-3px);
    box-shadow:
        0 8px 25px rgba(139, 0, 0, 1),
        inset 0 2px 0 rgba(255, 255, 255, 0.2),
        inset 0 -2px 5px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(212, 175, 55, 0.5);
    border-color: #e4bf47;
}

.send-btn:active {
    transform: translateY(-1px);
    box-shadow:
        0 4px 15px rgba(139, 0, 0, 0.8),
        inset 0 2px 5px rgba(0, 0, 0, 0.6);
}

/* 範例按鈕（竹簡風格）*/
.examples {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.example-btn {
    padding: 0.9rem 1.5rem;
    background:
        linear-gradient(135deg,
            rgba(42, 35, 25, 0.9) 0%,
            rgba(35, 28, 20, 0.95) 100%);
    border: 2px solid rgba(212, 175, 55, 0.6);
    border-radius: 10px;
    color: #d4af37;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    position: relative;
}

.example-btn::before {
    content: '☯';
    margin-right: 0.5rem;
    color: #c8102e;
    opacity: 0.8;
    font-size: 1.1em;
}

.example-btn:hover {
    background:
        linear-gradient(135deg,
            rgba(200, 16, 46, 0.5) 0%,
            rgba(200, 16, 46, 0.7) 100%);
    border-color: #d4af37;
    color: #f5f5dc;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(200, 16, 46, 0.5);
}

/* 影片容器 */
.video-container {
    margin: 1.5rem auto;
    max-width: 650px;
    border: 3px solid #d4af37;
    border-radius: 15px;
    overflow: hidden;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(212, 175, 55, 0.3);
    animation: fadeIn 1s ease-out;
}

.intro-video {
    width: 100%;
    height: auto;
    display: block;
}

/* 頁尾（古籍風格 - 縮小版）*/
.footer {
    background:
        linear-gradient(180deg,
            rgba(42, 35, 25, 0.75) 0%,
            rgba(35, 28, 20, 0.8) 100%);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 10px;
    padding: 1.2rem;
    text-align: center;
    margin-top: 3rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    opacity: 0.7;
}

.footer h3 {
    color: #d4af37;
    margin-top: 0;
    font-size: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.footer p {
    color: #f5f5dc;
    margin: 0.3rem 0;
    line-height: 1.4;
    font-size: 0.8rem;
}

.footer hr {
    border: none;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    margin: 1rem 0;
}

.disclaimer {
    font-size: 0.75rem;
    color: rgba(245, 245, 220, 0.6);
    font-style: italic;
}

/* 滾動條樣式（古銅風格增強）*/
::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 7px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d4af37 0%, #8b7355 100%);
    border-radius: 7px;
    border: 2px solid rgba(200, 16, 46, 0.5);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #e4bf47 0%, #9b8365 100%);
    box-shadow:
        inset 0 0 6px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(212, 175, 55, 0.6);
}

/* 動畫定義 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 2rem;
        letter-spacing: 0.2rem;
    }

    .input-area {
        flex-direction: column;
    }

    .send-btn {
        width: 100%;
    }

    .message.user,
    .message.bot {
        margin-left: 0;
        margin-right: 0;
    }

    body::after {
        font-size: 15rem;
    }
}

/* 對話管理按鈕 */
.chat-controls {
    display: none;
    /* 預設隱藏，由 JavaScript 控制顯示 */
    justify-content: flex-end;
    gap: 0.8rem;
    padding: 1rem;
    background: linear-gradient(180deg,
            rgba(42, 35, 25, 0.95) 0%,
            rgba(35, 28, 20, 0.98) 100%);
    border-top: 2px solid rgba(212, 175, 55, 0.3);
    margin-top: 1rem;
    position: sticky;
    bottom: 0;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.chat-controls:hover {
    opacity: 1;
}

.control-btn {
    padding: 0.6rem 1.2rem;
    border: 2px solid rgba(212, 175, 55, 0.5);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-family: inherit;
}

.clear-btn {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.7) 0%, rgba(90, 0, 0, 0.8) 100%);
    color: #f5f5dc;
}

.clear-btn:hover {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.8) 0%, rgba(139, 0, 0, 0.9) 100%);
    border-color: #d4af37;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(200, 16, 46, 0.5);
}

.download-btn {
    background: linear-gradient(135deg, rgba(42, 35, 25, 0.8) 0%, rgba(35, 28, 20, 0.9) 100%);
    color: #d4af37;
}

.download-btn:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3) 0%, rgba(42, 35, 25, 0.9) 100%);
    border-color: #d4af37;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.4);
}

.control-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}