/* ============================================================
   小米商城风格模板 — 全站设计系统（设计令牌 + 基础元素）
   风格：参考 mi.com/shop —— 白底大字、橙色点缀、简洁大气
   本文件为全站必加载样式，所有页面共用
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
    /* 声明为浅色页面：避免系统/浏览器深色模式把原生表单控件（复选框/单选框）染成黑色 */
    color-scheme: light;

    /* 品牌色（小米橙） */
    --brand: #ff6700;
    --brand-hover: #f25807;
    --brand-deep: #d95500;
    --brand-light: #fff4ec;
    --brand-grad: linear-gradient(135deg, #ff8534, #ff6700);

    /* 中性色 */
    --ink: #141414;
    --ink-2: #1f1f1f;
    --text: #333333;
    --text-strong: #111111;
    --text-2: #757575;
    --text-3: #b0b0b0;
    --bg: #f5f5f5;
    --card: #ffffff;
    --line: #e8e8e8;
    --line-2: #f0f0f0;

    /* 状态色 */
    --success: #14b81a;
    --danger: #e53935;
    --warning: #ff8f00;
    --info: #1e88e5;

    /* 几何 */
    --radius-xs: 4px;
    --radius-s: 8px;
    --radius: 12px;
    --radius-l: 18px;
    --shadow-s: 0 1px 4px rgba(0, 0, 0, .05);
    --shadow: 0 4px 16px rgba(0, 0, 0, .08);
    --shadow-hover: 0 12px 28px rgba(0, 0, 0, .14);
    --container: 1226px;
    --header-h: 64px;

    /* 动效 */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --fast: .18s var(--ease);
    --mid: .3s var(--ease);
}

/* ---------- 全局重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: var(--text); text-decoration: none; transition: color var(--fast); }
a:hover { color: var(--brand); }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* 复选框 / 单选框自绘（不再依赖浏览器 accent-color，避免其把对勾/圆点渲染成黑色）：
   选中 = 品牌橙底 + 白色对勾 / 白色圆点；具体尺寸由页面级更具体的规则覆盖（14/16/18/20px） */
input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid #c4c4c4;
    border-radius: 4px;
    background-color: #fff;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    cursor: pointer;
    vertical-align: middle;
    flex-shrink: 0;
    transition: background-color var(--fast), border-color var(--fast);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
input[type="radio"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3.2' fill='%23fff'/%3E%3C/svg%3E");
}

::selection { background: var(--brand); color: #fff; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局容器 ---------- */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 0 32px;
    flex: 1;
    width: 100%;
}
.container--flush { padding: 0; max-width: none; }

/* 通栏内容包裹（.mi-wrap 为全站统一定宽容器，header/footer/index/products 共用） */
.mi-wrap {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}
.mi-section { padding: 40px 0; }
.mi-section--gray { background: #fafafa; }
.mi-section--white { background: #fff; }

/* 欢迎条（管理员工具信息，低调处理） */
.greeting {
    max-width: var(--container);
    margin: 12px auto;
    padding: 8px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    font-size: 12px;
    color: var(--text-3);
}
.greeting p { margin: 0; }

/* ---------- 全站统一面包屑 ---------- */
.breadcrumb,
.plist-breadcrumb,
.faq-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    font-size: 13px;
    color: var(--text-2);
    padding: 16px 0;
}
.breadcrumb a,
.plist-breadcrumb a,
.faq-breadcrumb a { color: var(--text-2); text-decoration: none; transition: color var(--fast); }
.breadcrumb a:hover,
.plist-breadcrumb a:hover,
.faq-breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep,
.plist-breadcrumb .sep,
.faq-breadcrumb .sep { margin: 0 8px; color: var(--text-3); }
.breadcrumb .current,
.plist-breadcrumb .current,
.faq-breadcrumb .current {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
}

/* ---------- 通用按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 28px;
    height: 44px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    transition: all var(--fast);
    user-select: none;
    white-space: nowrap;
}
.btn-primary, .btn-buy-now { background: var(--brand); color: #fff; }
.btn-primary:hover, .btn-buy-now:hover { background: var(--brand-hover); color: #fff; }
.btn-outline, .btn-add-cart {
    background: #fff;
    border-color: var(--brand);
    color: var(--brand);
}
.btn-outline:hover, .btn-add-cart:hover { background: var(--brand-light); border-color: var(--brand-hover); color: var(--brand-hover); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #333; color: #fff; }
.btn-ghost { background: #f5f5f5; color: var(--text); }
.btn-ghost:hover { background: #ececec; color: var(--text); }
.btn-lg { height: 52px; padding: 0 40px; font-size: 16px; }
.btn-sm { height: 36px; padding: 0 18px; font-size: 13px; }
.btn-disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* 主按钮内部文字/加载态：继承按钮颜色，避免被通用类名覆盖导致看不见 */
button.btn-text { background: none; border: 0; color: var(--brand); padding: 0; height: auto; }
.btn .btn-text, .btn .btn-loading { color: inherit; padding: 0; background: none; }

/* ---------- 通用区块标题 ---------- */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 12px;
}
.section-head h2 {
    font-size: 24px;
    font-weight: 500;
    color: var(--text-strong);
    letter-spacing: .5px;
}
.section-head .more {
    font-size: 13px;
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.section-head .more:hover { color: var(--brand); }

/* ---------- 价格（全站统一样式） ---------- */
.mi-price, .price {
    color: var(--brand);
    font-weight: 600;
    font-size: 20px;
}
.mi-price-original, .price-original {
    color: var(--text-3);
    font-size: 13px;
    text-decoration: line-through;
    font-weight: 400;
}

/* ---------- 页脚 ---------- */
footer {
    background: var(--ink);
    color: #9e9e9e;
    margin-top: auto;
}
footer a { color: #9e9e9e; }
footer a:hover { color: #fff; text-decoration: none; }

/* ---------- Toast 提示 ---------- */
.toast-container {
    position: fixed;
    top: 84px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 24px;
    border-radius: var(--radius);
    background: rgba(25, 25, 25, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
    font-size: 14px;
    color: #fff;
    opacity: 0;
    transform: translateY(-16px);
    transition: opacity .35s var(--ease), transform .35s var(--ease);
    pointer-events: auto;
    min-width: 260px;
    max-width: 480px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hiding { opacity: 0; transform: translateY(-16px); }
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-success .toast-icon { color: #4ade80; }
.toast-error .toast-icon { color: #f87171; }
.toast-warning .toast-icon { color: #fbbf24; }
.toast-info .toast-icon { color: #60a5fa; }

/* ---------- 空状态 ---------- */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 72px 20px;
    color: var(--text-3);
}
.empty-state svg { color: #d8d8d8; }
.empty-state p { font-size: 14px; margin: 0; }

/* ---------- 加载骨架 ---------- */
.mi-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #f7f7f7 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: mi-skeleton 1.2s ease infinite;
    border-radius: var(--radius-s);
}
@keyframes mi-skeleton {
    from { background-position: 100% 50%; }
    to { background-position: 0 50%; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1260px) {
    .container { padding-left: 16px; padding-right: 16px; }
    .container--flush { padding-left: 0; padding-right: 0; }
}
@media (max-width: 768px) {
    .section-head h2 { font-size: 19px; }
    .greeting { margin: 8px 12px; }
    .mi-section { padding: 26px 0; }
    .breadcrumb,
    .plist-breadcrumb,
    .faq-breadcrumb { font-size: 12px; padding: 10px 0; }
}

/* ============================================================
   移动端体验优化（全局，≤768px 生效）
   ============================================================ */
@media (max-width: 768px) {
    /* iOS Safari：表单控件字号 <16px 时聚焦会自动放大页面 */
    input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]),
    select,
    textarea { font-size: 16px; }

    /* 主按钮加大触摸高度 */
    .btn { height: 46px; font-size: 15px; }

    /* 移动端用 :active 给出即时按压反馈 */
    a:active, button:active, .btn:active, .sort-item:active, .category-tags li > a:active { opacity: .75; }

    /* Toast 窄屏自适应宽度 */
    .toast-container { left: 12px; right: 12px; transform: none; }
    .toast { min-width: 0; max-width: none; width: 100%; }
}
