/* ===================================================
   UNIVIET CRM - DASHBOARD EXECUTIVE STYLING
   Tối ưu layout cân đối trên màn hình & Chuẩn in ấn PDF chuyên nghiệp
   =================================================== */

.dash-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* 4 Thẻ KPI trên cùng: 4 cột đều nhau, tự co dãn */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1280px) {
  .dash-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

@media (max-width: 640px) {
  .dash-kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Khung 2 cột chính: Cột trái 62%, Cột phải 38% */
.dash-main-grid {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 18px;
  width: 100%;
  box-sizing: border-box;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .dash-main-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Card chuẩn đồng bộ với thiết kế của Univiet: Dòng chảy tự nhiên từ trên xuống dưới */
.dash-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.dash-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

/* Nút bấm ở cuối card tự động neo đáy mà không làm dạt các phần tử trên */
.dash-card-footer {
  margin-top: auto;
  padding-top: 16px;
}

/* Header card bar */
.dash-header-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .dash-header-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Bảng xếp hạng thi đua */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.dash-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.dash-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.dash-table tr:hover td {
  background: #f8fafc;
}

/* Progress bar cho phễu và kênh */
.dash-progress-track {
  width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.dash-progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Deal card item */
.dash-deal-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.dash-deal-item:hover {
  background: #f0f7ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

/* ===================================================
   CHUYÊN DÙNG CHO IN ẤN / XUẤT FILE PDF (@media print)
   Khử hoàn toàn thanh cuộn, chống cắt trang và căn chỉnh hoàn hảo
   =================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* 1. Mở khóa triệt để toàn bộ các container cha */
  html, body, #root, #root > div, main, .dash-container {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
    position: static !important;
    display: block !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  /* 2. Khử thanh cuộn trong print */
  ::-webkit-scrollbar {
    display: none !important;
  }

  /* 3. Ẩn sidebar, nút bấm điều hướng, nút mở trang */
  aside,
  header,
  .no-print,
  .print\:hidden,
  .dash-card-footer,
  button {
    display: none !important;
  }

  /* 4. Thẻ Header tinh gọn khi in */
  .dash-header-card {
    border: 1px solid #cbd5e1 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    padding: 10px 14px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    break-after: avoid !important;
    page-break-after: avoid !important;
  }

  /* 5. 4 Thẻ KPI: Giữ nguyên 4 cột nằm gọn trên 1 hàng ngang */
  .dash-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
    break-after: avoid !important;
    page-break-after: avoid !important;
  }

  .dash-kpi-grid .dash-card {
    padding: 10px 12px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
  }

  .dash-kpi-grid .dash-card .text-2xl {
    font-size: 1.15rem !important;
    line-height: 1.25 !important;
  }

  /* 6. Layout 2 cột: Cột trái 60%, Cột phải 40% nằm cạnh nhau */
  .dash-main-grid {
    display: grid !important;
    grid-template-columns: 1.55fr 1fr !important;
    gap: 12px !important;
    margin-bottom: 14px !important;
    align-items: start !important;
  }

  .dash-card {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 10px !important;
    padding: 12px 14px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* 7. Bảng xếp hạng in đầy đủ mọi nhân sự, không có thanh cuộn */
  .overflow-x-auto, .overflow-y-auto {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }

  .dash-table {
    font-size: 11px !important;
  }

  .dash-table th {
    padding: 6px 8px !important;
    background: #f1f5f9 !important;
    border-bottom: 1px solid #cbd5e1 !important;
  }

  .dash-table td {
    padding: 6px 8px !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }

  .dash-table tr {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* 8. Deal items khi in */
  .dash-deal-item {
    padding: 8px 10px !important;
    border-radius: 8px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}
