/* ============================================================
   Work Planner – Main Stylesheet
   ============================================================ */
:root {
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --font-th: 'Sarabun', 'Noto Sans Thai', 'Prompt', sans-serif;
}

* { box-sizing: border-box; }
body { font-family: var(--font-th), system-ui, sans-serif; background: #f1f5f9; font-size: 0.875rem; color: #1e293b; }

/* ===== LAYOUT ===== */
.wrapper { min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  transition: width 0.25s ease;
  overflow: hidden;
}
.sidebar-brand {
  padding: 1.25rem 1rem;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid #1e293b;
  white-space: nowrap;
}
.sidebar-brand i { color: var(--sidebar-active); }
.sidebar-nav { list-style: none; padding: 0.75rem 0; margin: 0; flex: 1; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 0;
  transition: all 0.15s;
  white-space: nowrap;
}
.sidebar-nav li a:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar-nav li a.active { color: #fff; background: rgba(59,130,246,0.2); border-right: 3px solid var(--sidebar-active); }
.sidebar-nav li a i { font-size: 1rem; flex-shrink: 0; }
.nav-section {
  padding: 1rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #1e293b;
  color: var(--sidebar-text);
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.page-content { min-height: calc(100vh - var(--topbar-height)); }

/* ===== AVATAR ===== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm { width: 28px !important; height: 28px !important; font-size: 0.7rem !important; }

/* ===== BADGE NOTIF ===== */
.badge-notif {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid #f1f5f9;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: 0.75rem;
}
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; margin-bottom: 0.25rem; }
.stat-label { font-size: 0.75rem; color: #64748b; }
.bg-primary-soft { background: #eff6ff; }
.bg-success-soft { background: #f0fdf4; }
.bg-danger-soft  { background: #fef2f2; }
.bg-warning-soft { background: #fffbeb; }

/* ===== PROJECT CARDS ===== */
.project-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
}
.project-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.project-card-bar { height: 4px; }

.project-card-item { border: 1px solid #e2e8f0; overflow: hidden; transition: box-shadow 0.15s, transform 0.15s; }
.project-card-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.card-top-bar { height: 4px; }

/* ===== COLOR DOT ===== */
.color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ===== COLOR SWATCHES ===== */
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #1e293b; transform: scale(1.1); box-shadow: 0 0 0 2px #fff inset; }
.color-none-swatch { background: #f1f5f9; color: #94a3b8; border-color: #cbd5e1; }

/* ===== PROGRESS ===== */
.progress { border-radius: 99px; background: #f1f5f9; }

/* ===== TABLES ===== */
.table th { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }

/* ===== NAV TABS ===== */
.nav-tabs .nav-link { color: #64748b; border: none; border-bottom: 2px solid transparent; padding: 0.625rem 1rem; }
.nav-tabs .nav-link:hover { color: #1e293b; }
.nav-tabs .nav-link.active { color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 600; }

/* ===== EXPORT CARDS ===== */
.export-card {
  background: #f8fafc;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
  padding: 1.5rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.export-card:hover { border-color: #3b82f6; background: #eff6ff; }
.export-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }

/* ===== STAT ROW ===== */
.stat-row { display: flex; justify-content: space-between; align-items: center; }

/* ===== GANTT POPUP ===== */
.gantt-popup { background:#fff; border-radius:8px; padding:8px 12px; font-size:0.8rem; box-shadow:0 4px 12px rgba(0,0,0,0.15); }
.gantt-popup h5 { font-size:0.9rem; margin-bottom:4px; }
.gantt-popup p { margin-bottom:2px; color:#64748b; }

/* Override frappe-gantt bar colors via JS */
.gantt .bar { border-radius: 4px; }
.gantt .bar-progress { border-radius: 4px; }
.gantt-container { padding: 0.5rem 0; }

/* ===== TEXT CLAMP ===== */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { width: 0; position: fixed; z-index: 1000; height: 100vh; }
  .sidebar.open { width: var(--sidebar-width); }
  .main-content { width: 100%; }
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .topbar, .btn, .modal, .nav-tabs, button, form { display: none !important; }
  .main-content { margin: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
  .page-break { page-break-after: always; }
}

/* ===== Gantt – ปิดการลากทั้งหมด ===== */
.gantt .bar-wrapper { cursor: default !important; }
.gantt .bar-wrapper .bar { cursor: default !important; }
.gantt .handle { display: none !important; }
