/* --- 1. BIẾN MÀU SẮC & CẤU HÌNH CHUNG --- */
:root {
    --primary: #d32f2f;
    --bg-body: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

body { 
    background-color: var(--bg-body); 
    font-family: 'Inter', -apple-system, sans-serif; 
    margin: 0; color: var(--text-main); line-height: 1.6;
}

/* --- 2. TRANG CHỦ (INDEX.PHP) --- */
.header-section { padding-top: 40px; text-align: center; }
.main-title { 
    color: var(--primary); font-weight: 800; text-transform: uppercase; 
    border-bottom: 4px solid var(--primary); display: inline-block; 
    padding-bottom: 10px; font-size: 2rem; margin-bottom: 20px;
}

/* Thống kê trang chủ */
.stat-container { display: flex; justify-content: center; margin-bottom: 40px; }
.stat-pill { 
    background: #ffffff; padding: 10px 25px; border-radius: 50px; 
    color: var(--text-muted); font-size: 0.9rem; font-weight: 600; 
    border: 1px solid var(--border); display: inline-flex; 
    align-items: center; gap: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.stat-pill b { color: var(--primary); font-size: 1rem; }

/* Lưới đơn vị - Căn giữa & Chống vỡ */
.unit-grid { 
    display: flex; flex-wrap: wrap; justify-content: center; 
    gap: 25px; max-width: 1200px; margin: 0 auto; padding: 0 15px;
}

.unit-card { 
    background: white; border-radius: 24px; 
    width: 240px; height: 215px; /* Cố định để không bị lệch */
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); transition: 0.3s; text-decoration: none !important;
    border: 1px solid transparent;
}
.unit-card:hover { 
    transform: translateY(-10px); border-color: var(--primary); 
    box-shadow: 0 15px 30px rgba(211, 47, 47, 0.15); 
}

/* Khống chế Icon trang chủ */
.card-icon { width: 90px; height: 90px; margin-bottom: 15px; display: flex; align-items: center; justify-content: center; }
.card-icon img { width: 85px !important; height: 85px !important; object-fit: contain; }
.unit-name { 
    color: var(--text-main); font-weight: 700; text-transform: uppercase; 
    font-size: 0.85rem; text-align: center; padding: 0 15px; margin: 0; 
}

/* --- 3. TRANG CHI TIẾT (CHI_TIET.PHP) --- */
.top-bar { 
    background: white; border-bottom: 3px solid var(--primary); 
    position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.unit-brand img { width: 45px !important; height: 45px !important; object-fit: contain; }
.unit-brand h1 { font-size: 1.1rem; font-weight: 800; color: var(--primary); margin: 0; text-transform: uppercase; }

/* Điều hướng tuần 1-2-1 */
.week-nav {
    background: white; border: 1px solid var(--border);
    padding: 12px 25px; border-radius: 50px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 15px rgba(0,0,0,0.04);
}
.nav-btn-box { flex: 1; }
.nav-center { flex: 2; text-align: center; }

/* Khối lịch */
.day-group { background: white; border-radius: 12px; margin-bottom: 25px; overflow: hidden; border: 1px solid var(--border); }
.day-header { 
    background: #fdfdfd; padding: 15px 20px; border-bottom: 1px solid var(--border); 
    border-left: 6px solid #cbd5e1;
}
.is-today { border: 2px solid var(--primary); }
.is-today .day-header { background: var(--primary); color: white; border-left: none; }

.event-item { display: flex; padding: 20px; border-bottom: 1px solid #f1f5f9; }
.event-time { flex: 0 0 80px; }
.time-box { 
    background: #f1f5f9; color: #475569; padding: 5px 12px; 
    border-radius: 8px; font-weight: 800; font-size: 0.9rem; border: 1px solid var(--border);
}
.event-content { flex: 1; padding: 0 20px; }
.event-meta { flex: 0 0 280px; padding-left: 20px; border-left: 1px solid #f1f5f9; }
.meta-label { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; color: var(--text-muted); display: block; }
.meta-value { font-weight: 600; color: var(--text-main); }

/* Nút file */
.btn-attachment {
    display: inline-flex; align-items: center; gap: 8px;
    margin-top: 10px; padding: 5px 15px; border-radius: 20px;
    background: #fff; color: var(--primary); border: 1.5px solid var(--primary);
    font-size: 0.85rem; font-weight: 700; text-decoration: none; transition: 0.2s;
}

/* --- 4. RESPONSIVE (SỬA LỖI LẶP TIN & VỠ GRID) --- */
@media (max-width: 768px) {
    .main-title { font-size: 1.5rem; }
    .unit-card { width: calc(50% - 15px); height: 190px; }
    .card-icon { width: 75px; height: 75px; }
    .card-icon img { width: 70px !important; height: 70px !important; }
    
    .event-item { flex-direction: column; }
    .event-meta { display: none !important; }
    .mobile-info-box { 
        display: block !important; margin-top: 15px; background: #fdf2f2; 
        padding: 10px; border-radius: 8px; border: 1px solid #fee2e2;
    }
}
@media (min-width: 769px) {
    .mobile-info-box { display: none !important; }
}
/* --- TỐI ƯU HÓA HOÀN HẢO CHO BẢN IN --- */
@media print {
    /* 1. Ẩn tất cả các nút, thanh điều hướng, icon web */
    .no-print, .btn, footer, .top-bar, .week-nav, .btn-attachment, .badge, i, .bi {
        display: none !important;
    }

    /* 2. Cấu hình lại trang giấy */
    @page {
        size: A4;
        margin: 1.5cm;
    }

    body {
        background: white !important;
        color: black !important;
        font-family: "Times New Roman", Times, serif !important; /* Font chữ hành chính */
        font-size: 12pt;
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 3. Tiêu đề in chuyên nghiệp */
    .print-only {
        display: block !important;
        margin-bottom: 30px;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }

    /* 4. CHỐNG LẶP THÔNG TIN (Quan trọng nhất) */
    .mobile-info-box {
        display: none !important; /* Tuyệt đối ẩn phần chữ đỏ Mobile khi in */
    }

    .event-meta {
        display: block !important; /* Hiện phần thông tin Desktop gọn gàng */
        border-left: 1px solid #000 !important;
        flex: 0 0 30%; /* Chiếm 30% chiều ngang */
    }

    /* 5. Định dạng lại khối ngày */
    .day-group {
        border: 1px solid #000 !important; /* Viền đen mảnh */
        border-radius: 0 !important;       /* Bỏ bo góc */
        box-shadow: none !important;       /* Bỏ đổ bóng */
        margin-bottom: 15px !important;
        page-break-inside: avoid;          /* Không ngắt trang giữa chừng 1 ngày */
    }

    .day-header {
        background: #f0f0f0 !important;   /* Nền xám nhạt */
        border-bottom: 1px solid #000 !important;
        color: black !important;
        padding: 8px 15px !important;
    }

    .day-header h5 {
        font-weight: bold !important;
        margin: 0 !important;
        font-size: 13pt !important;
    }

    /* 6. Định dạng dòng sự kiện */
    .event-item {
        border-bottom: 1px solid #ccc !important;
        padding: 10px 15px !important;
        display: flex !important;
    }

    .event-time {
        flex: 0 0 60px !important;
        font-weight: bold !important;
    }

    .time-box {
        background: none !important;
        border: none !important;
        padding: 0 !important;
    }

    .content-display {
        font-weight: bold !important;
        font-size: 12pt !important;
    }

    .meta-label {
        font-size: 9pt !important;
        color: #555 !important;
        text-transform: uppercase;
        font-weight: bold;
    }
}