/**
 * 超能感應展示網頁樣式
 * 複用 examples/web/static/css/style.css 核心樣式並新增所需樣式
 */

/* ==================== 重設和基礎樣式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    margin-bottom: 20px;
}

/* ==================== 頁首樣式 ==================== */
.header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 3px solid #667eea;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5em;
    color: #2c3e50;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header .subtitle {
    font-size: 1.1em;
    color: #666;
}

/* ==================== 表單樣式 ==================== */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group label {
    display: block;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

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

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.char-count {
    position: absolute;
    right: 10px;
    bottom: -20px;
    font-size: 0.85em;
    color: #999;
}

.char-count.char-warning {
    color: #e74c3c;
    font-weight: bold;
}

/* ==================== 按鈕樣式 ==================== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.2em;
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

/* Loading 狀態 */
.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== 說明區塊 ==================== */
.info-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-top: 30px;
    border-left: 4px solid #667eea;
}

.info-box h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.info-box ul {
    margin-left: 20px;
}

.info-box li {
    margin-bottom: 8px;
    color: #666;
}

/* ==================== 時間輸入欄位樣式 ==================== */
.time-input-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.time-input-item {
    display: flex;
    flex-direction: column;
}

.time-input-item label {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #666;
    font-weight: normal;
}

.time-input-item .form-input {
    padding: 8px 10px;
    text-align: center;
}

/* 移除 number input 的箭頭（可選） */
.time-input-item input[type="number"]::-webkit-inner-spin-button,
.time-input-item input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

#timeInputs {
    border: 2px dashed #e9ecef;
    padding: 15px;
    border-radius: 10px;
    background: #f8f9fa;
}

/* checkbox 樣式 */
.form-group label[for="useCurrentTime"] {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* ==================== 數字輸入欄位樣式 ==================== */
.number-input-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 10px;
}

.number-input-item {
    display: flex;
    flex-direction: column;
}

.number-input-item label {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #666;
    font-weight: normal;
}

.number-input-item .form-input {
    padding: 10px 12px;
    text-align: center;
}

#numberInputs {
    border: 2px dashed #e9ecef;
    padding: 15px;
    border-radius: 10px;
    background: #f8f9fa;
}

/* ==================== 結果頁面樣式 ==================== */
.result-container {
    max-width: 100%;
}

/* 摘要卡片 */
.summary-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

.summary-card h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5em;
}

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

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.summary-item .label {
    font-weight: bold;
    color: #2c3e50;
}

.summary-item .value {
    color: #666;
}

.question-display {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #27ae60;
}

.question-display .label {
    font-weight: bold;
    color: #2c3e50;
    display: block;
    margin-bottom: 8px;
}

.question-text {
    color: #333;
    line-height: 1.8;
}

/* ==================== 分享 URL 區塊 ==================== */
.share-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    border-top: 4px solid #27ae60;
}

.share-card h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.share-url-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.share-url-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95em;
    background: #f8f9fa;
    color: #333;
    font-family: 'Courier New', monospace;
}

.btn-copy {
    white-space: nowrap;
    min-width: 100px;
}

.share-hint {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

/* ==================== AI 解卦區塊 ==================== */
.ai-section {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(116, 185, 255, 0.3);
}

.ai-section h2 {
    color: white;
    margin-bottom: 20px;
}

.topic-classification {
    margin-bottom: 20px;
}

.topic-classification .label {
    display: block;
    margin-bottom: 8px;
    opacity: 0.9;
}

.topic-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
}

.explanation-box {
    background: rgba(255, 255, 255, 0.15);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.explanation-box h3 {
    margin-bottom: 12px;
    font-size: 1.1em;
}

.explanation-content {
    line-height: 1.8;
    white-space: pre-wrap;
}

/* ==================== 警告與錯誤區塊 ==================== */
.warning-box {
    background: #fff3cd;
    color: #856404;
    padding: 15px 20px;
    border-radius: 10px;
    border-left: 4px solid #ffc107;
    margin-bottom: 15px;
}

.warning-box p {
    margin: 0;
}

.error-box {
    background: #f8d7da;
    color: #721c24;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    border-left: 4px solid #dc3545;
}

.error-box h2 {
    margin-bottom: 15px;
}

.error-message {
    font-size: 1.1em;
    margin-bottom: 25px;
}

.warnings-list {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.warnings-list h4 {
    margin-bottom: 10px;
}

.warnings-list ul {
    margin-left: 20px;
}

.warnings-list li {
    margin-bottom: 5px;
}

/* ==================== 卦象卡片 ==================== */
.hexagram-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    border-top: 4px solid #667eea;
}

.hexagram-card.predicted {
    border-top-color: #27ae60;
}

.hexagram-card h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

/* 三卦橫向顯示樣式（參考 spacetime_bazi_html_generator.py） */
.three-hexagram-info {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.hexagram-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.hexagram-card-compact {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #ddd;
    transition: all 0.3s ease;
}

.hexagram-card-compact:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.hexagram-name-compact {
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.trigram-info-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
    padding: 5px 0;
    font-size: 0.95em;
}

.trigram-info-compact span:first-child {
    color: #666;
}

.hexagram-name {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
    text-align: center;
    margin-bottom: 10px;
}

.hexagram-alias {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

.trigram-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.trigram-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.trigram-box h4 {
    color: #666;
    margin-bottom: 10px;
}

.trigram-name {
    font-size: 1.5em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.nature-info {
    color: #666;
    font-size: 0.9em;
    margin-top: 8px;
}

.timing-info,
.location-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.timing-info h4,
.location-info h4 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.timing-content {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    line-height: 1.6;
    color: #333;
    margin: 8px 0;
}

.lunar-timing {
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
}

/* ==================== 五行元素標籤 ==================== */
.element-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: bold;
    color: white;
}

.element-木 {
    background-color: #228B22;
}

.element-火 {
    background-color: #FF4500;
}

.element-土 {
    background-color: #D2691E;
}

.element-金 {
    background-color: #FFD700;
    color: #333;
}

.element-水 {
    background-color: #1E90FF;
}

/* 五行背景色 */
.element-bg-木 {
    background: linear-gradient(135deg, #228B22, #2ecc71);
}

.element-bg-火 {
    background: linear-gradient(135deg, #FF4500, #e74c3c);
}

.element-bg-土 {
    background: linear-gradient(135deg, #D2691E, #f39c12);
}

.element-bg-金 {
    background: linear-gradient(135deg, #FFD700, #f1c40f);
}

.element-bg-水 {
    background: linear-gradient(135deg, #1E90FF, #3498db);
}

/* ==================== 分數卡片 ==================== */
.score-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    border-top: 4px solid #9b59b6;
}

.score-card h2 {
    color: #2c3e50;
    margin-bottom: 20px;
}

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

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.result-item .label {
    font-weight: bold;
    color: #2c3e50;
}

.result-item .value {
    font-weight: bold;
    color: #666;
}

.result-item .value.positive {
    color: #27ae60;
}

.result-item .value.negative {
    color: #e74c3c;
}

.total-score {
    font-size: 1.8em;
    color: #667eea !important;
}

/* 體卦用卦資訊 */
.body-use-info {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.body-use-info .info-item {
    flex: 1;
    min-width: 200px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.body-use-info .label {
    font-weight: bold;
    color: #2c3e50;
}

/* 五行關係 */
.element-relationships {
    margin: 20px 0;
}

.element-relationships h4 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.relations-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.relation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
}

.relation-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: bold;
    color: white;
}

.relation-生 {
    background-color: #27ae60;
}

.relation-幫 {
    background-color: #3498db;
}

.relation-剋 {
    background-color: #e74c3c;
}

.relation-洩 {
    background-color: #f39c12;
}

.relation-耗 {
    background-color: #9b59b6;
}

.relation-elements {
    color: #666;
}

/* ==================== 明細表格 ==================== */
.breakdown-section {
    margin-top: 25px;
}

.breakdown-section h4 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.breakdown-table th,
.breakdown-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.breakdown-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #2c3e50;
}

.breakdown-table tr:last-child td {
    border-bottom: none;
}

.breakdown-table tr:hover {
    background: #f8f9fa;
}

.table-responsive {
    overflow-x: auto;
}

.multiplier {
    font-size: 0.85em;
    color: #999;
}

/* ==================== 八字五行詳細資料區塊 ==================== */
.wuxing-detail-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    border-top: 4px solid #e67e22;
}

.wuxing-detail-card h2 {
    color: #2c3e50;
    margin-bottom: 20px;
}

.wuxing-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.wuxing-card {
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.wuxing-card.element-bg-金 {
    color: #333;
}

.wuxing-name {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.wuxing-score {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.wuxing-percent {
    font-size: 0.9em;
    opacity: 0.9;
}

.wuxing-total {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 25px;
}

.wuxing-total .label {
    font-weight: bold;
    color: #2c3e50;
    margin-right: 10px;
}

.wuxing-total .value {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

.wuxing-detail-table-section h4 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.wuxing-detail-table th,
.wuxing-detail-table td {
    padding: 10px 12px;
    font-size: 0.95em;
}

/* ==================== 動作按鈕區 ==================== */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* ==================== 頁腳 ==================== */
.footer {
    text-align: center;
    padding: 25px 0 15px;
    border-top: 2px solid #e9ecef;
    margin-top: 30px;
    color: #666;
}

/* ==================== 響應式設計 ==================== */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 15px;
    }

    .header h1 {
        font-size: 2em;
    }

    .form-container,
    .summary-card,
    .share-card,
    .hexagram-card,
    .score-card,
    .wuxing-detail-card {
        padding: 20px;
    }

    .share-url-container {
        flex-direction: column;
    }

    .btn-copy {
        width: 100%;
    }

    .time-input-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .time-input-grid .time-input-item:nth-child(4),
    .time-input-grid .time-input-item:nth-child(5) {
        grid-column: span 1;
    }

    .number-input-grid {
        grid-template-columns: 1fr;
    }

    .hexagram-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .three-hexagram-info {
        padding: 15px;
    }

    .summary-grid,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .trigram-info-grid {
        grid-template-columns: 1fr;
    }

    .wuxing-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .body-use-info {
        flex-direction: column;
    }

    .relations-grid {
        flex-direction: column;
    }

    .btn-large {
        padding: 12px 30px;
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    .wuxing-cards {
        grid-template-columns: 1fr 1fr;
    }

    .wuxing-cards .wuxing-card:last-child {
        grid-column: 1 / -1;
    }

    .conversion-table {
        font-size: 0.8em;
    }

    .time-input-grid {
        grid-template-columns: 1fr 1fr;
    }

    .time-input-grid .time-input-item:first-child {
        grid-column: 1 / -1;
    }
}

/* ==================== 農曆轉換表格樣式 ==================== */
.timing-conversion-table {
    margin-top: 15px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.timing-conversion-table h5 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1em;
}

.conversion-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.conversion-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.conversion-table th,
.conversion-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.conversion-table th {
    font-weight: 600;
}

.conversion-table tbody tr:hover {
    background: #f8f9fa;
}

.conversion-table tbody tr:last-child td {
    border-bottom: none;
}

.conversion-table code {
    background: #e9ecef;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    color: #2c3e50;
}

.year-adjusted-tag {
    display: inline-block;
    background: #ffc107;
    color: #212529;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
}

.lunar-timing {
    margin-bottom: 10px;
    color: #555;
}

/* ==================== 八字四柱樣式 ==================== */
.bazi-pillars-info {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.pillars-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.pillar-card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #ddd;
    text-align: center;
    transition: all 0.3s ease;
}

.pillar-card:hover {
    border-color: #9b59b6;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.15);
    transform: translateY(-2px);
}

.pillar-name {
    font-size: 1em;
    font-weight: bold;
    color: #555;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.pillar-ganzhi {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ganzhi-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.ganzhi-item.tiangan {
    border-left: 3px solid #e74c3c;
}

.ganzhi-item.dizhi {
    border-left: 3px solid #3498db;
}

.ganzhi-char {
    font-size: 1.5em;
    font-weight: bold;
    color: #2c3e50;
}

@media (max-width: 768px) {
    .pillars-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .pillars-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ganzhi-char {
        font-size: 1.3em;
    }
}