/* =========================================================================
   LIFEBOOK - SIDEBARS (LEFT DASHBOARD & RIGHT JOURNEY TREE)
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. LEFT SIDEBAR (MẶC ĐỊNH OPEN, THU GỌN VỀ MINI-RAIL 60PX)
   ------------------------------------------------------------------------- */
.lifebook-sidebar {
    width: 310px;
    min-width: 310px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    height: calc(100vh - 56px);
    position: sticky;
    top: 56px;
    display: flex;
    flex-direction: column;
    transition: width 0.22s cubic-bezier(0.2, 0, 0, 1), min-width 0.22s cubic-bezier(0.2, 0, 0, 1);
    z-index: 90;
    box-shadow: 1px 0 4px rgba(0,0,0,0.03);
    flex-shrink: 0;
    overflow: hidden;
}

/* Thu nhỏ lại còn 60px */
.lifebook-sidebar.collapsed {
    width: 60px;
    min-width: 60px;
}

.sidebar-header {
    display: none !important;
}

/* MINI RAIL: Hiện khi sidebar bị thu nhỏ (<) */
.sidebar-mini-rail {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 6px;
    overflow-y: auto;
    flex: 1;
}

.lifebook-sidebar.collapsed .sidebar-mini-rail {
    display: flex;
}

.lifebook-sidebar.collapsed .sidebar-header,
.lifebook-sidebar.collapsed .sidebar-full-content,
.lifebook-sidebar.collapsed .sidebar-title-wrap {
    display: none !important;
}

.mini-rail-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #f0f2f5;
    color: #050505;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mini-rail-btn:hover {
    background: #e7f3ff;
    color: var(--primary);
    border-color: #bad9fc;
    transform: scale(1.08);
}

.mini-rail-btn.btn-expand-rail {
    background: #e7f3ff;
    color: var(--primary);
    font-weight: 700;
    border-color: #bad9fc;
}

.mini-rail-divider {
    width: 32px;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.mini-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    width: 100%;
}

.mini-rail-item:hover {
    background: #f0f2f5;
}

.mini-rail-sub {
    font-size: 0.65rem;
    font-weight: 700;
    color: #65676b;
    text-align: center;
    margin-top: 2px;
    white-space: nowrap;
}

/* FULL SIDEBAR CONTENT */
.sidebar-full-content {
    padding: 10px 12px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.sidebar-card-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #65676b;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.sidebar-collapse-btn {
    background: #f0f2f5;
    border: 1px solid var(--border);
    color: #4b5563;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: #e7f3ff;
    color: var(--primary);
    border-color: #bad9fc;
    transform: scale(1.08);
}

.sidebar-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.sidebar-stat-item {
    background: #f0f2f5;
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 8px;
}

.sidebar-stat-label {
    font-size: 0.72rem;
    color: #65676b;
    font-weight: 500;
}

.sidebar-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #050505;
    margin-top: 2px;
}

.sidebar-decade-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.decade-btn {
    background: #f0f2f5;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 2px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #050505;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.decade-btn:hover, .decade-btn.active {
    background: #e7f3ff;
    color: var(--primary);
    border-color: #bad9fc;
}

.sidebar-years-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.year-chip-btn {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.year-chip-btn:hover, .year-chip-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.sidebar-action-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    margin-bottom: 6px;
    transition: background 0.15s;
}

.sidebar-action-btn:hover {
    background: #f1f5f9;
    border-color: var(--border-hover);
}

/* -------------------------------------------------------------------------
   2. RIGHT JOURNEY SIDEBAR (CÂY HÀNH TRÌNH CUỘC ĐỜI CỐ ĐỊNH BÊN PHẢI)
   ------------------------------------------------------------------------- */
.right-journey-sidebar {
    width: 290px;
    min-width: 290px;
    background: #ffffff;
    border-left: 1px solid var(--border);
    height: calc(100vh - 56px);
    position: sticky;
    top: 56px;
    display: flex;
    flex-direction: column;
    transition: width 0.22s cubic-bezier(0.2, 0, 0, 1), min-width 0.22s cubic-bezier(0.2, 0, 0, 1);
    z-index: 80;
    box-shadow: -1px 0 4px rgba(0,0,0,0.02);
    flex-shrink: 0;
    overflow: hidden;
}

/* Thu nhỏ sang ray hẹp 44px */
.right-journey-sidebar.collapsed {
    width: 44px;
    min-width: 44px;
}

/* Ẩn hoàn toàn khi ở các chế độ không đủ chỗ trống như tuần, tháng, năm */
.right-journey-sidebar.hidden-view {
    display: none !important;
}

.right-sidebar-header {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    min-height: 44px;
    flex-shrink: 0;
}

.right-sidebar-title-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #0f172a;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.right-sidebar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.right-sidebar-btn {
    border: 1px solid var(--border);
    background: #ffffff;
    color: #475569;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}

.right-sidebar-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

/* Mini rail dọc khi sidebar phải đóng (Google Photos style scrubber) */
.right-sidebar-mini-rail {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 2px;
    flex: 1;
    overflow: hidden;
}

.right-journey-sidebar.collapsed .right-sidebar-mini-rail {
    display: flex;
}

.right-journey-sidebar.collapsed .right-sidebar-full-content,
.right-journey-sidebar.collapsed .right-sidebar-header {
    display: none !important;
}

.right-rail-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.15s;
    flex-shrink: 0;
}

.right-rail-btn:hover {
    background: #dbeafe;
    transform: scale(1.06);
}

.right-scrubber-timeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin-top: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 120px);
    padding: 2px 0;
}

.right-scrubber-year-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 3px 2px;
    border-radius: 4px;
    transition: all 0.12s ease;
    width: 38px;
    text-decoration: none;
}

.right-scrubber-year-btn:hover {
    background: #e7f3ff;
}

.right-scrubber-tick {
    width: 12px;
    height: 2px;
    background: #cbd5e1;
    border-radius: 2px;
    transition: all 0.12s;
}

.right-scrubber-year-btn:hover .right-scrubber-tick {
    width: 22px;
    background: var(--primary);
}

.right-scrubber-text {
    font-size: 0.62rem;
    font-weight: 700;
    color: #64748b;
    line-height: 1;
}

.right-scrubber-year-btn:hover .right-scrubber-text {
    color: var(--primary);
}

/* Nội dung đầy đủ của cây hành trình */
.right-sidebar-full-content {
    padding: 8px 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.right-tree-search-bar {
    position: relative;
    margin-bottom: 4px;
}

.right-tree-search-input {
    width: 100%;
    height: 30px;
    padding: 0 8px 0 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 0.78rem;
    color: var(--text-main);
    outline: none;
    transition: all 0.15s;
}

.right-tree-search-input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.15);
}

.right-tree-scroll-container {
    overflow-y: auto;
    flex: 1;
    padding-right: 2px;
}

/* Node cây đa cấp - SIÊU NHỎ VÀ SÍT NHAU (CHỈ 2 DÒNG) */
.right-tree-node {
    border-radius: 6px;
    padding: 3px 6px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background 0.12s, border-left 0.12s;
    border-left: 3px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.15;
}

.right-tree-node:hover {
    background: #f1f5f9;
}

.right-tree-node.active-spy {
    background: #eff6ff !important;
    border-left-color: var(--primary) !important;
}

/* Thụt lề cấp bậc */
.right-tree-node.level-0 { margin-left: 0px; }
.right-tree-node.level-1 { margin-left: 10px; background: rgba(248, 250, 252, 0.6); }
.right-tree-node.level-2 { margin-left: 20px; background: rgba(241, 245, 249, 0.8); }
.right-tree-node.level-3 { margin-left: 30px; }

/* Dòng 1: Caret + Icon + Tên */
.right-tree-row-1 {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #0f172a;
    min-width: 0;
}

.right-tree-caret {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 3px;
    transition: transform 0.15s, color 0.15s;
    flex-shrink: 0;
}

.right-tree-caret:hover {
    color: var(--primary);
    background: #e2e8f0;
}

.right-tree-caret.collapsed {
    transform: rotate(-90deg);
}

.right-tree-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Dòng 2: Ngày tháng và số ngày */
.right-tree-row-2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #64748b;
    padding-left: 18px;
    gap: 4px;
}

.right-tree-days-pill {
    font-weight: 700;
    color: #3b82f6;
}

/* MOBILE OFF-CANVAS OVERLAYS */
@media (max-width: 768px) {
    .lifebook-sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        height: calc(100vh - 56px);
        z-index: 1050;
        transform: translateX(0);
        transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
    }
    .lifebook-sidebar.collapsed {
        transform: translateX(-100%);
        width: 310px;
    }
    .sidebar-backdrop.active {
        display: block;
    }
    .right-journey-sidebar {
        display: none !important;
    }
}
