/* 人生进化系统 - 移动优先暗色主题 */

:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222;
    --bg-elevated: #252525;
    --text: #e8e8e8;
    --text-secondary: #999;
    --text-muted: #666;
    --border: #2a2a2a;
    --accent: #FF5722;
    --accent-dim: rgba(255, 87, 34, 0.15);
    --green: #4CAF50;
    --blue: #2196F3;
    --gold: #D4A017;
    --purple: #9C27B0;
    --red: #f44336;
    --radius: 12px;
    --radius-sm: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    padding-bottom: calc(70px + var(--safe-bottom));
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #E64A19);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.app-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.header-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-right .btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Views */
.view {
    display: none;
    padding: 16px;
}

.view.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Status Card */
.status-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.status-row {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-item span:last-child {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.status-icon.healthy {
    color: var(--green);
    font-size: 18px;
}

.status-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Dao Card */
.dao-card {
    background: linear-gradient(135deg, rgba(255,87,34,0.12), rgba(255,87,34,0.04));
    border: 1px solid rgba(255,87,34,0.2);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.dao-card:active {
    background: linear-gradient(135deg, rgba(255,87,34,0.2), rgba(255,87,34,0.08));
}

.dao-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    background: var(--accent-dim);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dao-info {
    flex: 1;
    min-width: 0;
}

.dao-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.dao-info p {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dao-arrow {
    color: var(--accent);
    font-size: 24px;
    font-weight: 300;
}

/* Grid */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* Dimension Cards */
.dim-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.dim-card:active {
    background: var(--bg-card-hover);
    transform: scale(0.98);
}

.dim-card .card-icon {
    font-size: 28px;
    margin-bottom: 8px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.dim-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.dim-card .card-mission {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

.dim-card .card-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-block;
}

.badge-today {
    background: rgba(76,175,80,0.15);
    color: var(--green);
}

.badge-latest {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

/* Section */
.section {
    margin-bottom: 8px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: "";
    width: 3px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

/* Report List */
.report-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.report-item:active {
    background: var(--bg-card-hover);
}

.report-item .report-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.report-item .report-info {
    flex: 1;
    min-width: 0;
}

.report-item .report-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-item .report-date {
    font-size: 12px;
    color: var(--text-muted);
}

.report-item .report-arrow {
    color: var(--text-muted);
    font-size: 18px;
}

/* Report list hint - 近7天提示 */
.report-hint {
    font-size: 12px;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* View Header */
.view-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.view-header h2 {
    font-size: 17px;
    font-weight: 600;
}

.btn-back {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

/* Markdown content */
.markdown-body {
    font-size: 14px;
    line-height: 1.8;
}

.markdown-body h1 { font-size: 20px; margin: 16px 0 8px; font-weight: 700; }
.markdown-body h2 { font-size: 17px; margin: 20px 0 10px; font-weight: 600; color: var(--accent); }
.markdown-body h3 { font-size: 15px; margin: 16px 0 8px; font-weight: 600; }
.markdown-body p { margin: 8px 0; color: var(--text); }
.markdown-body strong { color: #fff; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin: 8px 0; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    margin: 12px 0;
    background: var(--accent-dim);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-size: 13px;
}
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}
.markdown-body th, .markdown-body td {
    padding: 8px 10px;
    text-align: left;
    border: 1px solid var(--border);
}
.markdown-body th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--accent);
}
.markdown-body code {
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.markdown-body pre {
    background: var(--bg-elevated);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
}
.markdown-body pre code {
    background: none;
    padding: 0;
}
.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}
.markdown-body em {
    color: var(--text-muted);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 15, 15, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 var(--safe-bottom);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 11px;
    transition: color 0.2s;
    min-width: 56px;
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 20px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.loading::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
}

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ===== 桌面端响应式（Mac / PC 访问和谐布局）===== */
@media (min-width: 768px) {
    body {
        max-width: 960px;
        margin: 0 auto;
        padding-bottom: 28px;
    }
    .app-header {
        max-width: 960px;
        margin: 0 auto;
        border-radius: 0 0 var(--radius) var(--radius);
    }
    .bottom-nav {
        max-width: 960px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
        padding-bottom: 10px;
    }
    .grid-2col {
        grid-template-columns: repeat(4, 1fr);
    }
    .report-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .section-title { margin-top: 4px; }
    .chat-fab {
        right: 24px;
        bottom: 28px;
    }
    /* 聊天面板：右侧抽屉 */
    .chat-panel {
        left: auto;
        right: 24px;
        top: 24px;
        bottom: 24px;
        width: 400px;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    }
    /* 通知面板：居中模态 */
    .notification-panel {
        left: 50%;
        right: auto;
        top: 50%;
        bottom: auto;
        transform: translate(-50%, -50%);
        width: 480px;
        max-height: 82vh;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        box-shadow: 0 12px 40px rgba(0,0,0,0.5);
        padding: 20px;
    }
}

@media (min-width: 1200px) {
    body { max-width: 1180px; }
    .app-header { max-width: 1180px; }
    .bottom-nav { max-width: 1180px; }
    .grid-2col { grid-template-columns: repeat(4, 1fr); }
    .report-list { grid-template-columns: repeat(3, 1fr); }
    .chat-panel { width: 440px; }
}

/* ===== Notification Bell ===== */
.btn-notification {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.btn-notification .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Notification Panel */
.notification-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 300;
    display: none;
    flex-direction: column;
    padding: 16px;
    padding-bottom: calc(70px + var(--safe-bottom));
}

.notification-panel.active {
    display: flex;
}

.notification-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.notification-panel .panel-header h2 {
    font-size: 17px;
    font-weight: 600;
}

.notification-panel .panel-header .btn-close {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
}

.notification-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.notification-item:active {
    background: var(--bg-card-hover);
}

.notification-item.unread {
    border-left: 3px solid var(--accent);
}

.notification-item .notif-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.notification-item .notif-body {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.notification-item .notif-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.notification-item .notif-category {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 6px;
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.notification-item .notif-category.report { background: rgba(212,160,23,0.15); color: var(--gold); }
.notification-item .notif-category.chat { background: rgba(33,150,243,0.15); color: var(--blue); }
.notification-item .notif-category.alert { background: rgba(244,67,54,0.15); color: var(--red); }
.notification-item .notif-category.system { background: rgba(255,87,34,0.15); color: var(--accent); }

/* ===== Chat FAB ===== */
.chat-fab {
    position: fixed;
    bottom: calc(70px + var(--safe-bottom) + 12px);
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #E64A19);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(255,87,34,0.3);
    z-index: 150;
    transition: transform 0.2s;
}

.chat-fab:active {
    transform: scale(0.92);
}

/* Chat Panel */
.chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 300;
    display: none;
    flex-direction: column;
}

.chat-panel.active {
    display: flex;
}

.chat-panel .chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.chat-panel .chat-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-panel .chat-header .chat-status {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-panel .chat-header .chat-status.connected::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

.chat-panel .chat-header .chat-status.disconnected::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--red);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--accent-dim);
    border: 1px solid rgba(255,87,34,0.2);
    color: var(--text);
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
}

.chat-message.system {
    align-self: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    max-width: 90%;
    text-align: center;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.chat-input-area input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.chat-input-area input::placeholder {
    color: var(--text-muted);
}

.chat-input-area button {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== WS Status Indicator ===== */
.ws-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.ws-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.ws-status.connected .dot { background: var(--green); }
.ws-status.connecting .dot { background: var(--gold); animation: pulse 1s infinite; }
.ws-status.disconnected .dot { background: var(--red); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Server Info Banner ===== */
.server-banner {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.server-banner .server-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}
