
/* =====================================================
   KPI TABLE
===================================================== */

.kpi-table {
  margin-top: 12px;

  border-top: 1px solid #eee;

  width: 100%;

  overflow-x: auto;

  -webkit-overflow-scrolling: touch;

  font-size: 14px;
}


/* =====================================================
   GRID
===================================================== */

.kpi-head,
.kpi-body {
  min-width: 650px;
}


.kpi-head,
.kpi-row {
  display: grid;

  grid-template-columns:
    minmax(150px, 2fr)
    minmax(100px, 1fr)
    minmax(100px, 1fr)
    minmax(120px, 1fr)
    minmax(100px, 0.9fr);

  align-items: center;

  text-align: center;
}


/* =====================================================
   HEADER
===================================================== */

.kpi-head {
  padding: 10px 0;

  border-bottom: 2px solid #ddd;

  font-size: 13px;

  font-weight: 700;

  color: #555;
}


/* =====================================================
   BODY
===================================================== */

.kpi-body {
  display: flex;

  flex-direction: column;
}


/* =====================================================
   ROW
===================================================== */

.kpi-row {
  padding: 10px 0;

  border-bottom: 1px solid #f0f0f0;

  cursor: pointer;
}


.kpi-row:hover {
  background: #fafafa;
}


/* =====================================================
   CELL
===================================================== */

.kpi-head > div,
.kpi-row > div {
  min-width: 0;

  padding: 0 5px;

  white-space: nowrap;

  overflow: hidden;

  text-overflow: ellipsis;
}


/* =====================================================
   NHÂN VIÊN
===================================================== */

.kpi-head > div:first-child,
.kpi-row > div:first-child {
  text-align: left;

  padding-left: 8px;
}


.kpi-employee-name {
  font-weight: 600;
}


.kpi-employee-code {
  margin-top: 2px;

  font-size: 11px;

  color: #888;
}


/* =====================================================
   STATUS
===================================================== */

.kpi-status {
  display: inline-block;

  padding: 3px 8px;

  border-radius: 12px;

  font-size: 12px;

  white-space: nowrap;
}


.kpi-status-update {
  background: #e8f5e9;

  color: #2e7d32;
}


.kpi-status-draft {
  background: #f5f5f5;

  color: #777;
}


/* =====================================================
   LOAD MORE
===================================================== */

.kpi-load-more {
  padding: 10px 0 20px;
}


.kpi-load-more button {
  width: 100%;

  border: 1px dashed #ccc;

  background: #f9f9f9;

  color: #1976d2;

  cursor: pointer;

  font-weight: 500;

  padding: 12px;

  border-radius: 8px;
}


.kpi-history-end {
  text-align: center;

  color: #bbb;

  font-size: 12px;

  padding: 30px 10px;

  font-style: italic;
}






/* =========================================================
   KPI FORM
========================================================= */

#kpisFormView {
    width: 100%;
}


/* =========================================================
   CARD
========================================================= */

.kpis-form-card {
    width: 100%;
    overflow: hidden;
}


/* =========================================================
   HEADER
========================================================= */

.kpis-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}


.kpis-form-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}


.kpis-form-header .view-title {
    margin: 0;
}


.kpis-form-mode-label {
    margin-top: 2px;

    font-size: 13px;
    line-height: 1.3;

    color: #777;
}


/* =========================================================
   SECTION
========================================================= */

.kpis-form-section {
    margin-top: 16px;
}


.kpis-form-section-title {
    margin-bottom: 10px;

    font-size: 15px;
    font-weight: 600;

    color: #333;
}


/* =========================================================
   THÔNG TIN CHUNG
========================================================= */

.kpis-info-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 10px;
}


.kpis-info-field {
    min-width: 0;

    padding: 10px 12px;

    border: 1px solid #e1e1e1;
    border-radius: 8px;

    background: #fafafa;
}


.kpis-info-field label {
    display: block;

    margin-bottom: 5px;

    font-size: 12px;
    line-height: 1.3;

    color: #777;
}


.kpis-info-value {
    min-height: 20px;

    font-size: 14px;
    line-height: 1.4;

    font-weight: 500;

    color: #222;

    word-break: break-word;
}


/* =========================================================
   KPI TABLE WRAPPER
========================================================= */

/*
   Đây là phần quan trọng nhất.

   Desktop:
   - bảng chiếm toàn bộ chiều rộng.

   Mobile:
   - bảng KHÔNG co cột.
   - wrapper scroll ngang.
*/

.kpis-table-wrap {
    width: 100%;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;

    border: 1px solid #e1e1e1;
    border-radius: 8px;

    background: #fff;
}


/* =========================================================
   KPI TABLE
========================================================= */

.kpis-form-table {
    width: 100%;

    min-width: 980px;

    border-collapse: separate;
    border-spacing: 0;

    table-layout: fixed;

    font-size: 13px;
}


/* =========================================================
   HEADER
========================================================= */

.kpis-form-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;

    padding: 10px 10px;

    border-bottom: 1px solid #dcdcdc;

    background: #f7f7f7;

    font-weight: 600;

    color: #333;

    text-align: left;

    white-space: nowrap;
}


/* =========================================================
   BODY
========================================================= */

.kpis-form-table tbody td {
    padding: 10px;

    border-bottom: 1px solid #ededed;

    vertical-align: middle;

    color: #333;
}


.kpis-form-table tbody tr:last-child td {
    border-bottom: none;
}


.kpis-form-table tbody tr:hover {
    background: #fafafa;
}


/* =========================================================
   COLUMN WIDTH
========================================================= */

.kpis-form-table .col-loai-luong {
    width: 170px;
}


.kpis-form-table .col-loai-kpis {
    width: 190px;
}


.kpis-form-table .col-target {
    width: 120px;
}


.kpis-form-table .col-ket-qua {
    width: 145px;
}


.kpis-form-table .col-kq-final {
    width: 170px;
}


.kpis-form-table .col-kpis {
    width: 150px;
}


.kpis-form-table .col-rate {
    width: 150px;
}


/* =========================================================
   LOẠI LƯƠNG
========================================================= */

.kpis-loai-luong-code {
    display: block;

    font-size: 12px;

    color: #888;
}


.kpis-loai-luong-label {
    display: block;

    margin-top: 2px;

    font-weight: 600;

    color: #222;
}


/* =========================================================
   LOẠI KPI
========================================================= */

.kpis-loai-kpis-code {
    display: block;

    font-size: 12px;

    color: #888;
}


.kpis-loai-kpis-label {
    display: block;

    margin-top: 2px;

    font-weight: 500;

    color: #333;
}


/* =========================================================
   NUMBER / VALUE
========================================================= */

.kpis-value {
    text-align: right;

    white-space: nowrap;
}


/* =========================================================
   EDITABLE KPI INPUT
========================================================= */

.kpis-kpis-input {
    width: 100%;

    min-width: 100px;

    box-sizing: border-box;

    padding: 7px 8px;

    border: 1px solid #cfcfcf;
    border-radius: 6px;

    background: #fff;

    font: inherit;

    text-align: right;

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.kpis-kpis-input:focus {
    border-color: #1976d2;

    box-shadow:
        0 0 0 2px rgba(25, 118, 210, 0.12);
}


/* =========================================================
   READONLY VALUE TRONG EDIT MODE
========================================================= */

.kpis-readonly-value {
    display: block;

    min-height: 20px;

    white-space: nowrap;
}


/* =========================================================
   EMPTY
========================================================= */

.kpis-empty-row td {
    padding: 28px 12px;

    text-align: center;

    color: #888;
}


/* =========================================================
   ACTIONS
========================================================= */

.kpis-form-actions {
    display: flex;

    justify-content: flex-end;

    margin-top: 16px;
}


.kpis-edit-actions {
    display: flex;

    align-items: center;

    justify-content: flex-end;

    gap: 8px;
}


.kpis-form-actions button {
    min-height: 38px;

    padding: 0 16px;

    border-radius: 7px;

    font-size: 14px;
}


/* =========================================================
   HIDDEN
========================================================= */

.kpis-form-actions .hidden,
.hidden {
    display: none !important;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 1024px) {

    .kpis-info-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 640px) {

    .kpis-form-section {
        margin-top: 14px;
    }


    .kpis-info-grid {
        grid-template-columns: 1fr;

        gap: 8px;
    }


    .kpis-info-field {
        padding: 9px 10px;
    }


    .kpis-form-table {
        /*
           Cố ý giữ min-width.

           Mobile sẽ scroll ngang thay vì
           bóp méo bảng.
        */
        min-width: 980px;
    }


    .kpis-form-actions {
        justify-content: stretch;
    }


    .kpis-form-actions > button,
    .kpis-edit-actions {
        width: 100%;
    }


    .kpis-edit-actions button {
        flex: 1;
    }

}
