/* ========================================
   命理天機 - 前台樣式 (Modernized)
   ======================================== */

:root {
    --primary-color: #2d1b69;
    --primary-dark: #1a0533;
    --primary-light: #4a2c8a;
    --accent-color: #ffd700;
    --accent-glow: rgba(255, 215, 0, 0.5);
    --bg-color: #f8f5ff;
    --text-color: #333333;
    --text-muted: #666666;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-shadow: 0 10px 30px rgba(45, 27, 105, 0.08);
    --card-shadow-hover: 0 20px 40px rgba(45, 27, 105, 0.15);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 全域設定 */
body {
    font-family: 'Noto Sans TC', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(45, 27, 105, 0.03) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 215, 0, 0.03) 0%, transparent 20%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

main {
    flex: 1;
}

/* 標題字體 */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Serif TC', serif;
    color: var(--primary-color);
    font-weight: 700;
}

/* 導覽列優化 */
.navbar {
    background: rgba(26, 5, 51, 0.95) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-brand span {
    background: linear-gradient(45deg, #ffd700, #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Hero 區塊 */
.hero-section {
    background: linear-gradient(135deg, #120a2e 0%, #2d1b69 100%);
    color: #fff;
    padding: 100px 0 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #ffffff, rgba(0,0,0,0));
    background-size: 200px 200px;
    animation: twinkle 4s linear infinite;
    opacity: 0.3;
}

@keyframes twinkle {
    0% { transform: translateY(0); }
    100% { transform: translateY(-200px); }
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    height: 100px;
    background: #f8f5ff;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    transform: scaleX(1.5);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
    letter-spacing: 2px;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.8;
    font-weight: 300;
}

/* 算命類型卡片 */
.fortune-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(45, 27, 105, 0.05);
    box-shadow: var(--card-shadow);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.fortune-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    opacity: 0;
    transition: opacity 0.3s;
}

.fortune-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--card-shadow-hover);
    color: inherit;
}

.fortune-card:hover::before {
    opacity: 1;
}

.fortune-card .card-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--accent-color), #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
    display: inline-block;
    transition: transform 0.3s;
}

.fortune-card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
}

.fortune-card .card-title {
    font-family: 'Noto Serif TC', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.fortune-card .card-desc {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
}

/* 算命輸入表單 */
.fortune-form-section {
    padding: 40px 0 80px;
}

.fortune-form-card {
    background: #fff;
    border-radius: 24px;
    padding: 50px;
    box-shadow: var(--card-shadow);
    max-width: 650px;
    margin: 0 auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.fortune-form-card .form-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

.fortune-form-card .form-control,
.fortune-form-card .form-select {
    border: 2px solid #eef0f5;
    background-color: #fcfcfd;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 1rem;
    transition: all 0.3s;
}

.fortune-form-card .form-control:focus,
.fortune-form-card .form-select:focus {
    border-color: var(--primary-light);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(74, 44, 138, 0.1);
    outline: none;
}

.btn-divine {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #2d1b69;
    border: none;
    border-radius: 50px;
    padding: 16px 48px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Noto Serif TC', serif;
    transition: all 0.3s;
    width: 100%;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-divine::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(45deg) translate(-100%, -100%);
    transition: transform 0.6s;
}

.btn-divine:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5);
    color: #2d1b69;
}

.btn-divine:hover::after {
    transform: rotate(45deg) translate(0, 0);
}

.btn-divine:disabled {
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

/* 算命結果 */
.result-section {
    padding: 40px 0 80px;
}

.result-header {
    background: linear-gradient(135deg, #120a2e 0%, #2d1b69 100%);
    color: #fff;
    padding: 60px 0 80px;
    text-align: center;
    clip-path: ellipse(150% 100% at 50% 0%);
    margin-bottom: -40px;
}

.result-header h1 {
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.result-card {
    background: #fff;
    border-radius: 20px;
    padding: 35px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    border: none;
    border-left: 5px solid var(--accent-color);
    transition: transform 0.3s;
}

.result-card:hover {
    transform: translateY(-5px);
}

.result-card .result-title {
    font-family: 'Noto Serif TC', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 15px;
}

.result-card .result-title i {
    color: var(--accent-color);
    margin-right: 12px;
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.result-card .result-content {
    color: #4a4a4a;
    line-height: 1.9;
    font-size: 1.05rem;
    text-align: justify;
}

/* 幸運資訊 */
.lucky-info {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.lucky-info .lucky-label {
    font-weight: 600;
    color: #856404;
    margin-bottom: 8px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lucky-info .lucky-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Noto Serif TC', serif;
}

/* 載入動畫 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 10, 46, 0.9);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.loading-spinner {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(255, 215, 0, 0.1);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--accent-color);
    font-family: 'Noto Serif TC', serif;
    font-size: 1.4rem;
    margin-top: 30px;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* 使用次數提示 */
.usage-alert {
    background: #fff;
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    padding: 16px 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: inline-block;
}

/* 頁尾 */
footer {
    background: var(--primary-dark) !important;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* 紫微斗數命盤樣式 */
.ziwei-chart-container {
    width: 100%;
    max-width: 860px;
    margin: 0 auto 3rem;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(45, 27, 105, 0.12);
    overflow: hidden;
}

/* 命盤標題列 */
.ziwei-chart-title {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #fff;
    text-align: center;
    padding: 12px 20px;
    font-family: 'Noto Serif TC', serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.ziwei-chart {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, minmax(130px, auto));
    gap: 1px;
    background-color: var(--primary-color); /* 邊框顏色 */
}

.ziwei-cell {
    background-color: #fff;
    padding: 6px 8px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    transition: background-color 0.2s;
}

.ziwei-cell:hover {
    background-color: #faf8ff;
}

/* 命宮特殊樣式 */
.ziwei-cell-ming {
    background-color: #fffbeb;
}

.ziwei-cell-ming:hover {
    background-color: #fff8d6;
}

/* 身宮特殊樣式 */
.ziwei-cell-body {
    background-color: #f0f7ff;
}

.ziwei-cell-body:hover {
    background-color: #e3f0ff;
}

/* 中宮資訊 */
.ziwei-center {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background-color: #fdfefe;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, #fdfefe, #f8f5ff);
}

.ziwei-center-name {
    font-family: 'Noto Serif TC', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.ziwei-center-info {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.8;
}

.ziwei-center-info i {
    color: var(--primary-light);
    margin-right: 4px;
}

.ziwei-center-meta {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.ziwei-meta-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #f0edf7;
    color: var(--primary-color);
    border: 1px solid rgba(45, 27, 105, 0.15);
}

.ziwei-meta-badge.five-element {
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    color: #856404;
    border-color: rgba(133, 100, 4, 0.2);
}

.ziwei-meta-badge.body-palace {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border-color: rgba(12, 84, 96, 0.2);
}

/* 宮位標頭 */
.ziwei-cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: #666;
    border-bottom: 1px dashed #e8e5f0;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.ziwei-gan-zhi {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.8rem;
}

.ziwei-name {
    background-color: var(--primary-color);
    color: #fff;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.ziwei-name-ming {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: var(--primary-dark);
}

.ziwei-body-tag {
    display: inline-block;
    background: #17a2b8;
    color: #fff;
    border-radius: 3px;
    padding: 0 3px;
    font-size: 0.65rem;
    margin-left: 3px;
    vertical-align: middle;
}

/* 星曜區域 */
.ziwei-stars {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 3px 6px;
    align-content: flex-start;
    padding: 2px 0;
}

/* 主星樣式 */
.star-major {
    color: #d63384;
    font-weight: bold;
    font-size: 0.88rem;
    line-height: 1.4;
    position: relative;
}

/* 主星亮度樣式 */
.star-major.bright-miao {
    color: #c41e3a;
}

.star-major.bright-wang {
    color: #d63384;
}

.star-major.bright-dedi {
    color: #e85d75;
}

.star-major.bright-li {
    color: #b8627d;
}

.star-major.bright-ping {
    color: #888;
}

.star-major.bright-budedi {
    color: #999;
    font-weight: normal;
}

.star-major.bright-luoxian {
    color: #aaa;
    font-weight: normal;
    text-decoration: line-through;
    text-decoration-color: rgba(0,0,0,0.2);
}

/* 星曜亮度標記 */
.star-brightness {
    font-size: 0.6rem;
    font-weight: normal;
    color: #999;
    margin-left: 1px;
}

/* 四化星標記 */
.star-four-trans {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0 3px;
    border-radius: 3px;
    margin-left: 2px;
    vertical-align: middle;
    line-height: 1.4;
}

.star-four-trans.trans-lu {
    background: #d4edda;
    color: #155724;
}

.star-four-trans.trans-quan {
    background: #f8d7da;
    color: #721c24;
}

.star-four-trans.trans-ke {
    background: #cce5ff;
    color: #004085;
}

.star-four-trans.trans-ji {
    background: #e2e3e5;
    color: #383d41;
}

/* 輔星樣式 */
.star-minor {
    color: #0d6efd;
    font-size: 0.78rem;
    line-height: 1.4;
}

/* 宮位底部 */
.ziwei-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #999;
    border-top: 1px dashed #e8e5f0;
    padding-top: 3px;
    margin-top: 3px;
}

.ziwei-age {
    color: var(--primary-dark);
    font-weight: bold;
}

/* RWD 調整 */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        padding: 0 20px;
    }

    .fortune-form-card {
        padding: 30px 20px;
        margin: 0 15px;
    }

    .result-card {
        padding: 25px 20px;
    }
    
    .btn-divine {
        width: 100%;
        padding: 14px 20px;
    }

    /* 手機版命盤：改為可橫向捲動 */
    .ziwei-chart-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ziwei-chart {
        min-width: 600px;
    }

    .ziwei-cell {
        min-height: 110px;
        padding: 4px 6px;
    }

    .star-major {
        font-size: 0.8rem;
    }

    .star-minor {
        font-size: 0.7rem;
    }

    .ziwei-center-name {
        font-size: 1.2rem;
    }

    .ziwei-center-info {
        font-size: 0.8rem;
    }

    .ziwei-meta-badge {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
}

/* 命盤列印樣式 */
@media print {
    .ziwei-chart-container {
        box-shadow: none;
        border: 2px solid #333;
    }

    .ziwei-chart-title {
        background: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .ziwei-cell:hover {
        background-color: #fff;
    }
}
