/* ============================================
   NoteView - Timeline View
   ============================================ */

.timeline-view {
    position: relative;
    padding: 1rem 2rem;
}

.tl-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    gap: 1rem;
}

.tl-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: tl-spin 0.8s linear infinite;
}

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

.tl-container {
    position: relative;
    padding-left: 2.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.tl-line {
    position: absolute;
    left: 11px;
    top: 2rem;
    bottom: 2rem;
    width: 2px;
    background: linear-gradient(180deg, var(--accent), #8b5cf6, var(--accent));
    border-radius: 1px;
    opacity: 0.5;
}

/* Date group */
.tl-date-group {
    margin-bottom: 0.5rem;
}

.tl-date-header {
    position: relative;
    margin-bottom: 0.75rem;
    margin-left: -2.5rem;
    padding-left: 2rem;
}

.tl-date-header span {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.tl-event {
    position: relative;
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    animation: tl-fadeIn 0.3s ease-out both;
}

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

.tl-dot-wrapper {
    position: absolute;
    left: -2.85rem;
    top: 12px;
    width: 20px;
    display: flex;
    justify-content: center;
}

.tl-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
    transition: all 0.2s;
    flex-shrink: 0;
}

/* State-based dot colors */
.tl-dot.tl-state-todo { border-color: var(--text-muted); box-shadow: 0 0 0 3px rgba(148,163,184,0.15); }
.tl-dot.tl-state-x { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.15); background: #10b981; }
.tl-dot.tl-state-\/ { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); background: var(--accent); }
.tl-dot.tl-state-b { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,0.15); background: #f59e0b; }
.tl-dot.tl-state-\- { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.15); background: #ef4444; }
.tl-dot.tl-state-removed { border-color: #94a3b8; box-shadow: 0 0 0 3px rgba(148,163,184,0.15); background: #94a3b8; }

.tl-card {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    transition: all 0.15s;
}

.tl-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.tl-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tl-task-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.tl-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* State transition */
.tl-transition {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.tl-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
}

.tl-state-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.3;
}

.tl-state-badge.tl-state-todo { background: rgba(148, 163, 184, 0.15); color: #64748b; }
.tl-state-badge.tl-state-x { background: rgba(16, 185, 129, 0.12); color: #059669; }
.tl-state-badge.tl-state-\/ { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.tl-state-badge.tl-state-b { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.tl-state-badge.tl-state-\- { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.tl-state-badge.tl-state-removed { background: rgba(148, 163, 184, 0.12); color: #94a3b8; text-decoration: line-through; }

/* Card footer */
.tl-card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.tl-note-name {
    font-size: 0.7rem;
    color: var(--accent);
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.tl-note-name:hover {
    opacity: 1;
    text-decoration: underline;
}

.tl-refresh-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 50;
    transition: all 0.15s;
}

.tl-refresh-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* ============================================
   Timeline Diff Modal
   ============================================ */

.tl-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tl-modal {
    width: 90%;
    max-width: 900px;
    height: 80vh;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.tl-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.tl-modal-title {
    display: flex;
    flex-direction: column;
}

.tl-modal-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.tl-modal-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.tl-modal-toggle {
    display: flex;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-md);
    gap: 2px;
}

.tl-toggle-btn {
    border: none;
    background: transparent;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.tl-toggle-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.tl-modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}

.tl-modal-close:hover {
    color: var(--text-primary);
}

.tl-modal .tag-modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-secondary);
    padding: 0;
    min-height: 0;
}

.tl-diff-container {
    height: 100%;
}

.tl-diff-container .cm-mergeView {
    height: 100%;
}

.tl-diff-container .cm-mergeView .cm-editor {
    height: 100% !important;
    overflow: hidden !important;
}

.tl-diff-container .cm-mergeView .cm-scroller {
    overflow-y: auto !important;
}

.tl-loading-small {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tl-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: tl-spin 0.8s linear infinite;
}

.tl-error {
    padding: 2rem;
    text-align: center;
    color: #ef4444;
}

@media (max-width: 768px) {
    .tl-refresh-btn {
        bottom: 5rem;
    }
}
