/* 移动端自适应公共样式 */

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

:root {
    --primary-color: #1f6feb;
    --success-color: #2fb344;
    --warning-color: #f59f00;
    --error-color: #e03131;
    --info-color: #7b8497;
    --text-color: #1f2a3d;
    --border-color: #e5eaf3;
    --bg-color: #f3f6fb;
    --white: #fff;
    --shadow: 0 8px 24px rgba(15, 42, 79, 0.08);
    --radius-md: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(180deg, #f5f8fd 0%, var(--bg-color) 45%);
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 顶部导航栏 */
.header {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(229, 234, 243, 0.9);
}

.header-content {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary-color);
}

.header-nav {
    display: flex;
    gap: 15px;
}

.header-nav a {
    color: #374151;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 999px;
    transition: all 0.3s;
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--primary-color);
    background-color: #eaf3ff;
}

/* 主容器 */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 22px 20px;
}

/* 卡片 */
.card {
    background-color: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 16px;
    background: linear-gradient(180deg, #fbfcff 0%, #f8faff 100%);
}

.card-body {
    padding: 18px 20px;
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.3s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.form-control:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

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

/* 按钮 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #1f6feb 0%, #3b82f6 100%);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(31, 111, 235, 0.24);
}

.btn-success {
    background: linear-gradient(135deg, #2fb344 0%, #40c057 100%);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(47, 179, 68, 0.2);
}

.btn-warning {
    background: linear-gradient(135deg, #f59f00 0%, #fab005 100%);
    color: var(--white);
}

.btn-warning:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(245, 159, 0, 0.22);
}

.btn-danger {
    background: linear-gradient(135deg, #e03131 0%, #f03e3e 100%);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(224, 49, 49, 0.22);
}

.btn-default {
    background-color: var(--white);
    color: #374151;
    border: 1px solid var(--border-color);
}

.btn-default:hover:not(:disabled) {
    border-color: #c6d4ec;
    background: #f8fbff;
    color: var(--primary-color);
}

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

.btn-xs {
    padding: 4px 8px;
    font-size: 14px;
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 表格 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--white);
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: #f7f9fd;
    font-weight: 600;
    color: #344054;
}

.table tbody tr:hover {
    background-color: #f8fbff;
}

/* 状态标签 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background-color: #f6ffed;
    color: var(--success-color);
    border: 1px solid #b7eb8f;
}

.badge-warning {
    background-color: #fffbe6;
    color: var(--warning-color);
    border: 1px solid #ffe58f;
}

.badge-danger {
    background-color: #fff1f0;
    color: var(--error-color);
    border: 1px solid #ffccc7;
}

.badge-info {
    background-color: #f0f0f0;
    color: var(--info-color);
    border: 1px solid #d9d9d9;
}

.badge-primary {
    background-color: #e6f7ff;
    color: var(--primary-color);
    border: 1px solid #91d5ff;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--info-color);
}

.loading::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 提示消息 */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 280px;
    max-width: 90%;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

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

.toast-error {
    background-color: var(--error-color);
    color: var(--white);
}

.toast-warning {
    background-color: var(--warning-color);
    color: var(--white);
}

.toast-info {
    background-color: var(--primary-color);
    color: var(--white);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--info-color);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

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

.pagination button {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* 导航栏移动端优化 */
    .header-content {
        padding: 12px 15px;
        flex-wrap: nowrap;
        gap: 10px;
    }
    
    .header-title {
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .header-nav {
        display: none;
        width: 100%;
        order: 3;
        margin-top: 10px;
        gap: 5px;
        flex-wrap: wrap;
    }
    
    .header-nav.show {
        display: flex;
    }
    
    .header-nav a {
        padding: 8px 12px;
        background: #f5f5f5;
        border-radius: 4px;
        font-size: 13px;
        text-align: center;
        flex: 1;
        min-width: calc(33.33% - 5px);
    }
    
    .menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        padding: 5px;
    }
    
    /* 表格移动端优化 */
    .table-responsive {
        font-size: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    .table th,
    .table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    .table td:first-child,
    .table td:last-child {
        white-space: normal;
    }
    
    /* 按钮移动端优化 */
    .btn {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* 分页移动端 */
    .pagination {
        gap: 5px;
    }
    
    .pagination button {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        font-size: 12px;
    }
    
    /* Toast移动端 */
    .toast {
        min-width: auto;
        max-width: calc(100% - 40px);
        font-size: 13px;
    }
    
    /* 模态框移动端 */
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* 卡片标题 */
    .card-header {
        padding: 12px 15px;
        font-size: 15px;
    }
}

/* 小屏幕设备 */
@media screen and (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .header-nav a {
        min-width: calc(50% - 5px);
        font-size: 12px;
    }
    
    .table {
        font-size: 11px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .form-control {
        padding: 10px;
        font-size: 14px;
    }
    
    /* 卡片在小屏幕上的优化 */
    .order-card {
        margin: 10px;
        border-radius: 8px;
    }
    
    .order-header {
        padding: 15px;
    }
    
    .order-header h2 {
        font-size: 14px;
    }
    
    .order-header .order-no {
        font-size: 18px;
    }
    
    .order-body {
        padding: 15px;
    }
    
    .info-row {
        font-size: 13px;
    }
    
    .info-label {
        width: 70px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 8px;
        padding: 15px;
    }
    
    .action-buttons .btn {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* 快速入口按钮组 */
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* 模态框优化 */
    .modal-content {
        width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .modal-body {
        max-height: calc(100vh - 60px);
    }
}

/* 菜单按钮默认隐藏 */
.menu-toggle {
    display: none;
}

/* 工具类 */
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--error-color); }
.text-muted { color: var(--info-color); }
.d-none { display: none; }
.d-block { display: block; }

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

.modal .close {
    color: #999;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.modal .close:hover,
.modal .close:focus {
    color: #333;
}

/* ====== 移动端卡片列表样式 ====== */
.mobile-card-list {
    display: none;
}

.mobile-card {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-bottom: 1px solid #f0f0f0;
}

.mobile-card-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mobile-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mobile-card-body {
    padding: 12px 15px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px dashed #f5f5f5;
}

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

.mobile-card-label {
    color: #999;
    flex-shrink: 0;
    width: 70px;
}

.mobile-card-value {
    color: #333;
    text-align: right;
    flex: 1;
    word-break: break-all;
}

.mobile-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 15px;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
    flex-wrap: wrap;
}

.mobile-card-footer .btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 20px 10px;
    background: linear-gradient(135deg, #fafafa 0%, #fff 100%);
    border-radius: 8px;
}

.stat-number {
    font-size: 28px;
    font-weight: bold;
    line-height: 1.2;
}

.stat-label {
    color: var(--info-color);
    margin-top: 5px;
    font-size: 13px;
}

/* 筛选工具栏 */
.filter-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-toolbar .form-control {
    min-width: 120px;
}

.filter-toolbar .btn {
    white-space: nowrap;
}

/* 优化状态标签 */
.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    gap: 4px;
}

.status-tag-info { background: #e6f7ff; color: #1890ff; }
.status-tag-success { background: #f6ffed; color: #52c41a; }
.status-tag-warning { background: #fffbe6; color: #faad14; }
.status-tag-danger { background: #fff1f0; color: #f5222d; }

/* 短信状态标签优化 */
.sms-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    gap: 3px;
}

.sms-status-sent {
    background: linear-gradient(135deg, #d9f7be 0%, #f6ffed 100%);
    color: #389e0d;
}

.sms-status-pending {
    background: linear-gradient(135deg, #ffe7ba 0%, #fffbe6 100%);
    color: #d48806;
}

/* ====== 移动端适配优化 ====== */
@media screen and (max-width: 768px) {
    /* 隐藏桌面表格，显示移动卡片 */
    .desktop-table {
        display: none !important;
    }
    
    .mobile-card-list {
        display: block;
    }
    
    /* 统计卡片改为2列 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-item {
        padding: 15px 8px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    /* 筛选工具栏垂直排列 */
    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-toolbar .form-control,
    .filter-toolbar .btn {
        width: 100%;
    }
    
    .filter-toolbar .btn-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    /* 卡片头部标题 */
    .card-header {
        font-size: 15px;
        padding: 12px 15px;
    }
    
    /* 模态框全屏 */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    .modal-body {
        max-height: calc(100vh - 60px);
        padding: 15px;
    }
    
    /* 表单优化 */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    /* 按钮组优化 */
    .btn-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* 分页优化 */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }
    
    .pagination button {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
    
    /* 状态Tab移动端 */
    .status-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }
    
    .status-tab {
        padding: 10px 12px;
        font-size: 13px;
        flex-shrink: 0;
    }
    
    .status-tab .count {
        font-size: 11px;
        padding: 1px 6px;
    }
    
    /* 批量操作工具栏移动端 */
    #batchToolbar {
        padding: 10px !important;
    }
    
    #batchToolbar > div {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    #batchToolbar > div > div {
        width: 100%;
        justify-content: center;
    }
}

/* 小屏幕进一步优化 */
@media screen and (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .mobile-card {
        margin-bottom: 10px;
        border-radius: 10px;
    }
    
    .mobile-card-header {
        padding: 10px 12px;
    }
    
    .mobile-card-body {
        padding: 10px 12px;
    }
    
    .mobile-card-footer {
        padding: 8px 12px;
    }
    
    .mobile-card-footer .btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .stat-number {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 11px;
    }
}

/* 统计卡片块 - 简洁现代风格 */
.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: #1890ff;
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);
}

.stat-card-number {
    font-size: 36px;
    font-weight: 600;
    line-height: 1;
}

.stat-card-label {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

/* 移动端统计卡片适配 */
@media (max-width: 768px) {
    .stat-card {
        padding: 16px 12px;
    }
    
    .stat-card-number {
        font-size: 28px;
    }
    
    .stat-card-label {
        font-size: 12px;
    }
}
