@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Sarabun:wght@400;600;700&display=swap');

:root {
  --bg: #0a0f1a;
  --panel: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #0b4aa2;
  --brand-700: #083a80;
  --line: #e2e8f0;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  font-family: Inter, Sarabun, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
  background: #f5f7fb;
  color: var(--text);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0d2c66, #0b4aa2 60%, #0d2c66);
  color: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.user-chip {
    width: fit-content !important;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* ซ่อน quickbar บนเดสก์ท็อป */
.mobile-quickbar{ display:none; }

/* แสดงเฉพาะมือถือ */
@media (max-width: 768px){
  .mobile-quickbar{
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 9999;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 12px rgba(17, 12, 46, 0.08);
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-quickbar .mq-scroll{
    display: flex;
    justify-content: space-around;
    width: 100%;
    padding: 0;
  }

  .mobile-quickbar .mq-item{
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: #374151;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    position: relative;
    transition: all .2s ease;
  }

  .mobile-quickbar .mq-item.active{
    color: #4f46e5;
  }

  .mobile-quickbar .mq-item.primary{
    background: linear-gradient(135deg,#6366f1,#8b5cf6);
    color: #fff;
    border-radius: 12px;
    padding: 6px 8px;
    margin: 0 4px;
  }

  .mobile-quickbar .mq-icon{
    font-size: 20px;
    line-height: 1;
    margin-bottom: 4px;
  }

  .mobile-quickbar .mq-badge{
    position: absolute;
    top: 4px;
    right: 20px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    border-radius: 999px;
    padding: 2px 5px;
    line-height: 1;
  }

  /* ซ่อน sidebar */
  .sidebar{ display:none; }

  /* ให้ main/content เต็มจอ และกันโดนทับ */
  .main, .content{
    margin: 0 !important;
    padding-bottom: 80px !important; /* เผื่อพื้นที่ quickbar */
  }
}

/* --- แสดงโลโก้เฉพาะมือถือ --- */
.mobile-logo {
  display: none; /* ซ่อนโลโก้บน Desktop */
  align-items: center;
  gap: 8px;
}
.mobile-logo img {
  width: 100%;
  height: 50px;
  object-fit: contain;
}

/* แสดงโลโก้เมื่อเป็นมือถือ */
@media (max-width: 768px) {
  .mobile-logo {
    display: flex;
  }

  /* ปรับโครงสร้าง Header ให้โลโก้อยู่ซ้ายสุด */
  .topbar {
    /* flex-wrap: wrap; */
    gap: 6px;
    align-items: flex-start;
  }

  /* จัดปุ่มไปด้านขวาในบรรทัดถัดไป */
  .actions {
    width: 100%;
    justify-content: flex-end;
  }
}



.brand {
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
}

.brand img {
  width: 100%;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.company .title {
  font-weight: 700;
}

.company .sub {
  font-size: 12px;
  opacity: .8
}

.nav {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #dbeafe;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .08)
}

.nav-item.active {
  background: #fff;
  color: var(--brand);
}

.nav-item .icon {
  width: 40px;
  text-align: center
}

.bg-lab {
  background-image: url("assets/img/science-lab-bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.bg-lab::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3); /* เงามืดบางๆ เพื่อให้ข้อความอ่านง่าย */
  backdrop-filter: blur(2px);
}
.bg-lab * {
  position: relative;
  z-index: 1;
}

.nav-bottom {
  margin-top: auto
}

.nav-item.muted {
  color: #c7d2fe
}

.badge {
  background: #e0e7ff;
  color: #1e3a8a;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 8px
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .spacer {
  flex: 1
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px
}

.btn {
  /* background: #e2e8f0; */
  color: #0f172a;
  padding: 5px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid #cbd5e1
}

.btn:hover {
  filter: brightness(.98)
}

.btn.primary {
  background: #1d4ed8;
  color: #fff;
  border-color: #1d4ed8
}

.btn.ghost {
  background: transparent;
  border-color: #cbd5e1
}

.card{ position:relative; overflow:hidden; }
.card canvas{
  position:absolute; left:0; right:0; bottom:-6px;
  width:100%; height:70px; opacity:.75; pointer-events:none;
}


.icon {
  background: transparent;
  /* border: 1px solid #cbd5e1; */
  /* border-radius: 10px; */
  padding: 8px 10px;
  font-size: 16px
}

button.btn.btn-delete {
  background-color: red !important;
  color: wheat;
}

button.btn.btn-delete:hover {
    background: #eef2ff !important;
  color: black;

}

button.btn.btn-download {
  background: #509cdb !important;
  border: 1px solid #e5e7eb;
    color: #fff !important;

}


button.btn.btn-download:hover {
  background: #fff !important;
  border: 1px solid #e5e7eb;
  color: #000 !important;
}

.logout {
  color: #ef4444;
  font-weight: 600;
  margin-left: 4px;
  text-decoration: none
}

.content {
  padding: 20px 20px 80px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px
}

.input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 220px;
  background: #fff
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
      margin-bottom: 20px;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px
}

.table th {
  color: #334155;
  background: #f8fafc
}

.table tr:nth-child(even) {
  background: #fafafa
}

.status.btn {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: none;
  cursor: pointer
}

.status.warn {
  background: #fef3c7;
  color: #a16207
}

.status.danger {
  background: #fee2e2;
  color: #991b1b
}

/* .status.info {
  background: #f5f00b;
  color: #1d4ed8;
  color: #ffffff;
  border-radius: 5px;
  border-color: #f5f00b;
} */



.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #1d4ed8;
  color: #fff;
  border: none;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  font-size: 28px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .15)
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px
}

.detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px
}

.detail img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line)
}

.muted {
  color: var(--muted)
}

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px;
  font-size: 14px
}

.progress {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden
}

.progress>span {
  display: block;
  height: 100%;
  background: #10b981
}

.empty {
  display: grid;
  place-items: center;
  height: 420px;
  color: #64748b
}

.login-wrap {
  display: grid;
  place-items: center;
  height: 100vh
}

.login {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  width: 360px
}

.login h1 {
  margin: 8px 0 16px
}

.login .input {
  width: 100%
}

.login .btn {
  width: 100%;
  margin-top: 10px;
  background: #1d4ed8;
  color: #fff;
  border-color: #1d4ed8
}

.small {
  font-size: 12px
}

.status.danger {
  background: #ff0000;
  color: #ffffff;
  border-radius: 5px;
  /* padding: 2px; */
  border-color: red;
}

button.status.info {
  background: #509CDB;
  color: #fff;
  border-radius: 5px;
  border-color: #509CDB;
}

.btn-download {
  background: #509CDB;
  color: #fff;
  border-radius: 5px;
  border-color: #509CDB;
}

.btn-delete {
  background: #ff0000 !important;
  color: #ffffff;
  border-radius: 5px;
  /* padding: 2px; */
}

.form.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 800px;
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.input,
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.col-span-2 {
  grid-column: span 2;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.btn.primary {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
}

.btn:hover {
  opacity: 0.9;
}

.small {
  font-size: 12px;
  color: #6b7280;
}

.nav-item.active {
  background: #fff;
  color: #0b4aa2;
  font-weight: 600;
  border-radius: 8px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
}


.progress-bar {
  background: #e5e7eb;
  /* เทาอ่อน */
  border-radius: 6px;
  overflow: hidden;
  width: 120px;
  /* กำหนดความกว้าง bar */
  height: 20px;
}

.progress-fill {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  /* น้ำเงิน gradient */
  height: 100%;
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 20px;
  transition: width 0.3s ease;
}

.user-chip {
  width: 100% !important;
  display: flex;
  align-items: center;
  gap: 8px
}

.user-chip {
  /* width: 28px !important; */
  height: 28px;
  border-radius: 50%;
  object-fit: cover
}

.report-head {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px
}

.report-head .back {
  text-decoration: none;
  color: #0b4aa2
}

.report-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 2px
}

.report-date {
  color: #6b7280;
  font-size: 12px
}

.report-wrap {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 28px;
  margin-top: 12px
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.hero {
  width: 100%;
  aspect-ratio: 16/9;
  background: #f3f4f6;
  border-radius: 10px;
  object-fit: cover
}

.thumbs {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap
}

.thumbs img {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent
}

.thumbs img.active {
  border-color: #2563eb
}

.section-title {
  font-weight: 700;
  margin: 0 0 10px
}

.desc {
  color: #374151;
  line-height: 1.7;
  white-space: pre-wrap
}

.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px
}

.meta-item {
  background: #f9fafb;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  padding: 12px
}

.meta-item .label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px
}

.meta-item .value {
  font-weight: 600
}

.progress-bar {
  background: #e5e7eb;
  border-radius: 999px;
  height: 20px;
  overflow: hidden
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  width: 0;
  transition: width .35s
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px
}

.user-box img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover
}

.user-box .name {
  font-weight: 600
}

.small-muted {
  color: #6b7280;
  font-size: 12px;
  padding-top: 10px !important;

}

@media (max-width: 980px) {
  .report-wrap {
    grid-template-columns: 1fr;
    gap: 16px
  }
}

/* ============== MOBILE FIRST ============== */
@media (max-width: 768px) {
  /* 1) การ์ดสรุป — เรียง 1 คอลัมน์ (อ่านง่าย) */
  .summary{
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .summary .card{
    padding: 14px !important;
    border-radius: 14px !important;
  }
  .summary .card .metric{ font-size: 22px !important; }

  /* mini chart ในการ์ดให้เตี้ยลงนิดนึง */
  #mini1, #mini2, #mini3, #mini4 { height: 50px !important; }

  /* 2) กราฟ — เรียงซ้อนเป็น 1 คอลัมน์ และเพิ่มพื้นที่สัมผัส */
  .charts{
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .panel{
    padding: 12px !important;
    border-radius: 12px !important;
  }
  /* ความสูงกราฟให้พอดีจอ */
  #lineMonthly{ height: 200px !important; }
  #pieCat{ height: 200px !important; }

  /* เลเจนด์โดนัทให้ขึ้นบรรทัดใหม่และเว้นระยะ */
  .donut-legend{
    gap: 16px !important;
    margin-top: 8px !important;
  }
  .legend-item .val strong{ font-size: 18px !important; }

  /* 3) ตาราง — ทำให้พอดีกับจอโดย “ซ่อนคอลัมน์ที่กว้าง” */
  /* โครงสร้างคอลัมน์ปัจจุบัน:
     1 ชื่อโครงการ | 2 บริษัท | 3 ผู้ติดต่อ | 4 หมวดหมู่ | 5 ความคืบหน้า
     6 เริ่ม-สิ้นสุดโครงการ | 7 ไฟล์/รูปภาพ | 8 วันที่
     -> บนมือถือซ่อน (2,3,7) เพื่อลดความกว้าง แต่ยังคงคอลัมน์สำคัญไว้
  */
  .table thead th:nth-child(2),
  .table thead th:nth-child(3),
  .table thead th:nth-child(7),
  .table tbody td:nth-child(2),
  .table tbody td:nth-child(3),
  .table tbody td:nth-child(7){
    display: none !important;
  }

  /* ขยายระยะห่างระหว่างแถวให้อ่านง่ายขึ้น */
  .table td{ padding: 10px 8px !important; }

  /* ถ้าตารางยังล้น ให้ตัดคำยาว (เช่น ชื่อโครงการยาวๆ) */
  .table td:nth-child(1) a{
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }



}

/* ============== VERY SMALL PHONES (<= 480px) ============== */
@media (max-width: 480px){
  .summary .card .metric{ font-size: 20px !important; }
  .styled-table thead th, .styled-table td{ padding: 10px 12px !important; }
  #lineMonthly, #pieCat{ height: 180px !important; }
}
