/**
 * 公共基础样式 - 增强版
 * 包含：全局重置 + 视觉增强 + 组件库 + 响应式
 * 加载顺序：页面CSS之后加载此文件，以增强覆盖基础样式
 */

/* ===================== CSS 变量 ===================== */
:root {
    /* 主色调 */
    --color-bg-primary: #1a1a2e;
    --color-bg-secondary: #16213e;
    --color-bg-card: #2d2d44;
    --color-border: #3a3a5c;

    /* 金色系 */
    --color-gold: #ffd700;
    --color-gold-dark: #c9a700;
    --color-gold-light: #ffed4d;

    /* 状态色 */
    --color-hp: #e74c3c;
    --color-mp: #3498db;
    --color-exp: #f39c12;

    /* 稀有度色 */
    --rarity-white: #ffffff;
    --rarity-green: #2ecc71;
    --rarity-blue: #3498db;
    --rarity-purple: #9b59b6;
    --rarity-orange: #e67e22;
    --rarity-red: #e74c3c;
    --rarity-gold: #f1c40f;
}

/* ===================== 全局重置 ===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft Yahei", sans-serif;
}

/* ===================== 基础布局（增强） ===================== */
body {
    background: 
        radial-gradient(ellipse at top, #2a2030 0%, #1a1a1a 50%, #0d0d0d 100%);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ===================== 通用容器（增强） ===================== */
.game-container,
.login-container,
.bag-container,
.char-container {
    background: 
        linear-gradient(180deg, #2d2d3a 0%, #222230 50%, #1a1a28 100%) !important;
    border: 2px solid rgba(255, 215, 0, 0.15) !important;
    box-shadow: 
        0 0 30px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
    overflow: hidden;
    position: relative;
}

/* ===================== 顶部栏（增强） ===================== */
.top-bar {
    background: linear-gradient(180deg, #3a3a4a 0%, #2d2d38 100%) !important;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
    border-bottom: 1px solid rgba(255, 215, 0, 0.15) !important;
}

/* ===================== 底部导航栏（增强） ===================== */
.bottom-bar {
    background: linear-gradient(180deg, #2d2d38 0%, #1a1a22 100%) !important;
    border-top: 1px solid rgba(255, 215, 0, 0.15) !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4) !important;
}

.bottom-btn {
    color: #aaa !important;
    font-size: 11px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    text-align: center;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2px 0;
}

.bottom-btn .nav-icon {
    font-size: 18px;
    margin-bottom: 1px;
    line-height: 1;
}

.bottom-btn:hover {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.08) !important;
}

.bottom-btn.active {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.12) !important;
}

.bottom-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
    border-radius: 0 0 4px 4px;
}

/* ===================== 通用按钮（增强） ===================== */
button,
.btn {
    background: linear-gradient(180deg, var(--color-gold) 0%, var(--color-gold-dark) 100%) !important;
    color: #000 !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    font-weight: bold;
}

button:hover,
.btn:hover {
    box-shadow: 
        0 4px 12px rgba(255, 215, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-1px);
}

button:active,
.btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

button:disabled,
.btn:disabled {
    background: #555 !important;
    color: #888 !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none !important;
}

/* ===================== 通用输入框（增强） ===================== */
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    background: rgba(0, 0, 0, 0.4) !important;
    color: #fff;
    border: 1px solid #555 !important;
    border-radius: 6px;
    outline: none;
    transition: all 0.3s;
}

input:focus,
textarea:focus {
    border-color: var(--color-gold) !important;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2) !important;
}

/* ===================== index.html 导航栏（增强） ===================== */
.nav-bottom {
    background: linear-gradient(180deg, #2d2d38 0%, #1a1a22 100%) !important;
    border-top: 1px solid rgba(255, 215, 0, 0.15) !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4) !important;
}

.nav-btn {
    color: #aaa !important;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    text-align: center;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 11px !important;
}

.nav-btn .nav-icon {
    font-size: 18px;
    margin-bottom: 1px;
    line-height: 1;
}

.nav-btn:hover {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.08) !important;
}

.nav-btn.active {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.12) !important;
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
    border-radius: 0 0 4px 4px;
}

/* ===================== HP/MP 圆球（图片版） ===================== */
.hp-mp-circle {
    width: 84px !important;
    height: 84px !important;
    min-width: 84px !important;
    min-height: 84px !important;
    max-width: 84px !important;
    max-height: 84px !important;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    /* 用自定义图片当底：左红=血 右蓝=蓝，图自带金边/龙头/竖线 */
    background: #1a1a1a url('../images/hp_mp_orb.jpg') center/cover no-repeat !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6) !important;
}

/* 左右两半改透明，让底图透出来 */
.hp-mp-circle .hp-half,
.hp-mp-circle .mp-half {
    background: transparent !important;
}

/* 消耗遮罩：贴顶，高度=已消耗百分比，从上往下变暗 */
.hp-mp-circle .hp-fill,
.hp-mp-circle .mp-fill {
    top: 0 !important;
    bottom: auto !important;
    background: rgba(0, 0, 0, 0.62) !important;
    transition: height 0.3s ease !important;
}

/* 图片自带竖线，隐藏 CSS 画的那条 */
.hp-mp-circle .hp-mp-divider {
    display: none !important;
}

/* 文字层：血量在上、蓝量在下，居中压在球面上 */
.hp-mp-circle .hp-mp-text {
    position: absolute !important;
    z-index: 3 !important;
    top: 50% !important;
    left: 0 !important;
    width: 100% !important;
    transform: translateY(-50%);
    text-align: center !important;
    pointer-events: none;
}
.hp-mp-circle .hp-text,
.hp-mp-circle .mp-text {
    font-size: 12px !important;
    font-weight: bold;
    line-height: 1.25;
    color: #fff !important;
    /* 多层黑描边，保证在红/蓝亮底图上清晰可读 */
    text-shadow: 0 0 3px #000, 1px 1px 1px #000, -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000 !important;
    white-space: nowrap;
}

/* ===================== 快捷栏（增强，两排三列） ===================== */
.quick-slots {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 138px !important;   /* 3列*42 + 2间距*6 = 138 */
    gap: 6px !important;
    justify-content: center !important;
}
/* 主页：4 个一排（双类选择器，稳压上面的通用规则） */
.quick-slots.quick-slots-4 {
    flex-wrap: nowrap !important;
    width: auto !important;
}
.quick-slot {
    width: 42px !important;
    height: 42px !important;
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid #555 !important;
    overflow: hidden;
    border-radius: 4px;
    transition: all 0.2s;
}

.quick-slot:hover {
    border-color: var(--color-gold) !important;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.3) !important;
}

.quick-slot.has-item {
    border-color: var(--color-gold-dark) !important;
    box-shadow: 0 0 4px rgba(255, 215, 0, 0.35) !important;
}

/* ===================== 背包格子稀有度边框 ===================== */
.item-slot,
.equip-slot,
.bag-item {
    transition: all 0.2s;
}

.rarity-white { border-color: #999 !important; background: rgba(153,153,153,0.06) !important; }
.rarity-green { border-color: var(--rarity-green) !important; box-shadow: 0 0 5px rgba(46,204,113,0.4) !important; background: rgba(46,204,113,0.06) !important; }
.rarity-blue { border-color: var(--rarity-blue) !important; box-shadow: 0 0 5px rgba(52,152,219,0.4) !important; background: rgba(52,152,219,0.06) !important; }
.rarity-purple { border-color: var(--rarity-purple) !important; box-shadow: 0 0 7px rgba(155,89,182,0.5) !important; background: rgba(155,89,182,0.08) !important; }
.rarity-orange { border-color: var(--rarity-orange) !important; box-shadow: 0 0 7px rgba(230,126,34,0.5) !important; background: rgba(230,126,34,0.08) !important; }
.rarity-red { border-color: var(--rarity-red) !important; box-shadow: 0 0 9px rgba(231,76,60,0.6) !important; background: rgba(231,76,60,0.1) !important; }
.rarity-gold { border-color: var(--rarity-gold) !important; box-shadow: 0 0 10px rgba(241,196,15,0.6) !important; background: rgba(241,196,15,0.1) !important; }
.rarity-colorful { border-color: #0ff !important; box-shadow: 0 0 12px rgba(0,255,255,0.6), 0 0 20px rgba(255,0,255,0.3) !important; background: linear-gradient(135deg, rgba(0,255,255,0.08), rgba(255,0,255,0.08)) !important; }

/* ===================== Toast 通知组件 ===================== */
.toast-container {
    position: fixed;
    top: 45%;               /* 从顶部 15% 移到屏幕中间，减少飘屏干扰 */
    left: 50%;
    transform: translate(-50%, -50%);
    /* z-index 提到 100002：盖过技能书商店浮层(.ssp-overlay z-index:100000)与游戏弹窗
       (.gd-mask 100000)，否则「购买成功」toast 会被商店面板挡住而看不到。
       toast 只显示 1.6 秒且 pointer-events:none，置于最顶层安全。 */
    z-index: 100002;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.toast {
    background: rgba(0, 0, 0, 0.55);   /* 透明度 0.88→0.55，更淡 */
    color: var(--color-gold);
    padding: 7px 14px;                 /* 更小 */
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.22);
    font-size: 12px;                   /* 14→12 */
    max-width: 280px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    /* 停留更短：淡出提前到 1.2s（配合 JS 1600ms 移除） */
    animation: toastIn 0.25s ease, toastOut 0.3s ease 1.2s forwards;
    white-space: pre-line;
    word-break: break-word;
}

.toast.toast-success { color: #2ecc71; border-color: rgba(46, 204, 113, 0.4); }
.toast.toast-error { color: #e74c3c; border-color: rgba(231, 76, 60, 0.4); }
.toast.toast-warning { color: #f39c12; border-color: rgba(243, 156, 18, 0.4); }
.toast.toast-info { color: #3498db; border-color: rgba(52, 152, 219, 0.4); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-20px) scale(0.9); }
}

/* ===================== 战斗日志颜色编码 ===================== */
.log-damage { color: #ff5555; }
.log-heal { color: #55ff55; }
.log-system { color: #aaa; }
.log-crit { color: #ffd700; font-weight: bold; }
.log-exp { color: #f39c12; }
.log-item { color: #3498db; }

/* ===================== 加载遮罩（增强） ===================== */
.loading-mask {
    background: rgba(0, 0, 0, 0.92) !important;
    color: var(--color-gold) !important;
    flex-direction: column !important;
}

.loading-mask::before {
    content: '⚔';
    display: block;
    font-size: 32px;
    animation: spin 1.2s linear infinite;
    margin-bottom: 10px;
}

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

/* ===================== 通用文字颜色 ===================== */
.text-gold { color: var(--color-gold); }
.text-silver { color: #c0c0c0; }
.text-red { color: #ff4444; }
.text-green { color: #4caf50; }
.text-blue { color: #2196f3; }
.text-purple { color: #9c27b0; }
.text-orange { color: #ff9800; }

/* ===================== 通用间距 ===================== */
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

/* ===================== 通用布局 ===================== */
.flex { display: flex; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-column { display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ===================== 通用动画 ===================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
.fade-in { animation: fadeIn 0.3s ease; }
.pulse { animation: pulse 1s ease infinite; }

/* ===================== 滚动条 ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ===================== 响应式 ===================== */
@media (max-width: 400px) {
    .game-container,
    .login-container,
    .bag-container,
    .char-container {
        width: 100% !important;
        height: 100vh !important;
        border: none !important;
        border-radius: 0 !important;
    }
}


/* ===================== quick-wrap 防压扁补充 ===================== */
.quick-wrap {
    overflow: visible !important;
    min-height: 92px !important;
    align-items: center !important;
}

/* ===================== 战斗中浮层查看人物/背包/技能 =====================
   已改用主页同款 pageOverlay（css/pageOverlay.css + js/pageOverlay.js），
   旧的 .battle-overlay* 自定义样式全部废弃删除。 */

/* ===================== 统一装备详情弹窗（左右对比，紧凑版） ===================== */
/* 由 js/equipModalUnified.js 注入，背包/仓库/身上共用。选择器带 .equip-compare-modal
   以覆盖 bag.css / character.css 里旧的 .item-modal 尺寸样式。 */
.item-modal.equip-compare-modal {
    /* 定宽让左右两列有充足并肩空间（原 auto+min-width:280 会缩到 264，两列 132×2 撑不下→换行堆成上下） */
    width: 340px;
    max-width: 94vw;
    border: 2px solid #8b7355;
}
.equip-compare-modal .modal-body {
    max-height: 74vh;
    overflow-y: auto;
    padding: 8px;
}
/* 关闭叉号放大、加大点击热区（背包/仓库/身上共用弹窗，统一覆盖 bag.css/character.css 的 20px 小叉） */
.equip-compare-modal .modal-close {
    top: 4px;
    right: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    line-height: 1;
}
/* 两列容器 */
.equip-compare-cols {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}
.equip-compare-cols .equip-card {
    flex: 1 1 0;
    /* min-width:0 让两列可压缩并肩显示（左右对比），不再因 132px 撑不下而换行堆成上下 */
    min-width: 0;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #3d3020;
    border-radius: 4px;
    padding: 6px 8px;
}
.equip-compare-cols .equip-card-right {
    background: rgba(60, 48, 32, 0.18);
    opacity: 0.92;
}
/* 战力汇总行：占满整行显示在两列下方 */
.equip-compare-cols .equip-power-summary {
    flex-basis: 100%;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: #ddd;
    padding: 6px 0 2px;
    border-top: 1px solid #3d3020;
    margin-top: 2px;
}
.equip-power-summary .old-power { color: #aaa; }
.equip-power-summary .new-power { color: #ffd700; }
.equip-power-summary .diff.positive { color: #4CAF50; }
.equip-power-summary .diff.negative { color: #f44336; }
.equip-power-summary .diff.neutral { color: #888; }

/* 卡片标题 */
.equip-card-head {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1px solid #4d4020;
}
.equip-card-tag {
    font-size: 10px;
    color: #8b7355;
    background: rgba(139, 115, 85, 0.18);
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
}
/* 品质徽章：带品质底色的小胶囊，深色字，任意底色都清晰 */
.equip-card-quality {
    font-size: 10px;
    font-weight: bold;
    color: #1a1a1a;
    padding: 1px 5px;
    border-radius: 3px;
    line-height: 1.4;
    white-space: nowrap;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}
/* 幻彩徽章：彩虹渐变底，区别于其它纯色品质 */
.equip-card-quality.q-colorful {
    background: linear-gradient(90deg,#ff4d4d,#ffb84d,#ffff4d,#4dff88,#4dc3ff,#b84dff) !important;
    color: #1a1a1a !important;
}
.equip-card-name {
    font-size: 13px;
    font-weight: bold;
    color: #ffd700;
    line-height: 1.2;
}
/* 属性行（紧凑、小字） */
.equip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11.5px;
    line-height: 1.5;
    padding: 1px 0;
}
.equip-row-label {
    color: #9a9a9a;
    white-space: nowrap;
    margin-right: 6px;
}
.equip-row-value {
    color: #fff;
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
}
/* 附加属性：浅绿色凸显 */
.equip-row.secondary .equip-row-label { color: #7fc47f; }
.equip-row.secondary .equip-row-value {
    color: #90ee90;
    text-shadow: 0 0 3px rgba(144, 238, 144, 0.45);
}
/* 属性升降箭头 */
.equip-row-diff { font-size: 10px; margin-left: 3px; font-weight: bold; }
.equip-row-diff.positive { color: #4CAF50; }
.equip-row-diff.negative { color: #f44336; }
/* 出售价格行 */
.equip-compare-modal .equip-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11.5px;
    padding: 6px 4px 2px;
    margin-top: 6px;
    border-top: 1px solid #3d3020;
}
.equip-compare-modal .equip-price-row .attr-label { color: #9a9a9a; }

/* 宝石属性 / 镶嵌信息块 */
.equip-gem-socket { margin-top: 4px; }
.equip-gem-socket .gem-socket-block {
    border-top: 1px solid #3d3020;
    padding: 5px 4px 2px;
    margin-top: 4px;
}
.gem-socket-title {
    font-size: 12px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 3px;
}
.gem-socket-line { font-size: 11px; color: #ccc; line-height: 1.5; }
.gem-socket-line.special { color: #4ade80; }
.gem-socket-line.inlaid { color: #4ade80; }
.gem-socket-line.open { color: #fbbf24; }
.gem-socket-line.locked { color: #999; }
.gem-socket-line.hint { color: #888; font-size: 10px; }

/* 宝石属性 Tooltip（点击显示） */
.gem-tooltip {
    position: fixed;
    z-index: 3000;
    max-width: 240px;
    background: linear-gradient(180deg, #1c1c22 0%, #0e0e12 100%);
    border: 1px solid #6b5b8a;
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    pointer-events: auto;
}
.gem-tooltip .gem-tip-name { font-size: 13px; font-weight: bold; margin-bottom: 4px; }
.gem-tooltip .gem-tip-effect { font-size: 11.5px; color: #ddd; line-height: 1.5; }
.gem-tooltip .gem-tip-value { font-size: 11.5px; color: #90ee90; margin-top: 2px; }
.gem-tooltip .gem-tip-special { font-size: 11px; color: #fbbf24; margin-top: 4px; line-height: 1.5; border-top: 1px solid #3d3350; padding-top: 4px; }