/* =====================================================================================
   布局样式：登录页、应用外壳（顶栏 / 主体 / 过滤区 / 统计区 / 内容区）
   ===================================================================================== */

/* ---------- 登录 / 注册页 ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 45%, #0891b2 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-info));
    border-radius: var(--radius-md);
}

.auth-title {
    font-size: 20px;
}

.auth-subtitle {
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.auth-footer {
    margin-top: 16px;
    font-size: 13px;
    text-align: center;
    color: var(--color-text-secondary);
}

.auth-advanced {
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--color-surface-alt);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
}

/* ---------- 应用外壳 ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    display: flex;
    align-items: center;
    gap: 16px;
    height: 56px;
    padding: 0 20px;
    color: #fff;
    background: #0f172a;
    box-shadow: var(--shadow-sm);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.app-header__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 15px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-info));
    border-radius: var(--radius-sm);
}

.app-header__nav {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.app-header__nav button {
    padding: 6px 12px;
    font-family: inherit;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.app-header__nav button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.app-header__nav button.is-active {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.app-header__spacer {
    flex: 1;
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px 20px 40px;
}

/* ---------- 网络与同步状态条 ---------- */
.sync-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 12px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.12);
}

.sync-bar__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25);
}

.sync-bar.is-offline .sync-bar__dot {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.sync-bar.is-error .sync-bar__dot {
    background: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

.sync-bar__action {
    padding: 2px 8px;
    font-family: inherit;
    font-size: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
}

.sync-bar__action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- 过滤面板 ---------- */
.filter-panel {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.filter-panel__header {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 折叠后取消底部留白，保持紧凑 */
.filter-panel.is-collapsed .filter-panel__header {
    margin-bottom: 0;
}

.filter-panel__body {
    margin-top: 12px;
}

.filter-panel__title {
    font-size: 14px;
}

/* 当前生效条件摘要：折叠与展开状态下都展示，避免用户不清楚过滤了什么 */
.filter-panel__summary {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    color: var(--color-text-muted);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-item__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    /* 标签保持单行，避免"关键字"这类两字标签被压成两行 */
    white-space: nowrap;
}

.filter-item--wide {
    grid-column: 1 / -1;
}

.filter-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--color-border);
}

.filter-active-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* 多选按钮组（状态 / 优先级等小选项集合） */
.check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.check-chip {
    padding: 4px 10px;
    font-size: 13px;
    color: var(--color-text-secondary);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}

.check-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.check-chip.is-checked {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* ---------- 过滤项标题栏（维度名 + 单选/多选开关 + 清除） ---------- */
.filter-item__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* 单选 / 多选切换开关：按钮上直接显示当前模式，点击即可切换 */
.filter-mode-toggle {
    padding: 1px 8px;
    font-size: 12px;
    color: var(--color-text-secondary);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-mode-toggle:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* 单选模式以主色高亮，一眼可辨当前处于哪种模式 */
.filter-mode-toggle.is-single {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* 标题栏内的「清除」：清空该维度已选项，无可清除项时禁用 */
.filter-head-clear {
    padding: 1px 8px;
    font-size: 12px;
    color: var(--color-text-muted);
    background: transparent;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-head-clear:hover:not(:disabled) {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.filter-head-clear:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------- 统计卡片 ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-card.is-active {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.stat-card__value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card__label {
    margin-top: 2px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.stat-card--total { border-left-color: var(--color-primary); }
.stat-card--total .stat-card__value { color: var(--color-primary); }
.stat-card--notstarted { border-left-color: var(--color-text-muted); }
.stat-card--inprogress { border-left-color: var(--color-info); }
.stat-card--inprogress .stat-card__value { color: var(--color-info); }
.stat-card--completed { border-left-color: var(--color-success); }
.stat-card--completed .stat-card__value { color: var(--color-success); }
.stat-card--cancelled { border-left-color: var(--color-border-strong); }
.stat-card--overdue { border-left-color: var(--color-danger); }
.stat-card--overdue .stat-card__value { color: var(--color-danger); }

/* ---------- 内容区 ---------- */
.content-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.content-card__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.content-card__title {
    font-size: 14px;
}

.content-card__count {
    font-size: 12px;
    color: var(--color-text-muted);
}

.content-card__body {
    padding: 0;
}

.content-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ---------- 页面区块（设置页、用户管理页） ---------- */
.page-section {
    max-width: 900px;
    margin: 0 auto;
}

.section-card {
    margin-bottom: 16px;
    padding: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.section-card__title {
    margin-bottom: 4px;
    font-size: 15px;
}

.section-card__desc {
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ---------- 响应式适配：平板 / 手机 ---------- */

/* 平板（≤900px） */
@media (max-width: 900px) {
    .app-main {
        padding: 12px;
    }

    .form-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-header {
        padding: 0 12px;
        gap: 10px;
    }

    .app-header__nav {
        margin-left: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .app-header__nav::-webkit-scrollbar {
        display: none;
    }

    /* 平板下收窄过滤面板，保持两列但更紧凑 */
    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-section {
        max-width: 100%;
    }

    /* 甘特图左侧名称列在平板下适当收窄 */
    .gantt {
        --gantt-label-width: 180px;
    }
}

/* 手机（≤640px） */
@media (max-width: 640px) {
    /* 顶栏换行：品牌 + 状态条一行，导航单独一行 */
    .app-header {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        row-gap: 8px;
    }

    .app-header__brand span:last-child {
        display: none;
    }

    .app-header__nav {
        width: 100%;
        order: 3;
        gap: 2px;
    }

    .app-header__nav button {
        flex: 1;
        padding: 6px 4px;
        text-align: center;
    }

    /* 用户区隐藏显示名，仅保留角色与退出 */
    .app-header__user > span:first-child {
        display: none;
    }

    .sync-bar {
        flex: 1;
        justify-content: flex-end;
    }

    /* 统计卡片两列 */
    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    /* 过滤面板单列 */
    .filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* 工具栏按钮换行，去两端对齐避免挤压 */
    .content-card__toolbar {
        gap: 6px;
    }

    .content-card__toolbar .content-card__count {
        width: 100%;
    }

    /* 弹窗铺满，贴近手机操作习惯 */
    .modal-mask {
        padding: 12px;
        align-items: flex-start;
    }

    .modal {
        max-width: 100%;
        border-radius: var(--radius-md);
    }

    .drawer {
        max-width: 100%;
    }

    .detail-list {
        grid-template-columns: 80px 1fr;
        gap: 10px 12px;
    }

    .section-card {
        padding: 14px;
    }

    .auth-card {
        padding: 24px 20px;
    }

    /* 甘特图：更窄名称列 + 更紧凑行高 */
    .gantt {
        --gantt-label-width: 150px;
        --gantt-row-height: 54px;
    }

    .gantt-nav {
        flex-wrap: wrap;
    }

    .gantt-nav .text-muted {
        width: 100%;
        margin-left: 0;
    }
}
