/* ==========================================
   北海康辉散客ERP系统 - 全局样式
   ========================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", -apple-system, sans-serif; background: #f0f2f5; color: #333; line-height: 1.5; }

/* Header */
.header { background: #fff; border-bottom: 1px solid #e8e8e8; padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.header .logo { font-size: 17px; font-weight: 600; color: #1a73e8; }
.header .user-info { font-size: 13px; color: #666; display: flex; align-items: center; gap: 16px; }
.header .user-info a { color: #1a73e8; text-decoration: none; }

/* Navigation */
.nav { background: #fff; border-bottom: 1px solid #f0f0f0; }
.nav .container { display: flex; gap: 8px; padding: 0 20px; }
.nav-item { display: inline-block; padding: 12px 18px; font-size: 14px; color: #666; text-decoration: none; border-bottom: 2px solid transparent; transition: all 0.2s; }
.nav-item:hover { color: #1a73e8; }
.nav-item.active { color: #1a73e8; border-bottom-color: #1a73e8; font-weight: 600; }

/* Container */
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

/* Card */
.card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 20px; overflow: visible; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; font-size: 15px; font-weight: 600; color: #333; display: flex; justify-content: space-between; align-items: center; }
.card-body { padding: 20px; }

/* Buttons */
.btn { display: inline-block; padding: 8px 20px; border-radius: 6px; font-size: 14px; text-decoration: none; cursor: pointer; border: none; transition: background 0.2s; }
.btn-primary { background: #1a73e8; color: #fff; }
.btn-primary:hover { background: #1557b0; }
.btn-default { background: #fff; color: #333; border: 1px solid #d9d9d9; }
.btn-default:hover { background: #fafafa; }
.btn-success { background: #52c41a; color: #fff; }
.btn-success:hover { background: #49b016; }

/* Messages */
.error-msg { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; padding: 10px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.success-msg { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; padding: 10px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.warn-msg { background: #fffbe6; border: 1px solid #ffe58f; color: #ad6800; padding: 10px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.warn-msg a { color: #d4380d; font-weight: 600; }
.draft-msg { background: #f0f7ff; border: 1px solid #bae0ff; color: #0958d9; padding: 10px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.draft-msg a { color: #0958d9; font-weight: 600; }
/* 填表过程中「草稿已保存」状态提示（右下角固定，不打扰填写） */
.draft-status { position: fixed; right: 18px; bottom: 18px; z-index: 50; font-size: 12px; color: #8c8c8c; background: rgba(255,255,255,.94); border: 1px solid #eee; border-radius: 14px; padding: 5px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.draft-status.saving { color: #d46b08; }
.draft-status.saved  { color: #389e0d; }
.draft-status.error  { color: #cf1322; }
/* 侧栏草稿箱数量提示 */
.draft-badge { margin-left: auto; background: #fa8c16; color: #fff; font-size: 11px; line-height: 16px; border-radius: 8px; padding: 0 6px; }
/* 侧栏红点角标：有待处理事项（待缴费 / 退费待审 / 待审核合计） */
.nav-badge { margin-left: auto; background: #ff4d4f; color: #fff; font-size: 11px; line-height: 16px; border-radius: 8px; padding: 0 6px; min-width: 16px; text-align: center; box-sizing: border-box; }
/* 卡片标题里的条数小标（非侧栏） */
.count-tag { display: inline-block; background: #ff4d4f; color: #fff; font-size: 11px; line-height: 16px; border-radius: 8px; padding: 0 6px; min-width: 16px; text-align: center; box-sizing: border-box; vertical-align: 1px; }

/* Forms */
.form-section { margin-bottom: 24px; }
.form-section h3 { font-size: 14px; color: #1a73e8; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid #f0f0f0; }
.form-row { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 200px; }
.form-group label { display: block; font-size: 13px; color: #666; margin-bottom: 4px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: #1a73e8; }
.form-group textarea { resize: vertical; }
/* 单选/复选框恢复原生尺寸，避免被上面的 100% 宽度规则撑爆 */
.form-group input[type="radio"],
.form-group input[type="checkbox"] { width: auto; padding: 0; accent-color: #1a73e8; }
/* 成团约定等行内紧凑控件 */
.opt-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.opt-row > span, .opt-row label { white-space: nowrap; }
.opt-row select { width: 110px; flex: 0 0 auto; padding: 6px 8px; font-size: 13px; }
.opt-row input[type="text"] { width: 240px; flex: 0 0 auto; padding: 6px 10px; font-size: 13px; }
.opt-row input[type="number"] { width: 90px; flex: 0 0 auto; padding: 6px 10px; font-size: 13px; }
/* 单行布局：禁止换行，文本输入框自动伸缩填充剩余空间 */
.opt-row.single-line { flex-wrap: nowrap; }
.opt-row input.grow-text { flex: 1 1 auto; width: auto; min-width: 140px; }

/* form-group 级宽度上限工具类 */
.field-xs { max-width: 110px; }
.field-sm { max-width: 160px; }
.field-md { max-width: 220px; }
.field-lg { max-width: 320px; }
.field-flex-2 { flex: 2; }

/* 表格内紧凑输入：统一替代表内 width:xxxpx */
.table-input { width: 100%; min-width: 0; box-sizing: border-box; }
.w-xs { max-width: 70px; }   .w-sm { max-width: 110px; }
.w-md { max-width: 150px; }  .w-lg { max-width: 200px; }

/* .opt-row 变体 */
.opt-row--wrap    { flex-wrap: wrap; }
.opt-row--between { justify-content: space-between; }
.opt-row--gap-lg  { gap: 20px; }

/* disabled 控件灰底(替代内联 style) */
.form-group select:disabled,
.form-group input:disabled,
.form-group textarea:disabled { background: #f5f5f5; color: #666; cursor: not-allowed; }

/* 分步向导与确认信息表(从三张合同表单的 <style> 块移入) */
.step-wizard { display: flex; justify-content: space-between; margin-bottom: 24px; position: relative; }
.step-wizard::before { content: ''; position: absolute; top: 17px; left: 10%; right: 10%; height: 2px; background: #e0e0e0; z-index: 0; }
.step-item { position: relative; z-index: 1; flex: 1; text-align: center; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: #e0e0e0; color: #666; font-weight: bold; }
.step-item.active .step-num { background: #1a73e8; color: #fff; }
.step-item.done .step-num { background: #34a853; color: #fff; }
.step-label { display: block; margin-top: 6px; font-size: 13px; color: #666; }
.step-item.active .step-label { color: #1a73e8; font-weight: bold; }
.step-item.done .step-label { color: #34a853; }
.step-pane { display: none; }
.step-pane.active { display: block; }
.summary-table th { width: 140px; text-align: left; color: #666; font-weight: normal; padding: 6px 10px 6px 0; vertical-align: top; }
.summary-table td { padding: 6px 0; }

.form-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid #f0f0f0; display: flex; gap: 12px; align-items: center; }

/* 响应式：窄屏不溢出 */
@media (max-width: 768px) {
  .form-group { min-width: 0; }
  .opt-row, .opt-row.single-line { flex-wrap: wrap; }
  .table-input { max-width: none; }
  .step-wizard::before { left: 15%; right: 15%; }
  .summary-table th { width: 100px; }
}

/* 分房"选人"复选框组（替代 Ctrl 多选下拉，点选即选） */
.room-people-box {
  display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start;
  max-height: 150px; overflow-y: auto;
  border: 1px solid #d9d9d9; border-radius: 6px;
  background: #fff; padding: 8px;
  min-height: 42px;
}
.room-people-empty { color: #999; font-size: 12px; line-height: 24px; }
.room-person {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; white-space: nowrap;
  padding: 4px 12px; border: 1px solid #e2e2e2; border-radius: 16px;
  background: #fafafa; cursor: pointer; user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.room-person:hover { border-color: #1a73e8; }
.room-person.checked { background: #e8f0fe; border-color: #1a73e8; color: #1a73e8; font-weight: 500; }
.room-person input { accent-color: #1a73e8; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
th { color: #666; font-weight: 500; background: #fafafa; }

/* Status Badges */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.status-draft { background: #fff7e6; color: #d46b08; }
.status-pending { background: #e6f7ff; color: #096dd9; }
.status-generated { background: #fffbe6; color: #ad8b00; }
.status-partial { background: #fffbe6; color: #ad8b00; }
.status-completed { background: #f6ffed; color: #389e0d; }
.status-cancel { background: #f5f5f5; color: #999; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; color: #999; }
.empty-state p { margin-top: 12px; font-size: 14px; }

/* Login Box */
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); width: 400px; max-width: 90%; }
.login-brand { text-align: center; margin-bottom: 8px; }
.login-brand .login-logo { width: 170px; height: auto; object-fit: contain; }
.login-box h1 { text-align: center; color: #666464; margin-bottom: 8px; font-size: 20px; white-space: nowrap; }
.login-box .subtitle { text-align: center; color: #666; font-size: 13px; margin-bottom: 30px; }
.login-box label { display: block; font-size: 14px; color: #333; margin-bottom: 6px; }
.login-box input[type="text"], .login-box input[type="password"] { width: 100%; padding: 10px 14px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; margin-bottom: 18px; outline: none; transition: border-color 0.2s; }
.login-box input:focus { border-color: #1a73e8; }

/* Stat Cards */
.stat-row { display: flex; gap: 20px; flex-wrap: wrap; }
.stat-item { flex: 1; min-width: 120px; text-align: center; padding: 16px; background: #fafafa; border-radius: 8px; }
.stat-item .stat-num { font-size: 28px; font-weight: 700; color: #333; }
.stat-item .stat-label { font-size: 12px; color: #999; margin-top: 4px; }
.stat-draft { background: #fff7e6; }
.stat-draft .stat-num { color: #d46b08; }
.stat-pending { background: #e6f7ff; }
.stat-pending .stat-num { color: #096dd9; }
.stat-ok { background: #f6ffed; }
.stat-ok .stat-num { color: #389e0d; }

/* 行程填写要求提示 */
.requirement-tip {
    display: inline-block;
    position: relative;
    font-size: 12px;
    font-weight: 400;
    color: #1a73e8;
    cursor: pointer;
    margin-left: 12px;
    padding: 2px 10px;
    border: 1px solid #1a73e8;
    border-radius: 4px;
    vertical-align: middle;
}
.requirement-tip .requirement-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 0;
    background: #fffef5;
    border: 1px solid #e8d48b;
    border-radius: 6px;
    padding: 16px 20px;
    width: 620px;
    max-width: 95vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 9999;
    font-size: 13px;
    color: #333;
    line-height: 1.8;
    text-align: left;
    font-weight: 400;
}
.requirement-tip .requirement-popup ol {
    padding-left: 20px;
}
.requirement-tip:hover .requirement-popup,
.requirement-tip:focus .requirement-popup {
    display: block;
}

/* ==========================================
   管理后台布局：左侧菜单 + 右侧内容区
   ========================================== */
.app { display: flex; min-height: 100vh; }

/* 左侧菜单 */
.sidebar { width: 236px; background: linear-gradient(180deg, #14213d 0%, #1b2a4a 100%); color: #cbd5e1; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: margin-left .25s ease; }
.sidebar .brand { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: rgba(0,0,0,.18); color: #fff; font-size: 16px; font-weight: 600; flex-shrink: 0; }
.sidebar .logo-dot { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #4f8cff, #2b6ef2); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.sidebar .brand-logo { width: 30px; height: 30px; flex-shrink: 0; object-fit: contain; }
.sidebar .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; min-width: 0; }
.menu-group { padding: 0 10px; overflow-y: auto; flex: 1; }
.section { font-size: 11px; color: #8ea3c0; text-transform: uppercase; letter-spacing: .08em; padding: 14px 20px 6px; margin-top: 8px; }
.menu-item { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-radius: 8px; color: #cbd5e1; text-decoration: none; margin-bottom: 2px; font-size: 14px; position: relative; transition: background .15s, color .15s; }
.menu-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu-item.active { background: rgba(79,140,255,.18); color: #fff; }
.menu-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #4f8cff; }
.menu-item .icon { width: 20px; text-align: center; font-size: 16px; }
.menu-item.sub { padding-left: 40px; }
.menu-item.group { color: #eaeef5; font-weight: 600; cursor: default; }
.menu-item.group:hover { background: transparent; }
.sidebar .foot { padding: 14px 20px; font-size: 12px; color: #7d8ca6; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }

/* 右侧主区 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid #e7ebf3; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1600px; width: 100%; margin: 0 auto; padding: 0 22px; height: 100%; display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar .hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: #3b465a; }
.topbar .crumb { color: #8a94a6; font-size: 13px; }
.topbar .crumb b { color: #2b2f3a; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #3b465a; }
.topbar .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #4f8cff, #2b6ef2); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.topbar .logout { font-size: 13px; color: #6b7280; text-decoration: none; padding: 6px 12px; border: 1px solid #e0e5ef; border-radius: 6px; transition: .15s; }
.topbar .logout:hover { color: #ef4444; border-color: #ef4444; }
.content { padding: 22px; max-width: 1600px; width: 100%; margin: 0 auto; }
.content-scroll { overflow-x: auto; }

/* 页面标题区 */
.page-title { font-size: 19px; font-weight: 700; color: #1b2a4a; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-title .sub { font-size: 13px; color: #8a94a6; font-weight: 400; }

/* 表格细节点缀：行 hover 高亮 */
tbody tr:hover td { background: #f7f9fc; }

/* 响应式：小屏收起侧栏 */
@media (max-width: 900px) {
    .sidebar { margin-left: -236px; }
    .sidebar.open { margin-left: 0; }
    .topbar .hamburger { display: inline-block; }
    .content { padding: 14px; }
}

/* ==========================================
   移动端适配：第一阶段
   ========================================== */

/* 统计卡片响应式 */
@media (max-width: 768px) {
    .stat-row {
        gap: 12px;
    }

    .stat-item {
        flex: 0 1 calc(50% - 6px);
        min-width: calc(50% - 6px);
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .stat-item {
        flex: 1;
        min-width: 100%;
    }
}

/* 表格横向滚动 */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    table {
        min-width: 800px;
    }

    th, td {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* 按钮触摸优化 */
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .btn {
        padding: 10px 16px;
        font-size: 15px;
    }

    /* 按钮组自动换行 */
    .action-btns,
    .form-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .btn {
        flex: 0 1 auto;
    }
}

/* 表单间距调整 */
@media (max-width: 768px) {
    .form-group {
        margin-bottom: 12px;
    }

    .form-row {
        gap: 12px;
        margin-bottom: 12px;
    }

    /* 详情页信息行改为单列 */
    .detail-row {
        flex-direction: column;
    }

    .detail-label {
        margin-bottom: 4px;
    }

    /* 步骤条优化 */
    .step-wizard {
        margin-bottom: 18px;
    }

    .step-num {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .step-label {
        font-size: 12px;
        margin-top: 4px;
    }
}

/* 最小屏（iPhone SE 等）步骤条只显示数字 */
@media (max-width: 480px) {
    .step-label {
        display: none;
    }

    .step-num {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* 创建合同表单：标签上下排列 */
    .form-group label {
        font-size: 12px;
    }

    /* 向导操作按钮占满宽度，更易点击 */
    .step-actions,
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }

    .step-actions .btn,
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* 详情表格小屏优化 */
    .card-body table th {
        width: auto;
        max-width: 80px;
        word-break: break-word;
    }

    .card-body table td {
        word-break: break-word;
    }
}

/* ==========================================
   移动端：列表表格 → 卡片（一行一张卡片）
   仅 <=768px 生效；PC 端不受影响。
   表格加 class="table-cards"，data-label 由 main.js 按表头自动生成。
   ========================================== */
@media (max-width: 768px) {
    table.table-cards { min-width: 0; width: 100%; border-collapse: separate; }
    /* 表头视觉隐藏（保留给读屏） */
    table.table-cards thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
    }
    table.table-cards,
    table.table-cards tbody,
    table.table-cards tr,
    table.table-cards td { display: block; }
    table.table-cards tr {
        background: #fff; border: 1px solid #e8ebf0; border-radius: 8px;
        margin-bottom: 12px; padding: 4px 12px; box-shadow: 0 1px 4px rgba(0,0,0,.04);
    }
    table.table-cards td {
        position: relative; padding: 8px 0 8px 6.5em; min-height: 36px;
        border-bottom: 1px dashed #f0f0f0; font-size: 13px; text-align: left;
        word-break: break-word; overflow-wrap: anywhere;
    }
    table.table-cards td:last-child { border-bottom: none; }
    table.table-cards td::before {
        content: attr(data-label); position: absolute; left: 0; top: 8px;
        width: 6em; color: #8a94a6; font-weight: 500; font-size: 12px; line-height: 1.6;
    }
    /* 操作列、空数据行：通栏，不显示标签 */
    table.table-cards td.td-actions,
    table.table-cards td.td-full { padding-left: 0; }
    table.table-cards td.td-actions::before,
    table.table-cards td.td-full::before,
    table.table-cards td[data-label=""]::before { display: none; }
    table.table-cards td.td-actions { padding-top: 10px; }
    table.table-cards td.td-full { text-align: center; }
    /* 卡片内不再需要不换行限制 */
    table.table-cards td[style*="nowrap"] { white-space: normal !important; }
}
