/* 基本樣式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 定義顏色變數 */
    --primary-color: #4a2c82;
    --primary-light: #7a55c5;
    --secondary-color: #e66c2c;
    --secondary-light: #ff9d62;
    --text-color: #333;
    --light-text: #f5f5f5;
    --background-color: #f9f8ff;
    --card-color: #ffffff;
    --border-color: #e1e1e1;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* 定義六壬掌訣顏色 */
    --color-daan: #4caf50;    /* 大安 - 綠色 */
    --color-liulian: #ffc107; /* 留連 - 黃色 */
    --color-suxi: #2196f3;    /* 速喜 - 藍色 */
    --color-chikou: #f44336; /* 赤口 - 紅色 */
    --color-xiaoji: #9c27b0;  /* 小吉 - 紫色 */
    --color-kongwang: #607d8b; /* 空亡 - 灰藍色 */
}

body {
    font-family: "PingFang TC", "Heiti TC", "微軟正黑體", "Microsoft JhengHei", sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 頭部樣式 */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    color: var(--primary-color);
    font-size: 2.4rem;
    margin-bottom: 10px;
}

header .subtitle {
    color: var(--secondary-color);
    font-size: 1.2rem;
    font-style: italic;
}

/* 內容區域樣式 */
.content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 輸入區域樣式 */
.input-section {
    background-color: var(--card-color);
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.input-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 10px;
}

.form-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

input[type="number"],
input[type="time"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(122, 85, 197, 0.2);
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.btn-primary,
.btn-secondary {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
}

.btn-secondary {
    background-color: #f0f0f0;
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: #e0e0e0;
}

/* 結果區域樣式 */
.result-section {
    background-color: var(--card-color);
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.result-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 10px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.result-card {
    padding: 20px;
    background-color: var(--background-color);
    border-radius: 8px;
    border-left: 5px solid var(--primary-color);
}

.result-card h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.result-card p {
    font-size: 1.2rem;
    font-weight: 600;
}

.divination-results {
    margin-top: 30px;
}

.divination-results h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.sixren-diagram {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 30px;
}

.position {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: 20px 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--shadow-color);
    transition: transform 0.3s;
}

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

.position h4 {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.position p {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 5px;
    border-radius: 5px;
}

/* 結果解釋區域 */
.meaning-section {
    margin-top: 40px;
    padding: 20px;
    background-color: var(--background-color);
    border-radius: 8px;
    border-left: 5px solid var(--secondary-color);
}

.meaning-section h3 {
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.empty-state {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* 加載指示器 */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(74, 44, 130, 0.2);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* 錯誤訊息樣式 */
.error-message {
    background-color: #ffebee;
    border-left: 5px solid #f44336;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
    display: flex;
    align-items: center;
}

.error-message i {
    color: #f44336;
    font-size: 1.5rem;
    margin-right: 15px;
}

.error-message p {
    color: #d32f2f;
}

/* 頁腳樣式 */
footer {
    margin-top: 50px;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: #666;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* 模態框樣式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--card-color);
    border-radius: 10px;
    padding: 30px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.modal h3 {
    color: var(--secondary-color);
    margin: 20px 0 10px;
}

.modal p {
    margin-bottom: 15px;
}

.modal ul, .modal ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal li {
    margin-bottom: 8px;
}

/* 根據掌訣結果顯示不同顏色 */
.result-daan {
    background-color: rgba(76, 175, 80, 0.2);
    color: var(--color-daan);
}

.result-liulian {
    background-color: rgba(255, 193, 7, 0.2);
    color: var(--color-liulian);
}

.result-suxi {
    background-color: rgba(33, 150, 243, 0.2);
    color: var(--color-suxi);
}

.result-chikou {
    background-color: rgba(244, 67, 54, 0.2);
    color: var(--color-chikou);
}

.result-xiaoji {
    background-color: rgba(156, 39, 176, 0.2);
    color: var(--color-xiaoji);
}

.result-kongwang {
    background-color: rgba(96, 125, 139, 0.2);
    color: var(--color-kongwang);
}

/* 通用類 */
.hidden {
    display: none !important;
}

/* 響應式樣式 */
@media (min-width: 768px) {
    .content {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .input-section, .result-section {
        flex: 1;
    }
}

@media (max-width: 767px) {
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-row .form-group {
        min-width: 100%;
    }
    
    .sixren-diagram {
        flex-direction: column;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 10px 15px;
    }
}