/* 术数排盘 - 公共样式 */
/* 大部分布局样式由 Tailwind CDN 提供 */
/* Tailwind CDN 说明：生产环境建议使用构建工具生成静态CSS文件，当前使用CDN版以简化部署 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=ZCOOL+KuaiLe&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Serif SC', serif; background: #1a1a2e; color: #e8d5a3; min-height: 100vh; -webkit-tap-highlight-color: transparent; }
.title-font { font-family: 'ZCOOL KuaiLe', cursive; }

.inp {
    background: rgba(15,52,96,0.6);
    border: 1px solid rgba(212,160,23,0.3);
    color: #e8d5a3;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 16px;
    width: 100%;
    font-family: 'Noto Serif SC', serif;
}
.inp:focus { border-color: #d4a017; outline: none; box-shadow: 0 0 0 2px rgba(212,160,23,0.15); }
.inp option { background: #16213e; color: #e8d5a3; }

.btn-gold {
    background: linear-gradient(135deg, #d4a017 0%, #b8860b 100%);
    color: #1a1a2e; font-weight: 700;
    border-radius: 12px; padding: 12px;
    font-size: 17px; width: 100%;
    transition: all 0.2s;
    border: none; cursor: pointer;
}
.btn-gold:active { opacity: 0.85; transform: scale(0.97); }
.btn-gold:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-red {
    background: linear-gradient(135deg, #c0392b 0%, #96281b 100%);
    color: #fff; font-weight: 600;
    border-radius: 12px; padding: 12px;
    font-size: 17px; width: 100%;
    border: none; cursor: pointer;
}
.btn-red:active { opacity: 0.85; }

.btn-outline {
    background: transparent;
    border: 1px solid rgba(212,160,23,0.4);
    color: #d4a017; font-weight: 600;
    border-radius: 10px; padding: 8px 16px;
    font-size: 14px; cursor: pointer;
}

.panel {
    background: rgba(22,33,62,0.9);
    border: 1px solid rgba(212,160,23,0.15);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
}

.jg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.jg-cell {
    background: rgba(15,52,96,0.5);
    border: 1px solid rgba(212,160,23,0.15);
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
    min-height: 70px;
    font-size: 12px;
    line-height: 1.5;
}
.jg-cell.highlight { background: rgba(192,57,43,0.2); border-color: rgba(192,57,43,0.4); }

/* 奇门遁甲九宫格 */
.qimen-header {
    text-align: center;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(15,52,96,0.3);
    border-radius: 8px;
}
.qimen-title {
    font-size: 18px;
    font-weight: bold;
    color: #d4a017;
    margin-bottom: 4px;
}
.qimen-ganzhi {
    font-size: 14px;
    color: #e0d0b0;
    margin: 4px 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.qimen-ganzhi span {
    padding: 2px 6px;
    background: rgba(212,160,23,0.15);
    border-radius: 4px;
}
.qimen-info {
    font-size: 11px;
    color: #aaa;
    margin: 2px 0;
}
.qimen-info span {
    margin: 0 6px;
}
.qimen-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: calc(100% - 52px);
    aspect-ratio: 1;
    grid-template-rows: repeat(3, 1fr);
}
.qimen-cell {
    background: rgba(15,25,50,0.95);
    border: 1px solid rgba(212,160,23,0.2);
    border-radius: 6px;
    padding: 3px;
    aspect-ratio: 1;
    position: relative;
    overflow: visible;
    font-size: 11px;
    min-width: 0;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.qimen-cell:active, .qimen-cell:hover {
    border-color: rgba(212,160,23,0.6);
    box-shadow: 0 0 6px rgba(212,160,23,0.2);
}
.qimen-cell.qimen-zhong {
    background: rgba(30,40,70,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.qm-body { display:flex; width:100%; height:100%; align-items:stretch; }
.qm-left { flex:3; display:grid; grid-template-columns:auto 1fr; grid-template-rows:1fr 1fr 1fr; align-items:center; gap:0 2px; padding-left:2px; }
.qm-right { flex:2; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; }
.qm-yingan { font-size:8px; color:#aaa; line-height:1; grid-column:1; grid-row:1; justify-self:start; align-self:end; }
.qm-shen { font-size:16px; line-height:1.3; font-weight:600; text-align:center; grid-column:2; grid-row:1; }
.qm-xing { font-size:16px; line-height:1.3; text-align:center; grid-column:2; grid-row:2; }
.qm-yinGan { font-size:8px; color:#aaa; line-height:1; grid-column:1; grid-row:3; justify-self:start; align-self:start; }
.qm-men { font-size:16px; line-height:1.3; font-weight:600; text-align:center; grid-column:2; grid-row:3; }
.qm-tian { font-size:15px; font-weight:bold; line-height:1.2; }
.qm-di { font-size:13px; font-weight:bold; line-height:1.2; }
.qm-tags-row {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 1px;
    flex-wrap: wrap;
}
.qm-tag {
    display: inline-block;
    padding: 0 3px;
    border-radius: 3px;
    font-size: 8px;
    font-weight: 600;
    border: 1px solid;
    background: transparent;
    line-height: 1.4;
}
/* 5行布局样式 */
.qimen-cell-row {
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.2;
}
.qimen-row-yingan {
    justify-content: flex-start;
    position: absolute;
    top: 2px;
    left: 4px;
}
.qimen-row-gan {
    justify-content: space-around;
    margin-top: 8px;
    padding: 2px 0;
}
.qimen-row-xing,
.qimen-row-men,
.qimen-row-shen {
    text-align: center;
}
/* 外围标注样式 */
.qimen-board {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.qimen-outer-row {
    display: flex;
    justify-content: space-around;
    width: 100%;
    padding: 2px 0;
}
.qimen-outer-row.top {
    margin-bottom: 4px;
}
.qimen-outer-row.bottom {
    margin-top: 4px;
}
.qimen-outer-cell {
    font-size: 8px;
    color: #888;
    text-align: center;
    flex: 1;
}
.qimen-middle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.qimen-outer-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 0 2px;
    width: 24px;
    min-width: 24px;
    flex-shrink: 0;
}
.qimen-outer-col.left {
    margin-right: 4px;
}
.qimen-outer-col.right {
    margin-left: 4px;
}
.qimen-outer-cell-v {
    font-size: 8px;
    color: #888;
    writing-mode: vertical-rl;
    text-align: center;
    padding: 4px 0;
    letter-spacing: 1px;
}
.qimen-cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    line-height: 1.3;
}
.qimen-cell-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}
.qimen-cell-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    line-height: 1.3;
}
.qimen-dizhi {
    font-size: 10px;
    color: #888;
    font-weight: bold;
}
.qimen-shen {
    font-size: 11px;
    font-weight: bold;
}
.qimen-ma {
    font-size: 10px;
}
.qimen-xing {
    font-size: 11px;
    font-weight: bold;
}
.qimen-tiangan {
    font-size: 18px;
    font-weight: bold;
}
.qimen-men {
    font-size: 12px;
    font-weight: bold;
}
.qimen-dizhi-sm {
    font-size: 11px;
}
.qimen-center-gan {
    font-size: 22px;
    font-weight: bold;
    color: #d4a017;
    text-align: center;
}
.qimen-footer {
    font-size: 10px;
    color: #888;
    margin-top: 8px;
    text-align: center;
}
.qimen-footer span {
    margin: 0 10px;
}

.sizhu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.zhu-col { text-align: center; }
.zhu-label { font-size: 11px; color: #888; margin-bottom: 4px; }
.zhu-gan { font-size: 20px; font-weight: 700; color: #d4a017; }
.zhu-zhi { font-size: 20px; font-weight: 700; color: #e8d5a3; }

.fade-in { animation: fadeIn 0.35s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid rgba(212,160,23,0.3); border-top-color: #d4a017; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; margin: 2px; }
.tag-jin { background: rgba(212,160,23,0.2); color: #d4a017; }
.tag-zhu { background: rgba(192,57,43,0.2); color: #e74c3c; }
.tag-lan { background: rgba(52,152,219,0.2); color: #3498db; }
.tag-lv { background: rgba(46,204,113,0.2); color: #2ecc71; }

.collapse-hdr { cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.collapse-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.collapse-body.open { max-height: 5000px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: #d4a017; padding: 6px 4px; border-bottom: 1px solid rgba(212,160,23,0.2); font-weight: 600; }
.tbl td { padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }

.hidden { display: none !important; }
a { color: #d4a017; text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: rgba(212,160,23,0.3); border-radius: 3px; }

/* 登录模态框 */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: #1a1a2e; border: 1px solid rgba(212,160,23,0.3);
    border-radius: 16px; padding: 24px; width: 100%; max-width: 380px;
}
.tab-active { background: linear-gradient(135deg, #d4a017, #b8860b) !important; color: #1a1a2e !important; }
.tab-inactive { background: rgba(15,52,96,0.6); color: #888; }

/* 用户下拉 */
.user-dropdown { position: relative; display: inline-block; }
.user-menu {
    position: absolute; top: 100%; right: 0; margin-top: 4px;
    background: #16213e; border: 1px solid rgba(212,160,23,0.3);
    border-radius: 10px; min-width: 140px; z-index: 100;
    overflow: hidden;
}
.user-menu.hidden { display: none; }
.user-menu a, .user-menu button {
    display: block; width: 100%; padding: 10px 14px;
    color: #e8d5a3; text-align: left; font-size: 14px;
    background: none; border: none; cursor: pointer;
    font-family: 'Noto Serif SC', serif;
}
.user-menu a:active, .user-menu button:active { background: rgba(212,160,23,0.15); }

/* 加载指示器 */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(26,26,46,0.8); z-index: 999;
    display: flex; align-items: center; justify-content: center;
}
.loading-overlay.hidden { display: none; }

/* 错误提示 */
.error-toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(192,57,43,0.95); color: #fff; padding: 10px 20px;
    border-radius: 8px; font-size: 14px; z-index: 1001;
    animation: slideDown 0.3s ease-out;
}
@keyframes slideDown { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* 奇门宫位详情弹窗 */
.qmd-header {
    display: flex; align-items: baseline; gap: 8px;
    margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 1px solid rgba(212,160,23,0.2);
}
.qmd-bagua { font-size: 18px; font-weight: 700; }
.qmd-fangwei { font-size: 13px; color: #999; }
.qmd-wx { font-size: 13px; font-weight: 600; }
.qmd-section {
    margin-bottom: 10px; padding: 8px 10px;
    background: rgba(15,52,96,0.35); border-radius: 8px;
    border: 1px solid rgba(212,160,23,0.1);
}
.qmd-sec-title {
    font-size: 11px; color: #888; margin-bottom: 6px;
    font-weight: 600; letter-spacing: 1px;
}
.qmd-gan-row {
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.qmd-gan-item { text-align: center; min-width: 50px; }
.qmd-gan-char { font-size: 22px; font-weight: 700; line-height: 1.3; }
.qmd-gan-arrow { font-size: 13px; color: #d4a017; font-weight: 600; }
.qmd-item-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.qmd-label { font-size: 11px; color: #888; }
.qmd-big { font-size: 16px; font-weight: 700; }
.qmd-sub { font-size: 11px; color: #aaa; }
.qmd-tag {
    display: inline-block; padding: 1px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600;
    border: 1px solid; background: transparent;
}
.qmd-rel {
    font-size: 11px; color: #d4a017; margin-top: 4px;
}
.qmd-geju {
    font-size: 11px; color: #4caf50; margin-top: 2px;
}
.qmd-xiangyi {
    font-size: 13px; color: #ccc; line-height: 1.5;
}

/* AI聊天面板 */
.ai-chat-area {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(15,52,96,0.3);
    border-radius: 10px;
    border: 1px solid rgba(212,160,23,0.1);
}
.ai-msg {
    margin-bottom: 10px;
}
.ai-msg-label {
    font-size: 10px;
    color: #888;
    margin-bottom: 3px;
}
.ai-msg-content {
    font-size: 13px;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 10px;
    word-break: break-word;
}
.ai-msg-user .ai-msg-content {
    background: rgba(212,160,23,0.15);
    color: #e8d5a3;
    border-bottom-right-radius: 2px;
}
.ai-msg-assistant .ai-msg-content {
    background: rgba(22,33,62,0.8);
    color: #ccc;
    border: 1px solid rgba(212,160,23,0.1);
    border-bottom-left-radius: 2px;
}
.ai-msg-user {
    text-align: right;
}
.ai-msg-user .ai-msg-label {
    text-align: right;
}
.ai-msg-user .ai-msg-content {
    display: inline-block;
    max-width: 85%;
}
.ai-msg-assistant .ai-msg-content {
    display: inline-block;
    max-width: 85%;
}
