/**
 * Waywave 渡澜 - 成长地图页样式 (Flow)
 */

/* Time Axis (Top) */
#time-axis-container {
    position: fixed; /* 改为 fixed 以配合 navbar */
    top: 60px; /* Below navbar */
    left: 0;
    right: 0;
    height: 40px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    overflow: hidden;
    z-index: var(--z-sticky);
}

#time-axis-track {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    /* transform will be set by JS */
}

.time-marker {
    position: absolute;
    bottom: 0;
    padding: 4px;
    font-size: 12px;
    color: var(--color-text-secondary);
    border-left: 1px solid var(--color-border);
    height: 20px;
    white-space: nowrap;
}

/* Main Viewport */
#timeline-viewport {
    position: fixed; /* 改为 fixed */
    top: 100px; /* Header + Axis */
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden; /* Canvas moves inside */
    background-image: radial-gradient(var(--color-border) 1px, transparent 1px);
    background-size: 20px 20px; /* Grid */
    cursor: default; /* Default to selection */
    background-color: var(--color-bg);
}

#timeline-viewport.no-grid {
    background-image: none;
}

#timeline-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    /* transform set by JS */
}

/* SVG Layer */
#connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: all; /* Enable clicking on connections */
    z-index: 5;
}

#connections-layer g {
    pointer-events: stroke;
}

/* Entities */
.timeline-card {
    position: absolute;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0; /* Content padding inside */
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    user-select: none;
    min-height: 60px;
    box-sizing: border-box;
    color: var(--color-text-primary);
}

/* 时间阶段样式（辅助视觉，不再是主要区分） */
.timeline-card.past { opacity: 0.85; }
.timeline-card.future { border-style: dashed; border-color: var(--color-border); }

/* 节点类型样式 - 通过左侧边框颜色区分 */
.timeline-card.node-type-experience { border-left: 4px solid #52c41a; }  /* 成长经历 - 绿色 */
.timeline-card.node-type-interest { border-left: 4px solid #1890ff; }    /* 兴趣方向 - 蓝色 */
.timeline-card.node-type-goal { border-left: 4px solid #fa8c16; }        /* 愿望目标 - 橙色 */

/* 固定宽度卡片样式（用于 goal 和 interest） */
.timeline-card.fixed-width-card {
    border-radius: var(--radius-md);
    text-align: center;
}

.timeline-card.fixed-width-card .card-content {
    padding: 10px 8px;
}

.timeline-card.fixed-width-card .card-title {
    padding-right: 0;
    font-size: 13px;
    line-height: 1.3;
}

.timeline-card.fixed-width-card .card-date {
    margin-top: 4px;
}

.timeline-card.fixed-width-card .node-type-tag {
    position: static;
    display: inline-flex;
    margin-bottom: 4px;
}

/* goal 和 interest 特殊样式 */
.timeline-card.node-type-goal {
    background: linear-gradient(135deg, #fff7e6 0%, #fff 100%);
}

.timeline-card.node-type-interest {
    background: linear-gradient(135deg, #e6f7ff 0%, #fff 100%);
}

/* Selected State */
.timeline-card.selected, .sticky-note.selected, .timeline-sticker.selected {
    outline: 2px solid #1890ff;
    box-shadow: 0 0 10px rgba(24, 144, 255, 0.3);
}

.card-content {
    padding: 8px 12px;
    overflow: hidden;
    height: 100%;
    position: relative;
}

/* 节点类型标签 */
.node-type-tag {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.card-title {
    font-weight: 500;
    margin-bottom: 4px;
    padding-right: 22px; /* 为类型标签留出空间 */
}

.card-date {
    font-size: 11px;
    color: var(--color-text-muted);
}

.ai-badge {
    float: right;
    background: #e6f7ff;
    color: #1890ff;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 4px;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 20;
}
.resize-handle.left { left: 0; }
.resize-handle.right { right: 0; }

/* Connection Anchors - HIDDEN BY DEFAULT */
.conn-anchor {
    position: absolute;
    top: 50%;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid #666;
    border-radius: 50%;
    transform: translateY(-50%);
    opacity: 0;
    cursor: crosshair;
    z-index: 21;
    display: none; /* Key change: hidden by default */
}

/* Only show anchors when in connect mode */
#timeline-viewport.tool-connect .conn-anchor {
    display: block;
}
#timeline-viewport.tool-connect .timeline-card:hover .conn-anchor {
    opacity: 1;
}

.conn-anchor.left { left: -6px; }
.conn-anchor.right { right: -6px; }

/* Sticky Note */
.sticky-note {
    position: absolute;
    width: 120px;
    min-height: 100px;
    background: #fffb8f;
    padding: 10px;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.1);
    font-family: "Comic Sans MS", cursive, sans-serif;
    font-size: 13px;
    transform: rotate(-1deg);
    z-index: 15;
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.2s;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #333; /* 便签通常是黄色背景黑色文字，不受主题影响太深 */
}

.sticky-note:hover {
    box-shadow: 4px 4px 15px rgba(0,0,0,0.15);
    transform: rotate(-1deg) scale(1.02);
}

.sticky-note.selected {
    outline: 3px solid #1890ff;
    box-shadow: 0 0 15px rgba(24, 144, 255, 0.4);
    z-index: 20;
}

/* Zone */
.timeline-zone {
    position: absolute;
    border: 2px dashed var(--color-border);
    background: rgba(0,0,0,0.02);
    pointer-events: auto; /* Enable interaction */
    z-index: 1;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.timeline-zone .zone-label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 4px 10px;
    background: var(--color-bg-hover);
    font-size: 12px;
    color: var(--color-text-primary);
    pointer-events: auto;
    cursor: grab;
    border-radius: 0 0 4px 0;
    font-weight: 500;
    user-select: none;
}

/* Zone Selected State */
.timeline-zone.selected {
    border-style: solid;
    border-color: #1890ff !important;
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.2);
    z-index: 5;
}
.timeline-zone.selected .zone-label {
    background: #1890ff !important;
    color: white;
}

/* Zone Resize Handles */
.zone-resize-handle {
    position: absolute;
    background: #1890ff;
    border: 2px solid white;
    border-radius: 2px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.2s;
}

/* Show handles only when zone is selected */
.timeline-zone.selected .zone-resize-handle {
    opacity: 1;
    pointer-events: auto;
}

/* Edge handles */
.zone-resize-n, .zone-resize-s {
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 8px;
    cursor: ns-resize;
}
.zone-resize-n { top: -4px; }
.zone-resize-s { bottom: -4px; }

.zone-resize-e, .zone-resize-w {
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 30px;
    cursor: ew-resize;
}
.zone-resize-e { right: -4px; }
.zone-resize-w { left: -4px; }

/* Corner handles */
.zone-resize-nw, .zone-resize-ne, .zone-resize-sw, .zone-resize-se {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}
.zone-resize-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.zone-resize-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.zone-resize-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.zone-resize-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Hover effect for non-selected zones */
.timeline-zone:hover:not(.selected) {
    border-color: #91d5ff;
}

/* Sticker */
.timeline-sticker {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 20;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* Now Marker */
.now-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-error);
    z-index: 50;
    pointer-events: none;
}
.now-marker span {
    position: absolute;
    top: 10px;
    left: 4px;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
}

/* HUD Panels (Toolbar, Controls, AI Dock) */
.hud-panel {
    position: fixed;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    z-index: 500;
}

/* Toolbar */
#whiteboard-toolbar {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
}
.tool-btn {
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-primary);
}
.tool-btn:hover {
    background: var(--color-bg-hover);
}
.tool-btn.active {
    background: #e6f7ff;
    color: #1890ff;
    border-color: #1890ff;
}
.separator { height: 1px; background: var(--color-border); margin: 4px 0; }

/* AI Dock */
#ai-dock {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 90%;
    height: 120px;
    display: flex;
    flex-direction: column;
}
.dock-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 12px;
    font-weight: 600;
    background: var(--color-bg-hover);
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    color: var(--color-text-primary);
}
.dock-content {
    flex: 1;
    padding: 10px;
    overflow-x: auto;
    display: flex;
    gap: 10px;
    align-items: center;
}
.suggestion-chip {
    flex: 0 0 auto;
    background: var(--color-bg-elevated);
    border: 1px solid #ffd591;
    background: #fff7e6;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
}
.suggestion-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Context Menu */
#ctx-menu {
    display: none;
    position: fixed;
    z-index: 3000;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    border-radius: 6px;
    min-width: 150px;
    color: var(--color-text-primary);
}

/* Label Manager Styles */
.label-chip {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid transparent;
}
.label-chip:hover {
    border-color: var(--color-text-muted);
}

/* Bottom Controls */
.btn-icon {
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1.2rem;
    color: var(--color-text-primary);
}
.btn-icon:hover, .btn-icon.active {
    background: var(--color-bg-hover);
    color: #1890ff;
}

/* Short Card UX */
.timeline-card.short-card {
    overflow: visible;
    z-index: 100;
}
.timeline-card.short-card .card-content {
    overflow: visible;
    white-space: nowrap;
    width: max-content;
}
.timeline-card.short-card .card-date {
    display: none; /* Hide date for very short cards to reduce clutter */
}

/* 保存状态指示器 (Keep for backward compatibility, but navbar handles it now?) */
/* Actually the new header design might not include this specific element in the same way.
   Let's keep it just in case we re-add it to the navbar right section. */
.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    transition: all 0.3s ease;
}
.save-status:empty {
    display: none;
}
.save-status .save-icon {
    font-size: 14px;
}
.save-status.saving {
    background: #fff8e1;
    color: #f57c00;
}
.save-status.saved {
    background: #e8f5e9;
    color: #388e3c;
}
.save-status.local {
    background: #e3f2fd;
    color: #1976d2;
}
.save-status.error {
    background: #ffebee;
    color: #d32f2f;
}
.save-status.saving .save-icon {
    animation: spin 1s linear infinite;
}



