/* =========================================================================
   LIFEBOOK - VIEWS (WEEK, MONTH, YEAR, TIMELINE)
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. WEEK VIEW (CHẾ ĐỘ XEM TUẦN - 7 CỘT VỪA VẶN MÀN HÌNH TRÊN LAPTOP / DESKTOP)
   ------------------------------------------------------------------------- */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    width: 100%;
}

/* Tối thiểu 2 cột trên điện thoại / mobile */
@media (max-width: 768px) {
    .week-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px;
    }
}

.day-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 150px);
    min-height: 220px;
    max-height: 560px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    overflow: hidden;
}

@media (max-width: 768px) {
    .day-card {
        height: auto;
        min-height: 260px;
        max-height: none;
    }
}

.day-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.day-card.today {
    border: 2px solid var(--primary);
}

.day-card.active-selected {
    outline: 2px solid var(--primary);
    box-shadow: 0 0 0 4px rgba(24, 119, 242, 0.2);
}

.day-card.disabled-day {
    opacity: 0.35;
    background: #f1f5f9;
    pointer-events: none;
    filter: grayscale(1);
}

.day-header {
    padding: 5px 6px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.day-header-left {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.day-dow {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
}

.day-date-str {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.day-lifeday-badge {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 4px;
}

/* Thẻ chặng hành trình trong ngày */
.day-journeys-wrap {
    padding: 2px 4px;
    background: #fafafa;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    max-height: 48px;
    overflow: hidden;
}

.day-journey-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.62rem;
    font-weight: 600;
    color: #1e293b;
    background: #f1f5f9;
    border-left: 3px solid var(--primary);
    line-height: 1.2;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    gap: 4px;
    overflow: hidden;
}

.day-photo-wrap {
    position: relative;
    width: 100%;
    height: 85px;
    min-height: 70px;
    border-radius: 6px;
    overflow: hidden;
    background: #f1f5f9;
    cursor: pointer;
    flex-shrink: 0;
}

.day-photo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.day-photo-wrap:hover img {
    transform: scale(1.03);
}

.day-photo-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.day-photo-wrap:hover .day-photo-delete-btn {
    opacity: 1;
}

.day-photo-delete-btn:hover {
    background: var(--danger);
}

.day-note-edit-area {
    width: 100%;
    flex: 1;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px;
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--text-main);
    resize: none;
    outline: none;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
    min-height: 50px;
}

.day-note-edit-area:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.15);
}

.day-note-read-mode {
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-main);
    word-break: break-word;
    white-space: pre-wrap;
    padding: 4px;
}

/* -------------------------------------------------------------------------
   2. MONTH VIEW (CHẾ ĐỘ XEM THÁNG - ẢNH TRÀN VIỀN OVERLAY ĐÈ LÊN)
   ------------------------------------------------------------------------- */
/* Thanh công cụ lọc & ẩn/hiện Ảnh/Nội dung trong Lịch Tháng */
.month-filter-bar {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 8px;
}

.month-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.month-filter-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    margin-right: 2px;
}

.month-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: #f8fafc;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.month-toggle-label:hover {
    background: #f1f5f9;
    border-color: var(--border-hover);
}

.month-toggle-label input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.month-container {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* Khi ẩn ảnh trong lịch Tháng (Chỉ xem Content/Ghi chú) */
.month-container.hide-photos .month-cell-bg-photo {
    display: none !important;
}

.month-container.hide-photos .month-cell.has-photo .month-cell-daynum,
.month-container.hide-photos .month-cell.has-photo .month-cell-lifeday,
.month-container.hide-photos .month-cell.has-photo .month-cell-note-read,
.month-container.hide-photos .month-cell.has-photo .month-cell-note-edit {
    background: transparent !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

/* Khi ẩn ghi chú trong lịch Tháng (Chỉ xem Ảnh) */
.month-container.hide-content .month-cell-content {
    display: none !important;
}

.month-container.hide-content .month-cell {
    height: 110px;
    cursor: pointer;
}

.month-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.month-table th {
    padding: 8px 4px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: center;
}

.month-table th:last-child {
    border-right: none;
}

.month-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    height: 110px;
    min-height: 90px;
    max-height: 120px;
    padding: 3px 4px;
    position: relative;
    background: #ffffff;
    transition: background 0.15s;
    overflow: hidden;
}

.month-cell:last-child {
    border-right: none;
}

.month-cell.other-month {
    background: #f8fafc;
    opacity: 0.45;
}

.month-cell.today {
    background: #f0f7ff;
}

.month-cell.active-selected {
    outline: 2px solid var(--primary);
    z-index: 5;
}

/* Yêu cầu #5: Ảnh tràn viền full-bleed từ trên cùng xuống đáy ô tháng */
.month-cell-bg-photo {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    border-radius: 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.month-cell:hover .month-cell-bg-photo {
    transform: scale(1.04);
}

/* Overlay nội dung đè lên trên ảnh */
.month-cell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
    position: relative;
    z-index: 2;
}

/* Backdrop mờ khi có ảnh để chữ ngày tháng rõ ràng */
.month-cell.has-photo .month-cell-daynum,
.month-cell.has-photo .month-cell-lifeday {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(2px);
    border-radius: 3px;
    padding: 0 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.month-cell-daynum {
    font-size: 0.75rem;
    font-weight: 700;
    color: #0f172a;
}

.month-cell-lifeday {
    font-size: 0.6rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 0 3px;
    border-radius: 3px;
}

.month-journey-dots {
    display: inline-flex;
    gap: 2px;
    margin-left: 2px;
}

.month-journey-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.month-cell-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: calc(100% - 18px);
    position: relative;
    z-index: 2;
}

.month-cell.has-photo .month-cell-note-read,
.month-cell.has-photo .month-cell-note-edit {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(2px);
    border-radius: 3px;
    padding: 2px 4px;
}

.month-cell-note-read {
    font-size: 0.64rem;
    line-height: 1.15;
    color: #1e293b;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.month-cell-note-edit {
    width: 100%;
    flex: 1;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 0.64rem;
    line-height: 1.15;
    color: #1e293b;
    background: transparent;
    resize: none;
    outline: none;
}

.month-cell-note-edit:focus {
    background: #ffffff;
    border-color: var(--primary);
}

/* -------------------------------------------------------------------------
   3. YEAR VIEW (CHẾ ĐỘ XEM CẢ NĂM - LƯỚI 365 NGÀY & DẢI HÀNH TRÌNH)
   ------------------------------------------------------------------------- */
.year-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@media (max-width: 1100px) {
    .year-overview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .year-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.year-month-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.year-month-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.year-month-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.year-day-box {
    aspect-ratio: 1;
    border-radius: 2px;
    background: #f8fafc;
    font-size: 0.58rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    position: relative;
    transition: transform 0.1s;
}

.year-day-box:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.year-day-box.has-note {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 700;
}

.year-day-box.has-photo {
    background: #fef08a;
    color: #854d0e;
    font-weight: 700;
}

.year-day-box.today {
    outline: 2px solid var(--primary);
}

/* Banner dải hành trình ngắn trong tháng của năm */
.year-month-short-journeys {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.year-short-journey-banner {
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.62rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* -------------------------------------------------------------------------
   4. TIMELINE VIEW (CHẾ ĐỘ DÒNG ĐỜI - FEED FACEBOOK)
   ------------------------------------------------------------------------- */
.timeline-container-wrap {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.timeline-filter-bar {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 8px;
}

.timeline-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.timeline-feed {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.timeline-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.timeline-card:hover {
    box-shadow: var(--shadow-md);
}

.timeline-card-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
}

.timeline-card-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-card-date {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.timeline-card-lifeday {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

.timeline-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.timeline-card-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.15s;
}

.timeline-card-btn:hover {
    background: #e7f3ff;
    color: var(--primary);
    border-color: #bad9fc;
}

/* Yêu cầu #4: Ảnh Dòng Đời nền trắng thay vì nền đen */
.timeline-card-photo-wrap {
    width: 100%;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    max-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.timeline-card-photo {
    width: 100%;
    max-height: 520px;
    object-fit: contain;
    transition: transform 0.2s;
}

.timeline-card-photo:hover {
    transform: scale(1.01);
}

.timeline-card-note {
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-main);
    word-break: break-word;
    white-space: pre-wrap;
}

.timeline-load-more-wrap {
    text-align: center;
    padding: 16px 0;
}

/* GALLERY VIEW 3 CỘT CHO DÒNG ĐỜI */
.timeline-feed.gallery-mode {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .timeline-feed.gallery-mode {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.timeline-gallery-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--border);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.timeline-gallery-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.timeline-gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.timeline-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    color: #ffffff;
    padding: 18px 8px 6px 8px;
    font-size: 0.72rem;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.btn-today-pulse {
    background: #10b981 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border: none !important;
    animation: pulseToday 2s infinite;
}

@keyframes pulseToday {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
