/* =====================================================================
   ระบบบริหารโปรเจกต์ - Neumorphism (Soft UI) Design System
   โทนสี: Neutral / Mono พร้อมสีเน้นสำหรับสถานะ/ความสำคัญเท่านั้น
   ===================================================================== */

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

:root {
  /* --- Neumorphism base (Light) --- */
  --bg: #e6e7ee;
  --bg-elevated: #e6e7ee;
  --surface: #e6e7ee;
  --text-main: #3b3f4a;
  --text-muted: #7b8190;
  --text-faint: #9aa0ad;
  --shadow-light: #ffffff;
  --shadow-dark: #b8bac2;
  --accent: #6366f1;
  --accent-soft: #eef0fd;
  --border-soft: rgba(0,0,0,0.04);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-raised: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
  --shadow-raised-sm: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  --shadow-pressed: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  --shadow-flat: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
}

html[data-theme="dark"] {
  --bg: #2b2e36;
  --bg-elevated: #2b2e36;
  --surface: #2b2e36;
  --text-main: #e4e6eb;
  --text-muted: #a3a8b5;
  --text-faint: #767b88;
  --shadow-light: #34373f;
  --shadow-dark: #202228;
  --accent: #818cf8;
  --accent-soft: #363a54;
  --border-soft: rgba(255,255,255,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  transition: background .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--shadow-dark); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Neumorphic primitives ---------- */
.neu-flat {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-flat);
}
.neu-raised {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}
.neu-pressed {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pressed);
}
.neu-btn {
  background: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-raised-sm);
  color: var(--text-main);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 500;
  transition: box-shadow .15s ease, transform .1s ease;
}
.neu-btn:hover { box-shadow: var(--shadow-raised); }
.neu-btn:active, .neu-btn.active { box-shadow: var(--shadow-pressed); transform: translateY(1px); }
.neu-btn.primary { color: var(--accent); font-weight: 600; }
.neu-btn.danger { color: #ef4444; }
.neu-btn:disabled { opacity: .5; cursor: not-allowed; }

.neu-input {
  width: 100%;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pressed);
  padding: 12px 16px;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  font-size: 14px;
}
.neu-input::placeholder { color: var(--text-faint); }
.neu-input:focus { box-shadow: var(--shadow-pressed), 0 0 0 2px var(--accent); }

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  margin: 14px;
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: width .2s ease, padding .2s ease;
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  overflow-y: auto;
}
.sidebar.collapsed { width: 78px; padding: 20px 10px; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .group-list { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow-raised-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 700; flex-shrink: 0;
}
.brand-text { font-weight: 700; font-size: 16px; white-space: nowrap; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 14px;
  cursor: pointer; white-space: nowrap;
}
.nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.nav-item.active { box-shadow: var(--shadow-pressed); color: var(--accent); }
.nav-item .icon { width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin: 16px 10px 6px;
}

.main-area { flex: 1; min-width: 0; padding: 14px 14px 14px 0; }

.topbar {
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  border-radius: var(--radius-lg);
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-muted); }
.breadcrumb .sep { color: var(--text-faint); }
.breadcrumb .current { color: var(--text-main); font-weight: 600; }

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

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow-raised-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); border: none; cursor: pointer; position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn:active { box-shadow: var(--shadow-pressed); }

.badge-dot {
  position: absolute; top: 6px; right: 6px;
  background: #ef4444; color: #fff; font-size: 10px;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

.avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.content-card {
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ---------- Buttons row / page header ---------- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---------- Dashboard stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); box-shadow: var(--shadow-raised); border-radius: var(--radius-md); padding: 18px 20px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-size: 18px; }

/* ---------- Kanban board ---------- */
.kanban-scroll { overflow-x: auto; padding-bottom: 10px; }
.kanban-columns { display: flex; gap: 16px; align-items: flex-start; min-height: 60vh; }
.kanban-column {
  width: 290px; flex-shrink: 0;
  background: var(--surface); box-shadow: var(--shadow-raised);
  border-radius: var(--radius-md); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 220px);
}
.kanban-column-header { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; }
.kanban-column-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.column-count { background: var(--bg); box-shadow: var(--shadow-pressed); border-radius: 8px; font-size: 11px; padding: 2px 8px; color: var(--text-muted); }

.kanban-cards { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 2px; min-height: 40px; }
.kanban-cards.drag-over { background: var(--accent-soft); border-radius: var(--radius-sm); }

.kanban-card {
  background: var(--surface); box-shadow: var(--shadow-raised-sm);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: grab;
  display: flex; flex-direction: column; gap: 8px;
}
.kanban-card:hover { box-shadow: var(--shadow-raised); }
.kanban-card.dragging { opacity: .4; }
.kanban-card-title { font-weight: 500; font-size: 13.5px; line-height: 1.4; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.priority-tag { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 8px; }
.due-tag { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.due-tag.overdue { color: #ef4444; font-weight: 600; }
.card-footer-row { display: flex; align-items: center; justify-content: space-between; }
.mini-avatar { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.attach-count { font-size: 11px; color: var(--text-faint); display: flex; align-items: center; gap: 3px; }

.add-card-btn {
  background: transparent; border: 1.5px dashed var(--shadow-dark);
  border-radius: var(--radius-sm); padding: 10px; text-align: center;
  color: var(--text-faint); cursor: pointer; font-size: 13px;
}
.add-card-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data-table td { padding: 12px; border-top: 1px solid var(--border-soft); }
table.data-table tr:hover td { background: var(--accent-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,20,25,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-raised);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 26px;
}
.modal-box.wide { max-width: 780px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-title { font-size: 18px; font-weight: 700; }

/* ---------- Chat / comments ---------- */
.comment-item { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-bubble { background: var(--bg); box-shadow: var(--shadow-pressed); border-radius: var(--radius-sm); padding: 10px 14px; flex: 1; }
.comment-author { font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.comment-time { color: var(--text-faint); font-size: 11px; }

/* ---------- Login page ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.auth-box { width: 100%; max-width: 400px; background: var(--surface); box-shadow: var(--shadow-raised); border-radius: var(--radius-lg); padding: 36px 32px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; } .mb-14 { margin-bottom: 14px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }

.flash-msg { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-flat); }
.flash-success { color: #16a34a; }
.flash-error { color: #ef4444; }
.flash-warning { color: #d97706; }
.flash-info { color: var(--accent); }

/* print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-area { padding: 0 !important; }
  body { background: #fff !important; }
  .content-card { box-shadow: none !important; }
}

/* responsive */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 60; left: -300px; transition: left .2s ease; margin: 10px; height: calc(100vh - 20px); }
  .sidebar.mobile-open { left: 0; }
  .main-area { padding: 10px; }
  .kanban-column { width: 260px; }
}
