/* ============================================
   卡密管理系统后台 - Apple风格完整UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --success: #34c759;
    --warning: #ff9f0a;
    --danger: #ff3b30;
    --border: rgba(0,0,0,0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', sans-serif;
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ===== 侧边栏 ===== */
.sidebar {
    width: 240px;
    background: rgba(255,255,255,0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 15px;
    font-weight: 600;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent) 0%, #5856d6 100%);
    color: white;
    border-radius: var(--radius-md);
    text-align: center;
    letter-spacing: -0.01em;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.menu-item:hover {
    background: rgba(0,0,0,0.04);
}

.menu-item.active {
    background: rgba(0,113,227,0.1);
    color: var(--accent);
    font-weight: 500;
}

.menu-item .icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

/* ===== 主内容区 ===== */
.main {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== 顶部栏 ===== */
.header {
    height: 52px;
    background: rgba(255,255,255,0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

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

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

/* ===== 内容区 ===== */
.content {
    flex: 1;
    padding: 28px;
}

/* ===== 页面切换 ===== */
.page { display: none; }
.page.active { display: block; animation: pageIn 0.3s ease; }

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 统计卡片 ===== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-card .value.blue { color: var(--accent); }
.stat-card .value.green { color: var(--success); }
.stat-card .value.orange { color: var(--warning); }
.stat-card .value.red { color: var(--danger); }


.message-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .message-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
}

/* ===== 面板/卡片 ===== */
.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-body {
    padding: 20px;
}

/* 卡密管理头部工具栏 */
.card-keys-header {
    min-height: 0;
    gap: 12px;
}

.card-keys-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.card-keys-actions select {
    width: 110px;
    flex: 0 0 110px;
    padding: 8px 12px;
    font-size: 14px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
}

.card-keys-actions .btn {
    padding: 8px 14px;
}

/* 消息日志时间列保持单行显示 */
.log-time-cell {
    min-width: 168px;
    white-space: nowrap;
}

/* ===== 表格 ===== */
.table-wrap {
    overflow-x: auto;
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap th,
.table-wrap td {
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
}

.table-wrap th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.table-wrap td {
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: rgba(0,0,0,0.02); }

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label,
.form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 14px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    transition: all var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
    border-color: var(--accent);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #c7c7cc;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 980px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

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

.btn-success:hover {
    background: #2db84d;
}

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

.btn-danger:hover {
    background: #e6352b;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* ===== 标签 ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 980px;
    background: var(--bg);
    color: var(--text-secondary);
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.page-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 12px;
}

/* ===== 模态框 ===== */
.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-mask.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.96);
    transition: transform var(--transition);
}

.modal-mask.show .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: rgba(0,0,0,0.08);
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

/* ===== 配置 ===== */
.config-section {
    margin-bottom: 24px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.config-row:last-child { border-bottom: none; }

/* ===== Toast提示 ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== 加载状态 ===== */
.loading {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    padding: 40px;
}

.empty {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    padding: 40px;
}

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

/* ============================================
   输入框优化 - Apple风格精致输入
   ============================================ */

/* 覆盖所有内联样式的输入框 - 统一Apple风格 */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="file"],
select,
textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    color: #1d1d1f !important;
    background: #f5f5f7 !important;
    border: 1.5px solid #e5e5ea !important;
    border-radius: 10px !important;
    padding: 10px 14px !important;
    outline: none !important;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
    box-shadow: none !important;
    width: auto;
    line-height: 1.4;
}

/* 确保select箭头样式 */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    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 d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    padding-right: 36px !important;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="date"]:hover,
select:hover,
textarea:hover {
    border-color: #c7c7cc !important;
    background: #efeff1 !important;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: #0071e3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0,113,227,0.12) !important;
}

input::placeholder,
textarea::placeholder {
    color: #c7c7cc !important;
    font-weight: 400 !important;
}

/* 文本域 */
textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* 数字输入框 */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.5;
}

/* 文件上传 */
input[type="file"] {
    padding: 8px 12px !important;
    cursor: pointer;
}

/* 日期输入框 */
input[type="date"] {
    min-height: 40px;
}

/* 输入框行布局 */
.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.form-row label {
    font-size: 13px;
    font-weight: 500;
    color: #86868b;
    white-space: nowrap;
    min-width: fit-content;
}

.form-row input,
.form-row select {
    flex: 1;
}

/* 搜索框特殊样式 */
#user-search,
#log-keyword {
    min-width: 200px;
}

/* 小输入框 */
input.small,
select.small {
    padding: 6px 10px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
}

/* 卡片内的配置行 */
.config-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.config-row:last-child {
    border-bottom: none;
}

.config-row label {
    font-size: 13px;
    font-weight: 500;
    color: #86868b;
    min-width: 80px;
}

.config-row input,
.config-row select {
    flex: 1;
}

/* 模态框内输入框 */
.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
}

/* 表单组内的输入框 */
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

.form-group label,
.form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #86868b;
    margin-bottom: 6px;
}

/* 按钮样式也覆盖一下内联的 */
button, .btn {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', sans-serif !important;
}


    



/* ===== 移动端适配 - 增强 ===== */
/* 汉堡菜单按钮 */
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        background: transparent;
        font-size: 22px;
        color: #1d1d1f;
        cursor: pointer;
        border-radius: 8px;
        flex-shrink: 0;
    }
    .sidebar-toggle:hover {
        background: rgba(0,0,0,0.05);
    }

    /* 侧边栏移动端样式 */
    .sidebar {
        z-index: 100;
        box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    }
    
    /* 页面边距 */
    .content {
        padding: 16px 12px !important;
    }
    
    /* 面板圆角调小 */
    .panel {
        border-radius: 12px;
    }
    
    .panel-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .panel-title {
        font-size: 14px;
    }

    .card-keys-header {
        align-items: flex-start;
    }

    .card-keys-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .card-keys-actions select {
        width: 100%;
        flex: 1 1 140px;
    }
    
    .panel-body {
        padding: 14px 16px;
    }
    
    /* 配置行 - 移动端竖排 */
    .config-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 10px 0;
    }
    
    .config-row label {
        min-width: auto;
        font-size: 12px;
        margin-bottom: 0;
    }
    
    .config-row input,
    .config-row select,
    .config-row textarea {
        width: 100% !important;
        flex: none !important;
    }
    
    /* 按钮组 - 移动端可换行 */
    .panel-header .btn,
    .panel-body .btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .panel-body [style*="display:flex"] {
        flex-wrap: wrap !important;
    }
    
    /* 表格 - 卡片模式 */
    .table-wrap table {
        font-size: 12px;
    }
    
    .table-wrap th,
    .table-wrap td {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    /* 统计卡片 */
    .stat-cards {
        gap: 10px;
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
    
    /* 表单行 */
    .form-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .form-row input,
    .form-row select {
        width: 100% !important;
    }
    
    /* 分页 */
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    /* 弹出框 */
    .modal {
        width: 95%;
        max-width: none;
        margin: 10px;
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 80px;
    }
    
    /* 顶部栏调小 */
    .header {
        height: 48px;
        padding: 0 12px;
    }
    
    .header-title {
        font-size: 15px;
    }
    
    .header-user {
        font-size: 12px;
        gap: 8px;
    }
    
    /* 扫码弹窗适配 */
    #scanModal > div {
        width: 92% !important;
        padding: 20px !important;
        max-width: none !important;
    }
    
    #scanModal img {
        max-width: 200px !important;
    }

    /* details 摘要 */
    details summary {
        font-size: 13px;
    }
    
    /* 保活状态 */
    #weapp-keepalive-status {
        font-size: 13px;
    }
}

/* 非常小屏幕 */
/* 防止iOS缩放 */
    }
    
    .stat-card .value {
        font-size: 20px;
    }
    
    .header-title {
        font-size: 14px;
    }
    
    /* 按钮两列布局 */
    [style*="display:flex"][style*="gap"] {
        gap: 6px !important;
    }
    
    [style*="display:flex"][style*="gap"] .btn {
        flex: 1;
        min-width: 0;
        padding: 8px 10px;
        font-size: 12px;
    }
}


/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .sidebar-overlay.show { display: block; }
    .sidebar-close { display: inline-flex !important; }
    
    .main { margin-left: 0; }
    .stat-cards { grid-template-columns: 1fr; gap: 10px; }
    .content { padding: 16px 12px; }
    
    .panel { border-radius: 12px; }
    .panel-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
    .panel-body { padding: 14px 16px; }
    
    .config-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 10px 0;
    }
    .config-row label { min-width: auto; font-size: 12px; }
    .config-row input,
    .config-row select,
    .config-row textarea { width: 100% !important; flex: none !important; }
    
    .header { height: 48px; padding: 0 12px; }
    .header-title { font-size: 15px; }
    .header-user { font-size: 12px; gap: 8px; }
    
    .table-wrap th, .table-wrap td { padding: 8px 10px; font-size: 12px; }
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 24px; }
    
    #scanModal > div { width: 92% !important; padding: 20px !important; max-width: none !important; }
    #scanModal img { max-width: 200px !important; }
    
    .form-row { flex-direction: column; gap: 8px; }
    .form-row input, .form-row select { width: 100% !important; }
    
    .modal { width: 95%; max-width: none; margin: 10px; border-radius: 16px; }
}

/* 侧边栏头部 */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.sidebar-logo { flex: 1; margin-bottom: 0; }
.sidebar-close {
    display: none;
    width: 32px; height: 32px;
    align-items: center; justify-content: center;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white; font-size: 22px;
    cursor: pointer; border-radius: 50%;
    flex-shrink: 0; line-height: 1; padding: 0;
    transition: background 0.2s;
}
.sidebar-close:hover { background: rgba(255,255,255,0.35); }

/* 卡密列表分页数量选择 */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.page-size-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.page-size-control select {
    width: 76px !important;
    min-height: 34px;
    padding: 6px 28px 6px 10px !important;
    font-size: 13px !important;
}
