/* ===================================================================
   Bảng tổng quan dự án — giao diện tuỳ biến (gọn, sáng sủa, chuyên nghiệp)
   =================================================================== */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e6e8ec;
    --text: #1f2733;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 8px 28px rgba(16, 24, 40, .10);
    --ring: 0 0 0 3px rgba(37, 99, 235, .16);
    --brand-grad: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);

    /* Tông màu trạng thái: nền nhạt / chữ đậm */
    --slate-bg: #eef1f5;  --slate-fg: #475569;
    --blue-bg:  #e3edff;  --blue-fg:  #1d4ed8;
    --red-bg:   #fde6e6;  --red-fg:   #c62828;
    --amber-bg: #fdf0d9;  --amber-fg: #b45309;
    --green-bg: #e3f6e8;  --green-fg: #1b7f3b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Thanh trên cùng ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: 0 24px;
    height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo-badge {
    width: 34px; height: 34px; border-radius: 10px; background: var(--brand-grad);
    color: #fff; font-weight: 800; font-size: 19px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(29, 78, 216, .35);
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; font-size: 17px; line-height: 1.1; }
.brand-sub { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a {
    color: var(--muted); font-weight: 600; padding: 7px 14px; border-radius: 9px; white-space: nowrap;
}
.topnav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.topnav a.active { background: var(--blue-bg); color: var(--blue-fg); }
.btn-top { white-space: nowrap; }

/* ---------- Khung trang ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.footer { max-width: 1180px; margin: 0 auto; padding: 20px 24px 40px; color: var(--muted); font-size: 13px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }

.flash {
    background: var(--green-bg); color: var(--green-fg);
    border: 1px solid #bce6c8; border-radius: 10px;
    padding: 11px 16px; margin-bottom: 20px; font-weight: 600;
}

/* ---------- Thẻ thống kê ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 26px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden; transition: box-shadow .15s, transform .15s;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--slate-fg); opacity: .7;
}
.stat.accent-blue::before { background: var(--blue-fg); }
.stat.accent-red::before { background: var(--red-fg); }
.stat.accent-green::before { background: var(--green-fg); }
.stat.accent-amber::before { background: var(--amber-fg); }
.stat:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat .num { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.accent-red .num { color: var(--red-fg); }
.stat.accent-blue .num { color: var(--blue-fg); }
.stat.accent-green .num { color: var(--green-fg); }
.stat.accent-amber .num { color: var(--amber-fg); }

/* ---------- Bố cục 2 cột dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
/* Cho phép cột co lại để chữ 1-dòng (nowrap) cắt bằng "…" thay vì nở rộng gây tràn ngang */
.dash-grid > *, .detail-grid > * { min-width: 0; }
.proj-list, .proj-card { min-width: 0; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }

/* ---------- Thẻ dự án ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.proj-list { display: grid; gap: 10px; }
.proj-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 15px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s;
    border-left: 4px solid var(--slate-fg); display: block; color: inherit;
}
.proj-card:hover { box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.proj-card.tone-blue { border-left-color: var(--blue-fg); }
.proj-card.tone-red { border-left-color: var(--red-fg); }
.proj-card.tone-amber { border-left-color: var(--amber-fg); }
.proj-card.tone-green { border-left-color: var(--green-fg); }
.proj-card.tone-slate { border-left-color: var(--slate-fg); }
/* Mỗi dòng giữ 1 hàng, dài thì cắt bằng "…" để thẻ thấp, hiện được nhiều dự án */
.proj-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.proj-name { font-size: 15.5px; font-weight: 700; color: var(--text); margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-top > .gap-wrap { flex-shrink: 0; flex-wrap: nowrap; }
.proj-desc { color: var(--muted); margin: 3px 0 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 9px; }
.proj-meta .owner { display: flex; align-items: center; gap: 7px; color: var(--text); font-weight: 600; }
.proj-meta .avatar { width: 24px; height: 24px; font-size: 10.5px; }
/* Dấu màu nhận diện dự án */
.proj-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; margin-right: 7px; vertical-align: middle; position: relative; top: -1px; }
.proj-swatch.lg { width: 14px; height: 14px; border-radius: 4px; margin-right: 9px; }

/* ---------- Pill / nhãn trạng thái ---------- */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.pill.tone-slate { background: var(--slate-bg); color: var(--slate-fg); }
.pill.tone-blue  { background: var(--blue-bg);  color: var(--blue-fg); }
.pill.tone-red   { background: var(--red-bg);   color: var(--red-fg); }
.pill.tone-amber { background: var(--amber-bg); color: var(--amber-fg); }
.pill.tone-green { background: var(--green-bg); color: var(--green-fg); }

/* ---------- Avatar ---------- */
.avatar {
    width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: 11.5px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }

/* Chấm trạng thái online/offline ở góc avatar */
.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.status-dot {
    position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
    border-radius: 50%; border: 2px solid var(--surface); box-sizing: content-box;
}
.status-dot.online { background: #22c55e; }
.status-dot.offline { background: #cbd2dc; }
.avatar-wrap .avatar.lg ~ .status-dot { width: 12px; height: 12px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -7px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Thanh tiến độ ---------- */
.progress-mini { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; flex: 1; min-width: 80px; }
.progress-mini > span { display: block; height: 100%; background: var(--green-fg); border-radius: 999px; }

/* ---------- Bảng ---------- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--border); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafbfc; }
.tbl .nowrap { white-space: nowrap; }

/* ---------- Danh sách bên (thành viên / cảnh báo) ---------- */
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.member-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: none; }
.member-row .info { flex: 1; min-width: 0; }
.member-row .name { font-weight: 600; }
.member-row .doing { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .idle { color: var(--amber-fg); font-weight: 600; }
.presence { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.presence.on { color: #16a34a; font-weight: 700; }

/* Bảng "Thông tin" trong trang dự án — nhãn 1 hàng, không xuống dòng */
.info-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); white-space: nowrap; flex-shrink: 0; min-width: 104px; font-size: 13.5px; padding-top: 1px; }
.info-val { flex: 1; min-width: 0; }

.attention-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.attention-row:last-child { border-bottom: none; }
.attention-row .ico { color: var(--red-fg); font-size: 16px; line-height: 1.4; }

/* ---------- Form ---------- */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow-sm); max-width: 640px; }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.text-danger { color: var(--red-fg); font-size: 13px; }

/* ---------- Nút ---------- */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.inline-form { display: inline; }

/* ---------- Tiện ích ---------- */
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.gap-wrap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.back-link { color: var(--muted); font-weight: 600; font-size: 14px; display: inline-block; margin-bottom: 10px; }

/* ---------- Tab lọc danh sách ---------- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 4px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.tab {
    display: inline-flex; align-items: center; gap: 7px; padding: 7px 15px; border-radius: 8px;
    font-weight: 600; font-size: 14px; color: var(--muted);
}
.tab:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.tab.active { background: var(--blue-bg); color: var(--blue-fg); }
.tab .count {
    font-size: 12px; font-weight: 700; background: rgba(0, 0, 0, .06); color: inherit;
    border-radius: 999px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.tab.active .count { background: rgba(29, 78, 216, .15); }

/* Nút theo dõi (ngôi sao) */
.track-btn {
    background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1;
    color: #cbd2dc; padding: 2px 4px; border-radius: 6px; transition: color .12s, transform .12s;
}
.track-btn:hover { transform: scale(1.15); color: var(--amber-fg); }
.track-btn.on { color: #f5b301; }

/* Dòng dự án đã bỏ theo dõi: làm mờ nhẹ */
.row-muted td { opacity: .62; }
.row-muted:hover td { opacity: 1; }

/* ---------- Thanh công cụ danh sách (tab + lọc) ---------- */
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; margin-bottom: 18px; }
.list-toolbar .tabs { margin-bottom: 0; }
/* Bộ lọc: 1 hàng ngang trên desktop (cả cụm sẽ xuống dòng nguyên khối nếu hẹp) */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.filter-bar input[type="search"] { width: 200px; flex-shrink: 0; }
.filter-bar .form-select { width: 168px; flex-shrink: 0; }
.filter-bar .btn { flex-shrink: 0; }

/* Dòng cập nhật mới nhất trên thẻ dự án (1 dòng, cắt bằng "…") */
.proj-update { font-size: 13px; color: var(--text); margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Feed cập nhật (trang chi tiết) ---------- */
.update-feed { position: relative; }
.update-item { display: flex; gap: 12px; padding: 9px 0; position: relative; }
.update-item:not(:last-child)::before {
    content: ""; position: absolute; left: 4px; top: 20px; bottom: -2px; width: 2px; background: var(--border);
}
.update-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue-fg); margin-top: 5px; flex-shrink: 0; z-index: 1; }
.update-item .inline-form { display: inline; }

/* ---------- Menu người dùng trên thanh trên ---------- */
.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 9px; background: none; border: none;
    cursor: pointer; padding: 5px 8px; border-radius: 10px; color: var(--text);
}
.user-btn:hover { background: var(--bg); }
.user-name { font-weight: 600; font-size: 14px; }
.user-menu .dropdown-item { cursor: pointer; }

/* ---------- Trang đăng nhập ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #eef2fb 0%, #f5f6f8 100%);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
    box-shadow: var(--shadow); padding: 32px 34px; width: 100%; max-width: 380px; margin: 20px;
}
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-brand .logo-badge { width: 40px; height: 40px; border-radius: 12px; font-size: 22px; }
.login-brand .brand-text { font-size: 20px; }

/* ---------- Tinh chỉnh chung (polish) ---------- */
.topbar { box-shadow: 0 1px 3px rgba(16, 24, 40, .05); }

.btn { border-radius: 9px; font-weight: 600; transition: transform .12s, box-shadow .15s, background .15s, color .15s; }
.btn-sm { border-radius: 7px; }
.btn-primary { box-shadow: 0 2px 6px rgba(29, 78, 216, .25); }
.btn-primary:hover { box-shadow: 0 5px 14px rgba(29, 78, 216, .32); transform: translateY(-1px); }
.btn-outline-secondary, .btn-outline-danger { border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text); border-color: #cdd2da; }

/* Ô nhập liệu: bo mềm + viền focus đồng bộ thương hiệu */
.form-control, .form-select, textarea.form-control {
    border-color: var(--border); border-radius: 9px;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
    border-color: var(--primary); box-shadow: var(--ring); outline: none;
}

/* Avatar nổi nhẹ */
.avatar { box-shadow: 0 1px 2px rgba(16, 24, 40, .15); }

/* Tiêu đề bảng dày dặn hơn một chút */
.tbl th { font-weight: 700; }

/* Hiệu ứng xuất hiện nhẹ khi mở trang — chỉ mờ dần, KHÔNG dùng transform
   (transform trên phần tử cha sẽ chặn tương tác của modal/position:fixed bên trong) */
.page { animation: fadeIn .24s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Thanh cuộn tinh tế */
* { scrollbar-width: thin; scrollbar-color: #cdd2da transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cdd2da; border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #b6bcc6; }

/* Modal bo góc đồng bộ */
.modal-content { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.modal-header, .modal-footer { border-color: var(--border); }

@media (max-width: 900px) {
    .dash-grid, .detail-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE (≤ 720px) — tối ưu cho thao tác trên điện thoại
   ============================================================ */
@media (max-width: 720px) {
    body { font-size: 15px; }
    .page { padding: 16px 14px 80px; }
    .footer { padding: 16px 14px 30px; }

    /* --- Thanh trên: thương hiệu + người dùng 1 hàng, menu điều hướng hàng dưới --- */
    .topbar-inner { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px 14px; gap: 8px 10px; }
    .brand-sub { display: none; }
    .logo-badge { width: 30px; height: 30px; font-size: 17px; border-radius: 9px; }
    .brand-text { font-size: 16px; }
    .user-menu { margin-left: auto; }
    .user-name { display: none; }            /* chỉ còn avatar + huy hiệu cho gọn */
    .topnav {
        order: 5; width: 100%; gap: 4px;
        border-top: 1px solid var(--border); padding-top: 7px; margin-top: 2px;
    }
    .topnav a { flex: 1; text-align: center; padding: 9px 4px; font-size: 13.5px; }

    /* --- Tiêu đề trang --- */
    .page-head h1 { font-size: 20px; }
    .page-head { gap: 10px; margin-bottom: 16px; }

    /* --- Thẻ thống kê: 2 cột, gọn --- */
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
    .stat { padding: 12px 14px; }
    .stat .num { font-size: 24px; }

    /* --- Thanh công cụ danh sách: tab + bộ lọc xếp dọc, full chiều ngang --- */
    .list-toolbar { flex-direction: column; align-items: stretch; }
    .list-toolbar .tabs { width: 100%; justify-content: center; }
    .list-toolbar .tabs .tab { flex: 1; justify-content: center; }
    .filter-bar { width: 100%; flex-wrap: wrap; }
    .filter-bar .form-control, .filter-bar .form-select, .filter-bar input[type="search"] { flex: 1 1 100%; min-width: 0; width: 100%; }
    .filter-bar .btn { flex: 1; }

    /* --- BẢNG → THẺ xếp dọc (đọc dễ, không phải cuộn ngang) --- */
    .tbl-responsive thead { display: none; }
    .tbl-responsive tr { display: block; position: relative; padding: 13px 44px 13px 14px; border-bottom: 1px solid var(--border); }
    .tbl-responsive tr:last-child { border-bottom: none; }
    .tbl-responsive tr:hover td { background: none; }
    .tbl-responsive td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 4px 0; border: none; text-align: right; min-height: 30px;
    }
    .tbl-responsive td::before {
        content: attr(data-label); font-weight: 600; color: var(--muted); font-size: 12.5px; text-align: left; flex-shrink: 0;
    }
    /* Ô tên (tiêu đề thẻ): chiếm cả hàng, canh trái, không nhãn */
    .tbl-responsive td.cell-main { display: block; text-align: left; padding: 0 0 6px; }
    .tbl-responsive td.cell-main::before { content: none; }
    /* Ô sao theo dõi: nổi góc trên phải */
    .tbl-responsive td.cell-star { position: absolute; top: 9px; right: 10px; padding: 0; }
    .tbl-responsive td.cell-star::before { content: none; }
    /* Ô nút thao tác: canh phải, không nhãn */
    .tbl-responsive td.cell-actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
    .tbl-responsive td.cell-actions::before { content: none; }
    /* Select trong ô (trạng thái việc, gán dự án) full chiều ngang cho dễ bấm */
    .tbl-responsive td .form-select { width: auto; max-width: 60%; }

    /* --- Thẻ dự án trên dashboard: tên 1 hàng, pill xuống hàng dưới (tránh tràn ngang) --- */
    .proj-top { flex-direction: column; align-items: flex-start; gap: 5px; }
    .proj-top > .gap-wrap { flex-wrap: wrap; }
    .proj-name { white-space: normal; }

    /* --- Nút to hơn chút cho dễ chạm --- */
    .btn { padding: 7px 14px; }
    .btn-sm { padding: 5px 10px; }

    /* --- Hộp thoại sát mép --- */
    .modal-dialog { margin: 12px; }

    /* An toàn: chặn cuộn ngang ngoài ý muốn */
    html, body { overflow-x: hidden; }
}
