/* DCKU 会员系统后台样式（含移动端适配）*/

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

:root {
    --primary: #5c4815;
    --primary-light: #8b6914;
    --gold: #d4af37;
    --accent: #c0392b;
    --bg: #f4efe4;
    --card-bg: #ffffff;
    --text: #2c2c2c;
    --text-light: #666;
    --border: #e0d8c0;
    --border-radius: 8px;
    --success: #2e7d32;
    --warn: #c62828;
    --info: #1565c0;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

/* ========== 登录页 ========== */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #5c4815 0%, #8b6914 100%);
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 420px;
    padding: 40px 35px;
}

.login-header { text-align: center; margin-bottom: 30px; }
.login-logo { max-width: 80px; margin-bottom: 15px; }
.login-header h1 { color: var(--primary); font-size: 24px; margin-bottom: 5px; }
.login-subtitle { color: var(--text-light); font-size: 14px; font-style: italic; }
.login-assoc { color: var(--primary-light); font-size: 12px; margin-top: 8px; }

.login-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 13px 14px;   /* 高度提升至约 48px */
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.4;
    transition: border 0.2s;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}
.form-group select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235c4815' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212,175,55,0.15);
}
.form-group textarea { resize: vertical; min-height: 96px; }

.required { color: var(--warn); }

.login-footer { text-align: center; margin-top: 25px; font-size: 13px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}
.alert-error { background: #ffebee; color: var(--warn); border-left: 4px solid var(--warn); }
.alert-success { background: #e8f5e9; color: var(--success); border-left: 4px solid var(--success); }
.alert-warn { background: #fff8e1; color: #f57c00; border-left: 4px solid #f57c00; }

/* ========== 按钮 ========== */
.btn {
    padding: 12px 20px;   /* 高度提升至约 48px */
    min-height: 48px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.2;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--gold); color: var(--primary); }
.btn-secondary:hover { background: #e6bc4a; }
.btn-light { background: #f0f0f0; color: var(--text); }
.btn-light:hover { background: #e0e0e0; }
.btn-large { padding: 16px 28px; font-size: 17px; min-height: 56px; }

/* ========== 移动端顶部条 ========== */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 52px;
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.hamburger,
.mobile-logout {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 22px;
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.hamburger:active,
.mobile-logout:active { background: rgba(255,255,255,0.1); }
.mobile-title {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}
.mobile-title .sub { color: rgba(255,255,255,0.6); font-weight: 400; margin-left: 4px; font-size: 12px; }

/* ========== 抽屉遮罩 ========== */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.drawer-overlay.show {
    display: block;
    opacity: 1;
}

/* ========== 后台布局 ========== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--primary);
    color: white;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { max-width: 60px; margin-bottom: 10px; }
.sidebar-header h2 { color: var(--gold); font-size: 18px; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 20px 0; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;   /* 触控高度 */
    min-height: 48px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active {
    background: rgba(212,175,55,0.15);
    color: var(--gold);
    border-left-color: var(--gold);
}
.nav-icon { font-size: 18px; flex-shrink: 0; }
.nav-badge {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    margin-left: auto;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.admin-info { margin-bottom: 12px; }
.admin-name { color: white; font-size: 14px; font-weight: 600; }
.admin-role { color: rgba(255,255,255,0.6); font-size: 12px; word-break: break-all; }
.btn-logout, .btn-home {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 12px;
    margin-top: 8px;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    border-radius: var(--border-radius);
    transition: all 0.2s;
    text-decoration: none;
}
.btn-logout:hover { background: rgba(192,57,43,0.3); color: white; }
.btn-home:hover { background: rgba(255,255,255,0.08); color: white; }

/* ========== 主内容 ========== */
.main-content {
    flex: 1;
    padding: 30px 40px;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}
.page-header h1 { color: var(--primary); font-size: 24px; line-height: 1.3; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ========== 筛选栏 ========== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    align-items: center;
    background: white;
    padding: 18px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.filter-search {
    flex: 1;
    min-width: 220px;
}
.filter-search input {
    width: 100%;
    padding: 13px 14px;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 15px;
    -webkit-appearance: none;
}
.filter-search input:focus {
    outline: none;
    border-color: var(--gold);
}
.filter-select {
    padding: 13px 36px 13px 14px;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 15px;
    background: white url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235c4815' d='M6 8L0 0h12z'/></svg>") no-repeat right 14px center;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* ========== 表格 ========== */
.table-wrapper {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.member-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}
.member-table thead { background: var(--primary); color: white; }
.member-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}
.member-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.member-table tbody tr:hover { background: rgba(212,175,55,0.05); }
.empty-row { text-align: center; color: var(--text-light); padding: 40px; }
.cell-no { font-family: 'Courier New', monospace; font-size: 13px; color: var(--primary-light); white-space: nowrap; }
.cell-name { font-weight: 600; }
.sub-text { color: var(--text-light); font-size: 12px; font-weight: normal; }
.cell-actions { display: flex; gap: 10px; align-items: center; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    background: rgba(92,72,21,0.08);
    font-size: 16px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover { background: var(--primary); color: white; }

/* ========== 标签 ========== */
.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.tag-einzel { background: #e3f2fd; color: #1565c0; }
.tag-institution { background: #f3e5f5; color: #7b1fa2; }
.tag-lebenslang { background: #fff3e0; color: #e65100; }
.tag-ehren { background: #fce4ec; color: #c2185b; }

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.status-aktiv { background: #e8f5e9; color: var(--success); }
.status-wartend { background: #fff8e1; color: #f57c00; }
.status-inaktiv { background: #f5f5f5; color: var(--text-light); }
.status-abgelehnt { background: #ffebee; color: var(--warn); }

.deliver {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.deliver-pending { background: #f5f5f5; color: var(--text-light); }
.deliver-emailed { background: #e3f2fd; color: var(--info); }
.deliver-mailed { background: #e8f5e9; color: var(--success); }
.deliver-handed { background: #f3e5f5; color: #7b1fa2; }

/* ========== 分页 ========== */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    margin-top: 25px;
    flex-wrap: wrap;
}
.page-btn {
    padding: 10px 14px;
    min-width: 40px;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: white;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.page-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-ellipsis { padding: 8px 6px; color: var(--text-light); }
.page-info { margin-left: 15px; color: var(--text-light); font-size: 13px; }

/* ========== 表单页 ========== */
.member-form {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
fieldset {
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px 25px;
    margin-bottom: 25px;
}
legend {
    color: var(--primary);
    font-weight: 600;
    padding: 0 10px;
    font-size: 16px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}
.form-group.full-width { grid-column: 1 / -1; }
.form-hint {
    color: var(--text-light);
    font-size: 12px;
    margin-top: 8px;
    font-style: italic;
}
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ========== 详情页 ========== */
.member-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    border-left: 5px solid var(--gold);
}
.member-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
.member-avatar { flex-shrink: 0; }
.avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold);
}
.avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border: 3px solid var(--border);
}
.member-title-block { flex: 1; min-width: 200px; }
.invite-source {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
    color: var(--text-light);
}
.invite-source code {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--primary-light);
    font-family: 'Courier New', monospace;
    word-break: break-all;
}
.upload-preview {
    max-width: 100px;
    max-height: 100px;
    margin-top: 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}
.member-card-header h2 { color: var(--primary); font-size: 22px; line-height: 1.3; }
.member-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.detail-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}
.detail-section h3 {
    color: var(--primary);
    font-size: 16px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gold);
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
    min-width: 0;
}
.detail-item.full { grid-column: 1 / -1; }
.detail-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 600;
}
.detail-value {
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
}
.detail-value.mono { font-family: 'Courier New', monospace; color: var(--primary-light); }

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.log-table th {
    background: var(--bg);
    padding: 10px;
    text-align: left;
    color: var(--primary);
    font-size: 12px;
}
.log-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.certificate-action {
    margin-top: 25px;
    text-align: center;
    padding: 25px;
    background: rgba(212,175,55,0.08);
    border-radius: var(--border-radius);
    border: 1px dashed var(--gold);
}

/* ========== 响应式：平板/大屏手机 ≤ 768px ========== */
@media (max-width: 768px) {
    /* 顶部条生效 */
    .mobile-header { display: flex; }

    /* 侧边栏默认改为抽屉（隐藏在左侧屏幕外） */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        max-width: 84%;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.25);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-nav { padding: 10px 0; }
    .nav-item {
        min-height: 52px;
        padding: 12px 20px;
    }
    .sidebar-footer { display: block; }   /* 恢复显示：管理员信息+退出按钮 */
    .btn-logout, .btn-home { min-height: 48px; }

    /* 主内容区调整 */
    .admin-layout { flex-direction: column; }
    .main-content {
        padding: 16px 14px;
        overflow-x: visible;   /* 让 .table-wrapper 里的 overflow-x:auto 接管 */
    }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header h1 { font-size: 20px; }
    .page-actions { flex-direction: row; overflow-x: auto; }
    .page-actions .btn { flex: 1; min-width: 0; }

    /* 筛选栏 */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }
    .filter-search,
    .filter-select,
    .filter-bar .btn {
        width: 100%;
    }

    /* 表单/详情栅格变单栏 */
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }

    /* 表单页卡片和字段集缩小 padding */
    .member-form { padding: 18px 14px; }
    fieldset { padding: 14px 12px; margin-bottom: 18px; }
    legend { padding: 0 8px; font-size: 15px; }

    /* 详情卡片 */
    .member-card { padding: 18px 16px; }
    .detail-section { padding: 18px 16px; }
    .member-card-header { flex-direction: column; align-items: flex-start; }

    /* 表格：隐藏部分次要列，表头、数据都隐藏（按 class 控制） */
    .member-table th.col-date,
    .member-table td.col-date,
    .member-table th.col-deliver,
    .member-table td.col-deliver,
    .member-table th.col-expires,
    .member-table td.col-expires,
    .member-table th.col-creator,
    .member-table td.col-creator { display: none; }

    /* 表格字体略缩 */
    .member-table { font-size: 13px; min-width: 0; }
    .member-table th { padding: 12px 10px; font-size: 12px; }
    .member-table td { padding: 10px; }

    /* 分页按钮略小 */
    .page-btn { padding: 9px 12px; min-width: 38px; min-height: 38px; font-size: 13px; }
    .page-info { margin-left: 0; margin-top: 4px; width: 100%; text-align: center; }

    /* 卡片 padding 紧凑 */
    .certificate-action { padding: 18px 14px; }

    /* 操作表单按钮区左对齐、换行 */
    .form-actions { justify-content: stretch; }
    .form-actions .btn { flex: 1; }
}

/* ========== 响应式：普通手机 ≤ 640px ========== */
@media (max-width: 640px) {
    .main-content { padding: 14px 12px; }
    .page-header { margin-bottom: 18px; }
    .filter-bar { padding: 12px; gap: 10px; }

    /* 进一步隐藏更多次要列 */
    .member-table th.col-usage,
    .member-table td.col-usage,
    .member-table th.col-referrer,
    .member-table td.col-referrer { display: none; }

    /* 详情头像尺寸缩小 */
    .avatar-img, .avatar-placeholder { width: 64px; height: 64px; font-size: 28px; }

    /* 登录页卡片内边距、logo */
    .login-card { padding: 30px 24px; }
    .login-logo { max-width: 72px; }
    .login-header h1 { font-size: 22px; }

    .member-form { padding: 16px 12px; }
    .member-card { padding: 16px 14px; }
    .detail-section { padding: 16px 14px; }
    .detail-section h3 { font-size: 15px; margin-bottom: 14px; }
}

/* ========== 响应式：手机竖屏 ≤ 480px ========== */
@media (max-width: 480px) {
    /* 登录页 */
    .login-body { padding: 10px; }
    .login-card { padding: 24px 18px; border-radius: 10px; }
    .login-logo { max-width: 64px; }
    .login-header { margin-bottom: 22px; }
    .login-header h1 { font-size: 20px; }
    .login-subtitle { font-size: 13px; }
    .login-assoc { font-size: 11px; }
    .login-form { gap: 14px; }

    /* 管理后台 */
    .mobile-title { font-size: 14px; }
    .main-content { padding: 12px 10px; }
    .page-header h1 { font-size: 18px; }
    .page-header { margin-bottom: 14px; gap: 10px; }
    .filter-bar { padding: 10px; gap: 8px; margin-bottom: 18px; }

    /* 表格进一步精简：会员列表隐藏邮箱，只保留编号/姓名/类型/状态/操作 */
    .member-table th.col-email,
    .member-table td.col-email { display: none; }

    .member-table { font-size: 12px; }
    .member-table th { padding: 10px 8px; font-size: 11px; }
    .member-table td { padding: 9px 8px; }
    .cell-no { font-size: 12px; }
    .sub-text { font-size: 11px; }
    .tag, .status, .deliver { font-size: 11px; padding: 3px 8px; }
    .btn-icon { width: 40px; height: 40px; font-size: 15px; }
    .cell-actions { gap: 6px; }

    .btn { padding: 11px 14px; font-size: 14px; min-height: 44px; }
    .form-group input,
    .form-group select,
    .form-group textarea,
    .filter-search input,
    .filter-select { font-size: 14px; }

    .pagination { margin-top: 18px; gap: 4px; }
    .page-btn { padding: 8px 10px; min-width: 34px; min-height: 36px; font-size: 12px; }

    .member-card { padding: 14px 12px; }
    .detail-section { padding: 14px 12px; }
    .detail-section h3 { font-size: 14px; margin-bottom: 12px; padding-bottom: 8px; }
    .detail-grid { gap: 10px; }
    .detail-item { padding: 5px 0; }

    .member-form { padding: 14px 10px; }
    fieldset { padding: 12px 10px; margin-bottom: 14px; }
    legend { font-size: 14px; }
    .form-grid { gap: 14px; }
}

/* ========== 响应式：小屏手机 ≤ 375px（iPhone SE 等） ========== */
@media (max-width: 375px) {
    .login-card { padding: 22px 16px; }
    .login-header h1 { font-size: 19px; }
    .form-group label { font-size: 13px; }
    .form-group input,
    .form-group select,
    .form-group textarea { padding: 12px; font-size: 14px; }
    .btn { font-size: 13px; padding: 10px 12px; }

    .main-content { padding: 10px 8px; }
    .page-header h1 { font-size: 17px; }
    .mobile-title { font-size: 13px; }

    .member-table th { padding: 9px 6px; }
    .member-table td { padding: 8px 6px; }
    .btn-icon { width: 38px; height: 38px; }
    .cell-actions { gap: 5px; }

    .alert { padding: 10px 12px; font-size: 13px; }
}
