/* ============================================================
   Mac 风格主题 (macOS Sonoma / Sequoia 视觉风格)
   - 亚克力磨砂、细分割线、SF 字体、圆角卡片、柔和阴影
   ============================================================ */

:root {
    /* 系统色 - 大背景统一纯色(不用渐变, 避免上下色感差异) */
    --mac-bg: #eef1f6;
    --mac-window-bg: rgba(255, 255, 255, 0.82);
    --mac-titlebar-bg: rgba(246, 246, 246, 0.9);
    --mac-border: rgba(0, 0, 0, 0.08);
    --mac-divider: rgba(0, 0, 0, 0.06);
    --mac-text: #1d1d1f;
    --mac-text-secondary: #6e6e73;
    --mac-text-tertiary: #86868b;
    --mac-accent: #0071e3;
    --mac-accent-hover: #0077ed;
    --mac-accent-active: #006edb;
    --mac-success: #34c759;
    --mac-warning: #ff9500;
    --mac-error: #ff3b30;
    --mac-red: #ff5f57;
    --mac-yellow: #febc2e;
    --mac-green: #28c840;
    --mac-input-bg: rgba(255, 255, 255, 0.9);
    --mac-input-border: rgba(0, 0, 0, 0.1);
    --mac-input-focus: #0071e3;
    --mac-radius-sm: 6px;
    --mac-radius-md: 10px;
    --mac-radius-lg: 16px;
    --mac-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.03);
    --mac-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --mac-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
    --mac-transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --mac-bg: #20232a;
        --mac-window-bg: rgba(30, 30, 32, 0.85);
        --mac-titlebar-bg: rgba(46, 46, 48, 0.9);
        --mac-border: rgba(255, 255, 255, 0.08);
        --mac-divider: rgba(255, 255, 255, 0.06);
        --mac-text: #f5f5f7;
        --mac-text-secondary: #a1a1a6;
        --mac-text-tertiary: #86868b;
        --mac-input-bg: rgba(46, 46, 48, 0.9);
        --mac-input-border: rgba(255, 255, 255, 0.1);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--mac-text);
    background: var(--mac-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern", "liga";
}

body {
    min-height: 100vh;
    padding: 40px 20px 80px;  /* 底部 padding 比顶部大, 让白色卡片与视口底部留白 */
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* ============================================================
   Mac 窗口容器
   ============================================================ */

.mac-window {
    width: 100%;
    max-width: 780px;
    background: var(--mac-window-bg);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-radius: var(--mac-radius-lg);
    border: 1px solid var(--mac-border);
    box-shadow: var(--mac-shadow-lg);
    overflow: hidden;
    animation: windowAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes windowAppear {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.mac-titlebar {
    height: 44px;
    background: var(--mac-titlebar-bg);
    border-bottom: 1px solid var(--mac-divider);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: relative;
    user-select: none;
}

.mac-traffic-lights {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tl {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.15);
    transition: var(--mac-transition);
}

.tl-close { background: var(--mac-red); }
.tl-min { background: var(--mac-yellow); }
.tl-max { background: var(--mac-green); }

.mac-titlebar-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 500;
    color: var(--mac-text-secondary);
    letter-spacing: 0.02em;
}

.mac-content {
    padding: 40px 48px 48px;
}

@media (max-width: 640px) {
    body { padding: 16px 12px; }
    .mac-content { padding: 24px 20px 32px; }
}

/* ============================================================
   页面标题
   ============================================================ */

.page-header {
    text-align: center;
    margin-bottom: 36px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--mac-text);
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--mac-text-secondary);
}

/* ============================================================
   表单
   ============================================================ */

.form-section {
    margin-bottom: 28px;
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--mac-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mac-divider);
}

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--mac-text);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--mac-error);
    margin-left: 2px;
}

.form-label .optional {
    font-size: 12px;
    color: var(--mac-text-tertiary);
    font-weight: 400;
    margin-left: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--mac-text);
    background: var(--mac-input-bg);
    border: 1px solid var(--mac-input-border);
    border-radius: var(--mac-radius-md);
    outline: none;
    transition: var(--mac-transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--mac-text-tertiary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--mac-input-focus);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.form-textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.5;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236e6e73' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-help {
    font-size: 12px;
    color: var(--mac-text-tertiary);
    margin-top: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

/* 省/市/县 三级联动 - 任何屏幕都保持一行 */
.region-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.region-row .form-group {
    margin-bottom: 0;
    min-width: 0;  /* 允许收缩 */
}

.region-row .form-label {
    font-size: 13px;
    margin-bottom: 4px;
    white-space: nowrap;
}

.region-row .form-select {
    padding: 10px 24px 10px 10px;
    font-size: 13px;
    width: 100%;
    background-position: right 8px center;
    background-size: 10px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .region-row { gap: 6px; }
    .region-row .form-label { font-size: 12px; }
    .region-row .form-select {
        padding: 8px 20px 8px 8px;
        font-size: 12px;
    }
}

/* ============================================================
   单选按钮组 (Mac 风格分段控件)
   ============================================================ */

.segmented-control {
    display: flex;
    background: var(--mac-input-bg);
    border: 1px solid var(--mac-input-border);
    border-radius: var(--mac-radius-md);
    padding: 3px;
    gap: 2px;
    width: fit-content;
}

.segmented-control .segment {
    flex: 0 1 auto;
}

.segmented-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented-control label {
    display: inline-block;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--mac-text-secondary);
    border-radius: 7px;
    cursor: pointer;
    transition: var(--mac-transition);
    user-select: none;
    white-space: nowrap;
}

.segmented-control input[type="radio"]:checked + label {
    background: var(--mac-accent);
    color: white;
    box-shadow: var(--mac-shadow-sm);
}

.segmented-control label:hover {
    color: var(--mac-text);
}

.segmented-control input[type="radio"]:checked + label:hover {
    color: white;
}

/* 组别分段控件(更多项,允许换行) */
.segmented-control.wrap {
    flex-wrap: wrap;
    width: 100%;
}

/* ============================================================
   验证码
   ============================================================ */

.captcha-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.captcha-row .form-input.captcha-input {
    flex: 0 0 160px;
    max-width: 160px;
    height: 50px;
    padding: 0 14px;
    font-size: 16px;
}

.captcha-img {
    width: 140px;
    height: 50px;
    border-radius: var(--mac-radius-md);
    border: 1px solid var(--mac-input-border);
    cursor: pointer;
    transition: var(--mac-transition);
    background: #f5f5f7;
    display: block;
    flex: 0 0 140px;
    object-fit: cover;
}

@media (max-width: 480px) {
    .captcha-row .form-input.captcha-input {
        flex: 1;
        max-width: none;
    }
}

.captcha-img:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

/* ============================================================
   按钮
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 24px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--mac-radius-md);
    cursor: pointer;
    transition: var(--mac-transition);
    text-decoration: none;
    user-select: none;
    -webkit-appearance: none;
    appearance: none;
}

.btn-primary {
    background: var(--mac-accent);
    color: white;
    box-shadow: var(--mac-shadow-sm);
}

.btn-primary:hover {
    background: var(--mac-accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--mac-shadow-md);
}

.btn-primary:active {
    background: var(--mac-accent-active);
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--mac-text-tertiary);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--mac-input-bg);
    color: var(--mac-text);
    border: 1px solid var(--mac-input-border);
}

.btn-secondary:hover {
    background: var(--mac-titlebar-bg);
}

.btn-block {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
}

/* ============================================================
   后台宽屏布局: PC 默认宽, PAD/手机自适应收缩
   ============================================================ */

body.admin-wide .mac-window {
    max-width: 1400px;
}

@media (max-width: 1460px) {
    body.admin-wide .mac-window { max-width: 96vw; }
}

@media (max-width: 900px) {
    body.admin-wide .mac-window { max-width: 100%; }
}

/* 后台登录页: 窄窗 */
body.admin-login .mac-window {
    max-width: 460px;
}

@media (max-width: 520px) {
    body.admin-login .mac-window { max-width: 100%; }
}

.btn-danger {
    background: var(--mac-error);
    color: white;
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ============================================================
   提示消息
   ============================================================ */

.alert {
    padding: 12px 16px;
    border-radius: var(--mac-radius-md);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
    border: 1px solid;
}

.alert.show { display: block; }

.alert-success {
    background: rgba(52, 199, 89, 0.1);
    color: #248a3d;
    border-color: rgba(52, 199, 89, 0.3);
}

.alert-error {
    background: rgba(255, 59, 48, 0.1);
    color: #d70015;
    border-color: rgba(255, 59, 48, 0.3);
}

.alert-info {
    background: rgba(0, 113, 227, 0.1);
    color: var(--mac-accent);
    border-color: rgba(0, 113, 227, 0.3);
}

/* ============================================================
   表格 (后台列表)
   ============================================================ */

.mac-table-wrapper {
    overflow-x: auto;
    border-radius: var(--mac-radius-md);
    border: 1px solid var(--mac-divider);
    background: var(--mac-input-bg);
}

.mac-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mac-table thead {
    background: var(--mac-titlebar-bg);
    border-bottom: 1px solid var(--mac-divider);
}

.mac-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--mac-text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.mac-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--mac-divider);
    color: var(--mac-text);
    vertical-align: top;
}

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

.mac-table tbody tr:hover {
    background: rgba(0, 113, 227, 0.04);
}

.mac-table .cell-ellipsis {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   标签 / 徽章
   ============================================================ */

.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    letter-spacing: 0.02em;
}

.badge-primary { background: rgba(0, 113, 227, 0.12); color: var(--mac-accent); }
.badge-success { background: rgba(52, 199, 89, 0.15); color: #248a3d; }
.badge-warning { background: rgba(255, 149, 0, 0.15); color: #c93400; }
.badge-secondary { background: rgba(0, 0, 0, 0.06); color: var(--mac-text-secondary); }

/* ============================================================
   顶部导航(后台)
   ============================================================ */

.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--mac-divider);
}

.admin-nav-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--mac-text);
}

.admin-nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--mac-text-secondary);
}

.admin-nav-user a {
    color: var(--mac-accent);
    text-decoration: none;
    font-weight: 500;
}

.admin-nav-user a:hover {
    text-decoration: underline;
}

/* ============================================================
   筛选栏
   ============================================================ */

.filter-bar {
    background: var(--mac-input-bg);
    border: 1px solid var(--mac-divider);
    border-radius: var(--mac-radius-md);
    padding: 16px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.filter-bar .form-input,
.filter-bar .form-select {
    padding: 8px 12px;
    font-size: 13px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    grid-column: 1 / -1;
}

/* 筛选/重置/导出 按钮统一宽度 */
.filter-actions .btn {
    min-width: 140px;
    justify-content: center;
}

/* ============================================================
   分页
   ============================================================ */

.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 24px;
    align-items: center;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--mac-text);
    background: var(--mac-input-bg);
    border: 1px solid var(--mac-input-border);
    transition: var(--mac-transition);
}

.pagination a:hover {
    background: var(--mac-titlebar-bg);
    border-color: var(--mac-accent);
}

.pagination .current {
    background: var(--mac-accent);
    color: white;
    border-color: var(--mac-accent);
    font-weight: 600;
}

.pagination .disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .page-info {
    background: transparent;
    border: none;
    color: var(--mac-text-secondary);
    font-size: 12px;
}

/* ============================================================
   详情页
   ============================================================ */

.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px 20px;
    font-size: 14px;
}

.detail-grid dt {
    color: var(--mac-text-secondary);
    font-weight: 500;
}

.detail-grid dd {
    color: var(--mac-text);
    word-break: break-all;
}

/* ============================================================
   工具
   ============================================================ */

.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.text-secondary { color: var(--mac-text-secondary); }
.text-tertiary { color: var(--mac-text-tertiary); }
.text-small { font-size: 12px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* ============================================================
   Loading
   ============================================================ */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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