/* ============================================
   设计令牌（Design Tokens）
   ============================================ */
:root {
    /* 背景色 */
    --c-bg:         #ffffff;
    --c-bg-alt:     #f7f8fa;
    --c-bg-hover:   #f0f1f3;

    /* 边框 */
    --c-border:     #e5e6eb;

    /* 文字 */
    --c-text:       #1d2129;
    --c-text-sub:   #86909c;
    --c-text-light: #c9cdd4;

    /* 主题色 */
    --c-primary:    #1d2129;
    --c-primary-h:  #000000;

    /* 功能色 */
    --c-success:    #00b42a;
    --c-danger:     #f53f3f;
    --c-danger-h:   #cb2634;
    --c-warning:    #ff7d00;

    /* 其他 */
    --c-shadow:     rgba(0,0,0,.06);
    --c-overlay:    rgba(0,0,0,.3);
    --radius:       8px;
    --radius-sm:    4px;

    /* 字体栈 */
    --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
}

/* ============================================
   全局 Reset
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-bg-alt);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-h); }

/* ============================================
   布局
   ============================================ */
.header-inner,
#main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================
   Header
   ============================================ */
#header {
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
}
.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 24px;
}
.header-inner .logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--c-text);
    flex-shrink: 0;
}
#nav-main {
    display: flex;
    gap: 4px;
    flex: 1;
}
#nav-main a {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    color: var(--c-text-sub);
    transition: .15s;
}
#nav-main a:hover,
#nav-main a.active {
    color: var(--c-text);
    background: var(--c-bg-alt);
}
#user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--c-text-sub);
    flex-shrink: 0;
}

/* 汉堡菜单按钮 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--c-text);
    border-radius: var(--radius-sm);
    transition: .15s;
}
.menu-toggle:hover { background: var(--c-bg-alt); }

/* ============================================
   Drawer 侧滑菜单
   ============================================ */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 150;
    opacity: 0; pointer-events: none;
    transition: opacity .25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 270px; max-width: 80vw;
    background: var(--c-bg);
    z-index: 151;
    transform: translateX(100%);
    transition: transform .25s ease;
    display: flex; flex-direction: column;
    padding: 24px 20px;
    box-shadow: -4px 0 20px rgba(0,0,0,.1);
}
.drawer.open { transform: translateX(0); }

.drawer a {
    display: block;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: .15s;
}
.drawer a:hover,
.drawer a.active {
    background: var(--c-bg-alt);
}

.drawer .drawer-divider {
    height: 1px;
    background: var(--c-border);
    margin: 12px 0;
}
.drawer .btn-logout {
    margin-top: auto;
}

/* ============================================
   按钮
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    font-size: 14px;
    font-family: var(--font);
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: .15s;
    outline: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary:disabled { background: var(--c-border); color: var(--c-text-sub); }
.btn-primary:disabled:hover { background: var(--c-border); }

/* 变体 */
.btn-primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--c-primary-h); }

.btn-outline {
    background: var(--c-bg);
    color: var(--c-text);
    border-color: var(--c-border);
}
.btn-outline:hover { background: var(--c-bg-alt); }

.btn-danger {
    background: var(--c-danger);
    color: #fff;
}
.btn-danger:hover { background: var(--c-danger-h); }

.btn-link {
    background: none;
    border: none;
    color: var(--c-primary);
    padding: 4px 8px;
}
.btn-link:hover { color: var(--c-primary-h); }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============================================
   卡片
   ============================================ */
.card {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 1px 4px var(--c-shadow);
}
.card + .card { margin-top: 16px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.card-header h2 { font-size: 18px; font-weight: 600; }

/* ============================================
   表单
   ============================================ */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--c-text);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--c-text);
    background: var(--c-bg);
    transition: border-color .15s;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(0,0,0,.15);
}
.form-group .hint  { font-size: 12px; color: var(--c-text-sub); margin-top: 4px; }
.form-group .error { font-size: 12px; color: var(--c-danger); margin-top: 4px; }

/* 移动端防止 iOS 缩放 */
@media (max-width: 768px) {
    .form-group input,
    .form-group textarea,
    .form-group select { font-size: 16px; }
}

/* ============================================
   登录/注册居中布局
   ============================================ */
.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 24px;
}
.auth-card {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 2px 12px var(--c-shadow);
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { font-size: 13px; color: var(--c-text-sub); margin-bottom: 28px; }

/* ============================================
   表格
   ============================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 11px 14px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--c-border);
}
table th {
    font-weight: 600;
    color: var(--c-text-sub);
    background: var(--c-bg-alt);
    white-space: nowrap;
}
table tbody tr:hover { background: var(--c-bg-hover); }
table .actions { display: flex; gap: 8px; align-items: center; }

/* 移动端表格 → 卡片模式 */
@media (max-width: 768px) {
    table thead { display: none; }
    table, table tbody, table tr, table td { display: block; }
    table tr {
        background: var(--c-bg);
        border: 1px solid var(--c-border);
        border-radius: var(--radius-sm);
        padding: 12px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px var(--c-shadow);
    }
    table td {
        padding: 6px 0;
        border-bottom: none;
        display: flex;
        gap: 8px;
    }
    table td::before {
        content: attr(data-label);
        flex-shrink: 0;
        width: 72px;
        font-weight: 600;
        color: var(--c-text-sub);
        font-size: 12px;
    }
}

/* ============================================
   模态框
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--c-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}
.modal {
    background: var(--c-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    padding: 28px;
}
.modal h3 { font-size: 18px; margin-bottom: 20px; }
.modal .modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* 移动端底部弹出 */
@media (max-width: 768px) {
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal {
        max-width: 100%;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 24px 20px;
        max-height: 85vh;
    }
    .modal .modal-actions { flex-direction: column-reverse; gap: 8px; }
    .modal .modal-actions .btn { width: 100%; }
}

/* ============================================
   Toast 提示
   ============================================ */
.toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, top .25s;
    box-shadow: 0 4px 16px var(--c-shadow);
}
.toast.show { opacity: 1; top: 80px; }
.toast.success { background: #e8ffea; color: var(--c-success); border: 1px solid #b7eb8f; }
.toast.error   { background: #fff1f0; color: var(--c-danger);  border: 1px solid #ffa39e; }
.toast.info    { background: #f0f1f3; color: var(--c-primary); border: 1px solid #c9cdd4; }

/* 移动端全宽 */
@media (max-width: 768px) {
    .toast { left: 12px; right: 12px; transform: none; top: 56px; text-align: center; }
    .toast.show { top: 60px; }
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle-switch {
    position: relative; display: inline-block;
    width: 44px; height: 24px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #c9cdd4; border-radius: 24px;
    transition: .2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%;
    transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--c-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============================================
   小组件
   ============================================ */

/* 标签/Badge */
.role-badge {
    font-size: 12px; padding: 2px 8px;
    border-radius: 10px;
    background: #f0f1f3; color: var(--c-primary);
}
.role-badge.admin { background: #ffece8; color: var(--c-danger); }

/* URI 标签列表 */
.tag-uris { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-uri {
    font-size: 11px; font-family: var(--font-mono);
    background: var(--c-bg-alt); color: var(--c-text-sub);
    padding: 2px 8px; border-radius: 3px;
    border: 1px solid var(--c-border);
    word-break: break-all; max-width: 260px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Secret 展示区 */
.secret-display {
    background: var(--c-bg-alt);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 12px 16px; margin: 12px 0;
    display: flex; align-items: center; gap: 12px;
    font-family: var(--font-mono);
    font-size: 13px; word-break: break-all;
}

/* 空状态 */
.empty { text-align: center; padding: 48px 24px; color: var(--c-text-sub); }
.empty .icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty p { font-size: 14px; }

/* 分页 */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-top: 24px;
}
.pagination span { font-size: 13px; color: var(--c-text-sub); }

/* ============================================
   响应式
   ============================================ */

/* 平板/手机 */
@media (max-width: 768px) {
    .header-inner, #main {
        padding: 0 16px;
    }
    #nav-main { display: none; }
    #user-area { display: none; }
    .menu-toggle { display: inline-flex; }

    .card { padding: 16px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .card-header h2 { font-size: 16px; }
}

/* 超小屏 */
@media (max-width: 400px) {
    .header-inner .logo { font-size: 14px; }
}

/* ============================================
   打印 / 无障碍
   ============================================ */
@media print {
    #header, .drawer-overlay, .drawer, #toast, #modal-container { display: none; }
    #main { max-width: none; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================
   工作管理专属样式
   ============================================ */

/* 工作项列表 - 卡片网格 */
.work-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.item-card {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 4px var(--c-shadow);
    cursor: pointer;
    transition: .15s;
    position: relative;
}
.item-card:hover {
    box-shadow: 0 2px 12px var(--c-shadow);
    border-color: var(--c-primary);
}
.item-card.completed {
    opacity: 0.65;
}
.item-card.completed .item-title {
    text-decoration: line-through;
    color: var(--c-text-sub);
}
.item-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    padding-right: 60px; /* 给状态标签留空间 */
}
.item-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--c-text-sub);
    flex-wrap: wrap;
}
.item-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.item-progress {
    margin-top: 10px;
    font-size: 12px;
    color: var(--c-text-sub);
}
.completed-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e8ffea;
    color: var(--c-success);
}

/* 工具栏 */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.toolbar .search-input {
    flex: 1;
    min-width: 160px;
    max-width: 300px;
}
.toolbar select {
    padding: 8px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--c-bg);
    color: var(--c-text);
    outline: none;
}
.toolbar select:focus {
    border-color: var(--c-primary);
}

/* 详情页 */
.item-detail-header {
    margin-bottom: 20px;
}
.item-detail-header h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}
.item-detail-header.completed h2 {
    text-decoration: line-through;
    color: var(--c-text-sub);
}
.detail-meta {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--c-text-sub);
    flex-wrap: wrap;
    margin-top: 8px;
}

/* 子任务列表 */
.subtask-list {
    list-style: none;
}
.subtask-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--c-border);
}
.subtask-item:last-child {
    border-bottom: none;
}
.subtask-item .check-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .15s;
    color: transparent;
    font-size: 12px;
}
.subtask-item .check-box.checked {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
}
.subtask-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.7;
}
.subtask-content.completed {
    text-decoration: line-through;
    color: var(--c-text-sub);
}
.subtask-time {
    font-size: 12px;
    color: var(--c-text-sub);
    margin-top: 2px;
}
.subtask-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.subtask-actions .btn {
    padding: 2px 6px;
    font-size: 12px;
}

/* 工作记录 */
.records-toggle {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: var(--c-text-sub);
    cursor: pointer;
    border-top: 1px solid var(--c-border);
    transition: .15s;
    user-select: none;
}
.records-toggle:hover {
    color: var(--c-primary);
}
.record-list {
    border-top: 1px solid var(--c-border);
}
.record-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--c-border);
    font-size: 13px;
}
.record-item:last-child {
    border-bottom: none;
}
.record-time {
    color: var(--c-text-sub);
    font-size: 12px;
    margin-bottom: 2px;
}

/* 内联表单 */
.inline-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.inline-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
}
.inline-form input:focus {
    border-color: var(--c-primary);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .work-items-grid {
        grid-template-columns: 1fr;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar .search-input {
        max-width: none;
    }
    .detail-meta {
        flex-direction: column;
        gap: 6px;
    }
    .detail-meta label {
        width: 100%;
    }
    .detail-meta input[type="datetime-local"] {
        flex: 1;
    }
}
