/* ==========================================================================
   紫微斗數排盤系統 - 主要樣式表
   ========================================================================== */

/* Google Fonts 導入 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;600;700&family=Ma+Shan+Zheng&family=Zcool+KuaiLe&family=LXGW+WenKai+TC:wght@400&display=swap');

/* ==========================================================================
   字體類別定義
   ========================================================================== */

.font-noto-serif {
    font-family: 'Noto Serif TC', serif;
}

.font-noto-sans {
    font-family: 'Noto Sans TC', sans-serif;
}

.font-ma-shan-zheng {
    font-family: 'Ma Shan Zheng', cursive;
}

.font-zcool-kuaile {
    font-family: 'Zcool KuaiLe', sans-serif;
}

.font-lxgw-wenkai {
    font-family: 'LXGW WenKai TC', cursive;
}

/* ==========================================================================
   基礎樣式與暗模式
   ========================================================================== */

body {
    font-family: 'Noto Serif TC', serif;
    transition: all 0.3s ease;
    color: #1F2937; /* 日間模式深色字體 */
}

body.dark {
    color: #F3F4F6; /* 夜間模式淺色字體 */
    background: #374151; /* 夜間模式淺灰色背景 */
}

/* 極簡模式在夜間模式下的特殊處理 */
body.dark:not([class*="-theme"]) .palace-cell {
    background: rgba(107, 114, 128, 0.8); /* 夜間模式下的宮位背景 */
}

body.dark:not([class*="-theme"]) .form-container {
    background: rgba(107, 114, 128, 0.9); /* 夜間模式下的表單背景 */
}

body.dark:not([class*="-theme"]) .settings-panel {
    background: rgba(75, 85, 99, 0.95); /* 夜間模式下的設定面板背景 */
}

body.dark:not([class*="-theme"]) .export-container {
    background: rgba(75, 85, 99, 0.95); /* 夜間模式下的匯出容器背景 */
}

/* ==========================================================================
   宮位單元格樣式
   ========================================================================== */

.palace-cell {
    min-height: 240px;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    position: relative;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.palace-cell:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.palace-cell.sanfang-highlight {
    border: 3px solid #3B82F6 !important;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6) !important;
    background: rgba(59, 130, 246, 0.05);
}

.dark .palace-cell { 
    border-color: #6B7280; 
    background: rgba(75, 85, 99, 0.8);
    color: #F3F4F6;
}

/* ==========================================================================
   星曜樣式
   ========================================================================== */

.star-zw, .star-tf, .star-other, .star-auxiliary, .star-malefic { 
    color: #8B5CF6; 
    font-weight: 500; 
    font-size: 1.125rem; 
    line-height: 1.1; 
    cursor: pointer; 
}

.star-tf { color: #1E3A8A; } /* 天府星系：深藍色 */
.star-auxiliary { color: #3B82F6; } /* 輔星：藍色 */
.star-malefic { color: #BE185D; } /* 煞星：深粉紅色 */
.star-other { color: #374151; }

.dark .star-other { color: #E5E7EB; }
.dark .star-auxiliary { color: #60A5FA; } /* 夜間模式下的輔星顏色 */
.dark .star-malefic { color: #F472B6; } /* 夜間模式下的煞星顏色 */

/* 四化星樣式 */
.star-four { font-size: 0.975rem; color: #EF4444; font-weight: 600; }
.star-four-daxian { font-size: 0.975rem; color: #10B981; font-weight: 600; }
.star-four-liunian { font-size: 0.975rem; color: #269cfc; font-weight: 600; }

/* 星曜亮度樣式 */
.star-brightness { font-size: 0.975rem; color: #6B7280; font-weight: 400; cursor: pointer; }
.dark .star-brightness { color: #D1D5DB; }

/* ==========================================================================
   特殊星曜樣式
   ========================================================================== */

.doctor-stars {
    font-size: 1.125rem;
    color: #F59E0B;
    font-weight: 500;
    line-height: 1.1;
}

.longevity-star {
    font-size: 1.125rem;
    color: #10B981;
    font-weight: 500;
}

.jiang-qian-stars {
    font-size: 1.125rem;
    color: #9CA3AF;
    font-weight: 500;
    line-height: 1.1;
}

.dark .jiang-qian-stars {
    color: #6B7280;
}

/* ==========================================================================
   宮位信息樣式
   ========================================================================== */

.palace-name { 
    font-size: 1.125rem; 
    font-weight: 600; 
    color: #1F2937; 
    cursor: pointer; 
}

.dark .palace-name { color: #F3F4F6; }

.daxian-info {
    font-size: 1.125rem;
    color: #3B82F6;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.1);
    padding: 1px 4px;
    border-radius: 4px;
}

.tianGan-diZhi {
    font-size: 1.125rem;
    color: #6B7280;
    font-weight: 500;
}

.dark .tianGan-diZhi { color: #D1D5DB; }

.special-position {
    font-size: 1.125rem;
    color: #EF4444;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    padding: 1px 2px;
    border-radius: 2px;
    margin-top: 1px;
}

/* ==========================================================================
   中央信息區域樣式
   ========================================================================== */

.center-info { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    color: white;
}

.dark .center-info { 
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-color: #6B7280; 
}

/* ==========================================================================
   表單容器樣式
   ========================================================================== */

.form-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.dark .form-container {
    background: rgba(75, 85, 99, 0.9);
    border-color: rgba(107, 114, 128, 0.3);
}

/* ==========================================================================
   按鈕樣式
   ========================================================================== */

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px 0 rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px 0 rgba(102, 126, 234, 0.5);
}

.toggle-btn {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px solid #d1d5db;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.dark .toggle-btn {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    border-color: #6b7280;
    color: #f9fafb;
}

.dark .toggle-btn:hover {
    background: linear-gradient(135deg, #4b5563 0%, #6b7280 100%);
}

/* 主題按鈕樣式 */
.theme-btn {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px solid #d1d5db;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.theme-btn:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    transform: translateY(-1px);
}

.theme-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.dark .theme-btn {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    border-color: #6b7280;
    color: #f9fafb;
}

.dark .theme-btn:hover {
    background: linear-gradient(135deg, #4b5563 0%, #6b7280 100%);
}

/* ==========================================================================
   表單輸入框樣式
   ========================================================================== */

.form-input {
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
}

.form-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.dark .form-input {
    background: rgba(55, 65, 81, 0.8);
    border-color: #4B5563;
    color: #F9FAFB;
}

/* ==========================================================================
   設定面板樣式
   ========================================================================== */

.settings-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(229, 231, 235, 0.5);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.dark .settings-panel {
    background: rgba(31, 41, 55, 0.95);
    border-color: rgba(75, 85, 99, 0.5);
}

/* ==========================================================================
   匯出容器樣式
   ========================================================================== */

.export-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(229, 231, 235, 0.5);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.dark .export-container {
    background: rgba(31, 41, 55, 0.95);
    border-color: rgba(75, 85, 99, 0.5);
}

/* ==========================================================================
   浮動按鈕樣式
   ========================================================================== */

.floating-tab-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #667eea;
    border-radius: 50px;
    padding: 4px 6px;
    color: white;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    backdrop-filter: blur(10px);
    min-width: 36px;
}

.floating-tab-btn:hover:not(.disabled) {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.floating-tab-btn.disabled {
    background: linear-gradient(135deg, #9CA3AF 0%, #6B7280 100%);
    border-color: #9CA3AF;
    color: #D1D5DB;
    cursor: not-allowed;
    box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
}

.floating-tab-btn.disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
}

.dark .floating-tab-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-color: #6366f1;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.dark .floating-tab-btn:hover:not(.disabled) {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.dark .floating-tab-btn.disabled {
    background: linear-gradient(135deg, #4B5563 0%, #374151 100%);
    border-color: #4B5563;
    color: #6B7280;
}

/* ==========================================================================
   解釋彈窗樣式
   ========================================================================== */

.explanation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.explanation-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    margin: 1rem;
}

.dark .explanation-content {
    background: #1f2937;
    color: #f9fafb;
}

/* ==========================================================================
   三方四正線條樣式
   ========================================================================== */

.sanfang-line {
    position: absolute;
    border: 2px dashed #3B82F6;
    opacity: 0.6;
    pointer-events: none;
    z-index: 10;
}

/* ==========================================================================
   動畫效果
   ========================================================================== */

/* 星曜閃動動畫 */
@keyframes starBlink {
    0%, 50% { 
        opacity: 1; 
        background-color: rgba(255, 255, 0, 0.3); 
        transform: scale(1);
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    }
    25%, 75% { 
        opacity: 0.7; 
        background-color: rgba(255, 215, 0, 0.6); 
        transform: scale(1.05);
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
    }
}

/* ==========================================================================
   主題變體樣式
   ========================================================================== */

/* Retro Theme */
body.retro-theme {
    background: linear-gradient(135deg, #8B5A2B 0%, #CD853F 100%);
}

body.retro-theme .palace-cell {
    background: rgba(222, 184, 135, 0.9);
    border: 2px solid #8B4513;
    box-shadow: 0 4px 8px rgba(139, 69, 19, 0.3);
}

body.retro-theme .center-info {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
}

body.retro-theme .form-container {
    background: rgba(222, 184, 135, 0.95);
    border: 2px solid #8B4513;
}

body.retro-theme .btn-primary {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
}

body.retro-theme .settings-panel {
    background: rgba(210, 180, 140, 0.95);
    border: 2px solid #8B4513;
}

body.retro-theme .export-container {
    background: rgba(210, 180, 140, 0.95);
    border: 2px solid #8B4513;
}

body.retro-theme .explanation-content {
    background: rgba(210, 180, 140, 0.98);
    border: 2px solid #8B4513;
}

/* Nature Theme */
body.nature-theme {
    background: linear-gradient(135deg, #2F5233 0%, #4A7C59 100%);
}

body.nature-theme .palace-cell {
    background: rgba(144, 238, 144, 0.9);
    border: 2px solid #228B22;
    box-shadow: 0 4px 8px rgba(34, 139, 34, 0.3);
}

body.nature-theme .center-info {
    background: linear-gradient(135deg, #228B22 0%, #32CD32 100%);
}

body.nature-theme .form-container {
    background: rgba(144, 238, 144, 0.95);
    border: 2px solid #228B22;
}

body.nature-theme .btn-primary {
    background: linear-gradient(135deg, #228B22 0%, #32CD32 100%);
}

body.nature-theme .settings-panel {
    background: rgba(152, 251, 152, 0.95);
    border: 2px solid #228B22;
}

body.nature-theme .export-container {
    background: rgba(152, 251, 152, 0.95);
    border: 2px solid #228B22;
}

body.nature-theme .palace-name {
    color: #1F2937;
}

body.nature-theme .explanation-content {
    background: rgba(152, 251, 152, 0.98);
    border: 2px solid #228B22;
    color: #1F2937;
}

/* Ancient Theme */
body.ancient-theme {
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
}

body.ancient-theme .palace-cell {
    background: rgba(255, 215, 0, 0.9);
    border: 3px solid #8B0000;
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.4);
    border-radius: 0px;
}

body.ancient-theme .center-info {
    background: linear-gradient(135deg, #8B0000 0%, #B22222 100%);
    border-radius: 0px;
}

body.ancient-theme .form-container {
    background: rgba(255, 215, 0, 0.95);
    border: 3px solid #8B0000;
    border-radius: 0px;
}

body.ancient-theme .btn-primary {
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    border-radius: 0px;
}

body.ancient-theme .settings-panel {
    background: rgba(255, 228, 181, 0.95);
    border: 3px solid #8B0000;
    border-radius: 0px;
}

body.ancient-theme .export-container {
    background: rgba(255, 228, 181, 0.95);
    border: 3px solid #8B0000;
    border-radius: 0px;
}

body.ancient-theme .palace-name {
    color: #8B0000;
    font-weight: 700;
}

body.ancient-theme .explanation-content {
    background: rgba(255, 228, 181, 0.98);
    border: 3px solid #8B0000;
    border-radius: 0px;
    color: #8B0000;
}

/* Ocean Theme */
body.ocean-theme {
    background: linear-gradient(135deg, #1E3A8A 0%, #06B6D4 100%);
}

body.ocean-theme .palace-cell {
    background: rgba(191, 219, 254, 0.9);
    border: 2px solid #1E40AF;
    box-shadow: 0 4px 8px rgba(30, 64, 175, 0.3);
}

body.ocean-theme .center-info {
    background: linear-gradient(135deg, #1E40AF 0%, #0284C7 100%);
}

body.ocean-theme .form-container {
    background: rgba(191, 219, 254, 0.95);
    border: 2px solid #1E40AF;
}

body.ocean-theme .btn-primary {
    background: linear-gradient(135deg, #1E40AF 0%, #0284C7 100%);
}

body.ocean-theme .settings-panel {
    background: rgba(219, 234, 254, 0.95);
    border: 2px solid #1E40AF;
}

body.ocean-theme .export-container {
    background: rgba(219, 234, 254, 0.95);
    border: 2px solid #1E40AF;
}

body.ocean-theme .palace-name {
    color: #1E40AF;
    font-weight: 600;
}

body.ocean-theme .explanation-content {
    background: rgba(219, 234, 254, 0.98);
    border: 2px solid #1E40AF;
    color: #1E40AF;
}

/* Sakura Theme */
body.sakura-theme {
    background: linear-gradient(135deg, #FDF2F8 0%, #F9A8D4 100%);
}

body.sakura-theme .palace-cell {
    background: rgba(253, 242, 248, 0.9);
    border: 2px solid #EC4899;
    box-shadow: 0 4px 8px rgba(236, 72, 153, 0.3);
}

body.sakura-theme .center-info {
    background: linear-gradient(135deg, #EC4899 0%, #BE185D 100%);
}

body.sakura-theme .form-container {
    background: rgba(253, 242, 248, 0.95);
    border: 2px solid #EC4899;
}

body.sakura-theme .btn-primary {
    background: linear-gradient(135deg, #EC4899 0%, #BE185D 100%);
}

body.sakura-theme .settings-panel {
    background: rgba(252, 231, 243, 0.95);
    border: 2px solid #EC4899;
}

body.sakura-theme .export-container {
    background: rgba(252, 231, 243, 0.95);
    border: 2px solid #EC4899;
}

body.sakura-theme .palace-name {
    color: #BE185D;
    font-weight: 600;
}

body.sakura-theme .explanation-content {
    background: rgba(252, 231, 243, 0.98);
    border: 2px solid #EC4899;
    color: #BE185D;
}

/* ==========================================================================
   響應式設計 - 手機版面調整
   ========================================================================== */

@media (max-width: 768px) {
    .floating-tab-btn {
        padding: 3px 5px;
        min-width: 32px;
        font-size: 10px;
    }
    
    .floating-tab-btn .text-sm {
        font-size: 10px;
    }
    
    .floating-tab-btn .text-xs {
        font-size: 8px;
    }
    
    /* 手機端命盤響應式設計 */
    .chart-container {
        transform: scale(0.65) !important;
        transform-origin: center !important;
    }
    
    /* 手機端宮位高度調整 */
    .palace-cell {
        min-height: 120px !important;
        font-size: 0.6rem !important;
    }
    
    /* 手機端星曜文字縮小 */
    .star-zw, .star-tf, .star-other, .star-auxiliary, .star-malefic {
        font-size: 0.49rem !important;
        line-height: 1.0 !important;
    }
    
    /* 手機端四化文字縮小 */
    .star-four, .star-four-daxian, .star-four-liunian {
        font-size: 0.45rem !important;
    }
    
    /* 手機端亮度文字縮小 */
    .star-brightness {
        font-size: 0.41rem !important;
    }
    
    /* 手機端宮位名稱縮小 */
    .palace-name {
        font-size: 0.53rem !important;
        line-height: 1.1 !important;
    }
    
    /* 手機端中央資訊區文字縮小 */
    .center-info .text-xl {
        font-size: 0.68rem !important;
    }
    
    .center-info .text-lg {
        font-size: 0.56rem !important;
        line-height: 1.1 !important;
    }
    
    /* 手機端天干地支縮小 */
    .tianGan-diZhi {
        font-size: 0.53rem !important;
    }
    
    /* 手機端長生十二神縮小 */
    .longevity-star {
        font-size: 0.49rem !important;
    }
    
    /* 手機端長生十二神縮小（內聯樣式覆蓋） */
    .palace-cell span[style*="color: #047809"] {
        font-size: 0.49rem !important;
    }
    
    /* 手機端博士十二星縮小 */
    .doctor-stars {
        font-size: 0.49rem !important;
        line-height: 1.0 !important;
    }
    
    /* 手機端將前諸星縮小（內聯樣式覆蓋） */
    .palace-cell div[style*="color: #6B7280"] {
        font-size: 0.49rem !important;
        line-height: 1.0 !important;
    }
    
    /* 手機端歲前諸星縮小（內聯樣式覆蓋） */
    .palace-cell div[style*="color: #454545"] {
        font-size: 0.49rem !important;
        line-height: 1.0 !important;
    }
    
    /* 手機端大限資訊縮小 */
    .daxian-info {
        font-size: 0.49rem !important;
        padding: 1px 2px !important;
    }
    
    /* 手機端特殊宮位標註縮小 */
    .special-position {
        font-size: 0.45rem !important;
        padding: 0px 1px !important;
    }
    
    /* 手機端大限盤、流年盤、流月盤宮位名稱縮小 */
    .palace-cell [style*="color: #10B981"],
    .palace-cell [style*="color: #269cfc"],
    .palace-cell [style*="color: #BF5700"] {
        font-size: 0.53rem !important;
        line-height: 1.0 !important;
    }
    
    /* 手機端流月四化縮小 */
    .palace-cell [style*="color: #BF5700"][onclick*="showStarExplanation"] {
        font-size: 0.6rem !important;
    }
}

/* ==========================================================================
   工具類別樣式
   ========================================================================== */

.tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    background-color: transparent;
    color: #6B7280;
}

.tab-btn.active {
    background-color: #667eea;
    color: white;
}

.tab-btn:hover:not(.active) {
    background-color: #F3F4F6;
    color: #374151;
}

.dark .tab-btn {
    color: #9CA3AF;
}

.dark .tab-btn:hover:not(.active) {
    background-color: #374151;
    color: #F3F4F6;
}

.dark .tab-btn.active {
    background-color: #6366f1;
}

.hidden {
    display: none !important;
}

.prose {
    max-width: none;
    color: #374151;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
    color: #111827;
    font-weight: 600;
}

.prose p {
    margin-bottom: 1rem;
    line-height: 1.75;
}

.prose ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.prose li {
    margin-bottom: 0.25rem;
}

.dark .prose {
    color: #D1D5DB;
}

.dark .prose h1, .dark .prose h2, .dark .prose h3, .dark .prose h4 {
    color: #F9FAFB;
}