/* ============================================================
   WorkLog 网页端样式
   设计语言沿用桌面端：浅灰底 + 白卡片 + 靛蓝主色
   ============================================================ */

:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d5d9e0;

    --text: #111827;
    --text-soft: #6b7280;
    --text-faint: #9ca3af;

    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --primary-border: #c7d2fe;

    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #dc2626;
    --danger-soft: #fef2f2;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
    --shadow-lg: 0 10px 30px rgba(17, 24, 39, .10);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* Blazor 默认焦点框太抢眼，只给键盘导航留 outline */
:focus:not(:focus-visible) {
    outline: none;
}

/* FocusOnNavigate 会把焦点放到 h1 上，去掉黑框，键盘用户仍能看到 */
h1:focus {
    outline: none;
}

h1:focus-visible {
    outline: 2px solid var(--primary-border);
    outline-offset: 4px;
    border-radius: 4px;
}

::selection {
    background: var(--primary-border);
}

/* ------------------------------------------------------------ 框架 */

.app-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 58px;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -.2px;
    color: var(--text);
    text-decoration: none;
    flex: 0 0 auto;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(79, 70, 229, .3);
}

.nav {
    display: flex;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.nav a {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 13px;
    border-radius: 8px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 13.5px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.nav a:hover {
    background: #f3f4f6;
    color: var(--text);
}

.nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 550;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 4px;
    height: 34px;
    border-radius: 999px;
    color: var(--text-soft);
    font-size: 13px;
    text-decoration: none;
    transition: background .15s;
}

.user-chip:hover {
    background: #f3f4f6;
}

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 auto;
}

.page {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px 40px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 19px;
    font-weight: 620;
    letter-spacing: -.3px;
    margin: 0;
}

.page-sub {
    font-size: 12.5px;
    color: var(--text-faint);
}

.spacer {
    flex: 1 1 auto;
}

/* ------------------------------------------------------------ 按钮 */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}

.btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: var(--border-strong);
}

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

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 550;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-soft);
}

.btn-ghost:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: transparent;
    color: var(--text);
}

.btn-danger-text {
    border-color: transparent;
    background: transparent;
    color: var(--danger);
    padding: 0 8px;
    height: 28px;
    font-size: 12.5px;
}

.btn-danger-text:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: transparent;
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 7px;
}

.btn-block {
    width: 100%;
    height: 42px;
    font-size: 14px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-soft);
}

/* ------------------------------------------------------------ 卡片 */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px 0;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.1px;
}

.card-hint {
    font-size: 11.5px;
    color: var(--text-faint);
}

.blk {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ------------------------------------------------------------ 表单 */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-soft);
}

.input,
.textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 9px 12px;
    transition: border-color .15s, box-shadow .15s;
}

.input {
    height: 40px;
}

.textarea {
    resize: none;
    line-height: 1.7;
    min-height: 96px;
    display: block;
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary-border);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .10);
}

.input::placeholder,
.textarea::placeholder {
    color: #c2c8d2;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input {
    padding-right: 42px;
}

.eye-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.eye-btn:hover {
    background: #f3f4f6;
    color: var(--text-soft);
}

.field-error {
    font-size: 12.5px;
    color: var(--danger);
}

/* ------------------------------------------------------------ 提示条 */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    line-height: 1.5;
}

.alert-error {
    background: var(--danger-soft);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-ok {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.alert-info {
    background: #f8fafc;
    color: var(--text-soft);
    border: 1px solid var(--border);
}

/* ------------------------------------------------------------ 状态点 */

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d1d5db;
    flex: 0 0 auto;
}

.dot.dirty {
    background: var(--warn);
}

.dot.saved {
    background: var(--ok);
}

.dot.saving {
    background: var(--primary);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .3;
    }
}

/* ------------------------------------------------------------ 日期切换 */

.date-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.date-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.2px;
    min-width: 0;
}

.date-today {
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-soft);
    border: none;
    border-radius: 999px;
    padding: 2px 9px;
    margin-left: 6px;
    vertical-align: 1px;
}

/* ------------------------------------------------------------ 日报 */

.daily-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
}

.daily-grid .blk {
    flex: 1 1 0;
    min-height: 140px;
}

.daily-grid .blk:first-child {
    flex: 1.7 1 0;
}

.daily-grid .textarea {
    flex: 1 1 auto;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 10px 16px 14px;
    min-height: 80px;
}

.daily-grid .textarea:focus {
    box-shadow: none;
    background: #fcfcfd;
}

/* ------------------------------------------------------------ 周报 */

.weekly-grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 14px;
    flex: 1 1 auto;
    min-height: 0;
}

.week-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
}

.week-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 11px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: #fff;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    width: 100%;
}

.week-item:hover {
    border-color: var(--primary-border);
    background: #fcfcff;
}

.week-item.is-empty {
    background: #fafbfc;
    border-style: dashed;
}

.week-item.is-active {
    border-color: var(--primary-border);
    background: var(--primary-soft);
}

.week-item-head {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 3px;
}

.week-item-label {
    font-size: 12.5px;
    font-weight: 600;
}

.week-item-date {
    font-size: 11.5px;
    color: var(--text-faint);
}

.week-item-body {
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.week-item-empty {
    font-size: 12px;
    color: #c2c8d2;
    font-style: normal;
}

.weekly-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
}

/* 三块高度由内容决定，超出容器就整栏滚动，不压缩输入框 */
.weekly-right .blk {
    flex: 0 0 auto;
}

.weekly-right .textarea {
    min-height: 110px;
    overflow-y: hidden;
}

/* ------------------------------------------------------------ 登录 / 注册 */

.auth-wrap {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 18px;
    background:
        radial-gradient(900px 500px at 50% -10%, #eef2ff 0%, rgba(238, 242, 255, 0) 70%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 30px 28px 26px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-brand .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 15px;
}

.auth-brand-text {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.4px;
}

.auth-title {
    font-size: 17px;
    font-weight: 620;
    margin: 0 0 4px;
    letter-spacing: -.2px;
}

.auth-desc {
    font-size: 12.5px;
    color: var(--text-faint);
    margin: 0 0 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-foot {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.auth-foot a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-foot a:hover {
    text-decoration: underline;
}

.server-line {
    margin-top: 14px;
    font-size: 11px;
    color: #c2c8d2;
    text-align: center;
    word-break: break-all;
}

.check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-soft);
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.check input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ------------------------------------------------------------ 个人中心 */

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.kv {
    display: flex;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px dashed #eef0f3;
    font-size: 13px;
    gap: 12px;
}

.kv:last-child {
    border-bottom: none;
}

.kv-k {
    color: var(--text-faint);
    width: 76px;
    flex: 0 0 auto;
    font-size: 12.5px;
}

.kv-v {
    color: var(--text);
    word-break: break-all;
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-muted {
    background: #f3f4f6;
    color: var(--text-soft);
}

.badge-ok {
    background: #ecfdf5;
    color: #047857;
}

.badge-warn {
    background: #fffbeb;
    color: #b45309;
}

.badge-danger {
    background: var(--danger-soft);
    color: #b91c1c;
}

/* ------------------------------------------------------------ 邀请码 */

.invite-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.tbl th {
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-faint);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.tbl td {
    padding: 11px 12px;
    border-bottom: 1px solid #f1f2f4;
    vertical-align: middle;
}

table.tbl tr:last-child td {
    border-bottom: none;
}

table.tbl tbody tr:hover {
    background: #fcfcfd;
}

.code-cell {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13.5px;
    letter-spacing: .6px;
    font-weight: 600;
}

.row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    white-space: nowrap;
}

/* ------------------------------------------------------------ 空状态 */

.empty-card {
    padding: 60px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.empty-title {
    font-size: 15px;
    font-weight: 600;
}

.empty-desc {
    font-size: 13px;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.loading-line {
    padding: 40px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-faint);
}

/* ------------------------------------------------------------ 提示气泡 */

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(8px);
    background: #111827;
    color: #fff;
    font-size: 12.5px;
    padding: 9px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 60;
    max-width: calc(100vw - 40px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Blazor 出错提示条 */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 12px 18px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 13px;
    border-top: 1px solid #fecaca;
}

#blazor-error-ui .reload {
    color: #b91c1c;
    margin-left: 10px;
    font-weight: 600;
}

/* ------------------------------------------------------------ 平板与手机 */

@media (max-width: 900px) {
    .topbar {
        height: auto;
        padding: 8px 14px 0;
        flex-wrap: wrap;
        gap: 10px;
    }

    .brand {
        order: 1;
    }

    .topbar-right {
        order: 2;
        margin-left: auto;
    }

    .nav {
        order: 3;
        flex-basis: 100%;
        overflow-x: auto;
        gap: 2px;
        padding-bottom: 8px;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav a {
        padding: 0 11px;
        height: 32px;
        font-size: 13px;
    }

    .user-chip .user-name {
        display: none;
    }

    .page {
        padding: 14px 12px 28px;
    }

    .page-title {
        font-size: 17px;
    }

    .weekly-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .week-list {
        max-height: 260px;
    }

    .profile-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .invite-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invite-form .btn {
        grid-column: 1 / -1;
    }

    /* 手机上每块至少 150px，别把输入框压扁 */
    .daily-grid .blk,
    .daily-grid .blk:first-child,
    .weekly-right .blk {
        flex: 0 0 auto;
        min-height: 150px;
    }

    .daily-grid .textarea,
    .weekly-right .textarea {
        min-height: 110px;
    }

    .auth-card {
        padding: 24px 20px 20px;
        border-radius: 16px;
    }
}

@media (max-width: 560px) {
    .invite-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .date-title {
        font-size: 14px;
    }

    .page-sub {
        display: none;
    }
}

/* 打印周报时把按钮和左栏去掉，直接出一张干净的纸 */
@media print {
    .topbar,
    .nav,
    .btn,
    .week-list,
    .status {
        display: none !important;
    }

    .weekly-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
        border-color: #ddd;
        break-inside: avoid;
    }
}
