/* =============================================================
   顾客查询系统 - 主样式文件
   设计原则：简洁专业、响应式、无障碍友好
   ============================================================= */

/* ---- CSS 变量（主题色彩系统）---- */
:root {
    --primary:      #4f46e5;   /* 主色：靛紫 */
    --primary-dark: #3730a3;
    --primary-light:#e0e7ff;
    --success:      #10b981;   /* 成功绿 */
    --warning:      #f59e0b;   /* 警告橙 */
    --danger:       #ef4444;   /* 危险红 */
    --info:         #3b82f6;   /* 信息蓝 */
    --secondary:    #6b7280;   /* 次要灰 */

    --bg:           #f1f5f9;   /* 页面背景 */
    --surface:      #ffffff;   /* 卡片背景 */
    --border:       #e2e8f0;   /* 边框颜色 */

    --text-primary: #1e293b;   /* 主文字 */
    --text-secondary:#64748b;  /* 次要文字 */
    --text-muted:   #94a3b8;   /* 辅助文字 */

    --radius:       8px;       /* 圆角半径 */
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:    0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);

    --navbar-height:60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* ---- 全局重置 ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================================================================
   导航栏
   ================================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    height: var(--navbar-height);
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    gap: 24px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    flex: 1;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.nav-link:hover { background: var(--bg); color: var(--text-primary); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.user-name {
    font-size: .9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
}

/* ================================================================
   主内容区域
   ================================================================ */
.main-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: .9rem;
}

/* ================================================================
   卡片
   ================================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-action {
    font-size: .85rem;
    color: var(--primary);
}

.card-body { padding: 16px 20px; }
.card-body.p-0 { padding: 0; }

/* ================================================================
   统计卡片（首页）
   ================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { color: var(--text-secondary); font-size: .85rem; margin-top: 2px; }
.stat-sub   { color: var(--text-muted);    font-size: .8rem; }

.stat-blue   { border-left: 4px solid var(--primary); }
.stat-green  { border-left: 4px solid var(--success); }
.stat-purple { border-left: 4px solid #8b5cf6; }
.stat-orange { border-left: 4px solid var(--warning); }

.content-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 16px;
}

.chart-card { height: fit-content; }

/* ================================================================
   过滤表单
   ================================================================ */
.filter-card { padding: 16px 20px; }

.filter-form {}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.filter-item-wide { grid-column: span 2; }

.filter-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ================================================================
   表单控件
   ================================================================ */
.form-input,
.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

/* ================================================================
   按钮
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-block { width: 100%; justify-content: center; }

.btn-primary  { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }

.btn-secondary { background: var(--bg); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); text-decoration: none; }

.btn-info { background: var(--info);    color: #fff; }
.btn-info:hover { opacity: .85; text-decoration: none; }

.btn-sm { padding: 4px 10px; font-size: .8rem; }

/* ================================================================
   数据表格
   ================================================================ */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.table th {
    padding: 10px 14px;
    background: var(--bg);
    font-weight: 600;
    font-size: .8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    text-align: left;
}

.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.table-hover tr:hover td { background: #f8faff; }

.table tr:last-child td { border-bottom: none; }

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-money   { color: #059669; font-weight: 600; }
.text-bold    { font-weight: 700; }
.text-muted   { color: var(--text-muted); }
.text-truncate{ max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.py-8 { padding-top: 32px; padding-bottom: 32px; }

.order-no {
    font-family: monospace;
    font-size: .85rem;
    color: var(--text-secondary);
}

.customer-cell { display: flex; flex-direction: column; }
.customer-name { font-weight: 600; }
.customer-phone { font-size: .8rem; color: var(--text-muted); }

.product-cell { display: flex; flex-direction: column; }
.product-name { font-weight: 500; }
.product-category {
    display: inline-block;
    font-size: .75rem;
    background: var(--bg);
    color: var(--text-secondary);
    padding: 1px 6px;
    border-radius: 4px;
    margin-top: 2px;
}

/* ================================================================
   徽章（状态标签）
   ================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success   { background: #d1fae5; color: #065f46; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--bg); color: var(--text-secondary); }

/* ================================================================
   结果统计栏
   ================================================================ */
.result-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: .875rem;
    margin-bottom: 8px;
}

/* ================================================================
   分页
   ================================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 0 8px;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: .875rem;
    transition: all .15s;
    text-decoration: none;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ================================================================
   弹窗（Modal）
   ================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-box {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn .2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: background .15s;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px 22px; }

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th {
    width: 120px;
    padding: 8px 12px;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: .85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.detail-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

/* ================================================================
   登录页
   ================================================================ */
.login-page {
    background: linear-gradient(135deg, #e0e7ff 0%, #f1f5f9 60%, #dbeafe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    display: inline-flex;
    margin-bottom: 12px;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-subtitle {
    color: var(--text-muted);
    font-size: .9rem;
    margin-top: 4px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: .8rem;
    color: var(--text-muted);
}

.form-group { margin-bottom: 18px; }

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 10px;
    font-size: 1rem;
    pointer-events: none;
}

.input-wrapper .form-input {
    padding-left: 34px;
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: .6;
}
.toggle-password:hover { opacity: 1; }

/* ================================================================
   提示框
   ================================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 16px;
}

.alert-icon { flex-shrink: 0; }

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ================================================================
   响应式（移动端适配）
   ================================================================ */
@media (max-width: 1024px) {
    .content-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .navbar-menu {
        display: none;
        position: absolute;
        top: var(--navbar-height);
        left: 0; right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 8px;
        box-shadow: var(--shadow-md);
    }
    .navbar-menu.open { display: flex; }
    .navbar-toggle { display: block; }
    .navbar-user .user-name { display: none; }

    .main-wrapper { padding: 16px 12px 32px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.2rem; }

    .filter-grid { grid-template-columns: 1fr; }
    .filter-item-wide { grid-column: span 1; }

    .page-title { font-size: 1.2rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 24px 18px; }
}
