/* Task Management – shared modern theme (injected last into every HTML page by csrf.php) */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&display=swap");

:root {
  --primary-purple: #6366f1;
  --secondary-purple: #7c3aed;
  --light-purple: #eef0ff;
  --pastel-purple: #c7d2fe;
  --soft-purple: #e0e7ff;
  --t-ink: #1e293b;
  --t-muted: #64748b;
  --t-border: #e8ecf4;
  --t-radius: 18px;
  --t-shadow: 0 4px 24px rgba(79, 70, 229, .08);
  --t-shadow-lg: 0 14px 38px rgba(79, 70, 229, .18);
}

html { -webkit-font-smoothing: antialiased; }
body {
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, "Segoe UI", sans-serif !important;
  color: var(--t-ink);
  line-height: 1.55;
  background:
    radial-gradient(900px 420px at 100% -5%, #e0e7ff 0%, transparent 60%),
    radial-gradient(700px 400px at 0% 100%, #cffafe 0%, transparent 60%),
    #f6f8ff !important;
  background-attachment: fixed !important;
  min-height: 100vh;
}
::selection { background: rgba(79,70,229,.18); }
:focus-visible { outline: 3px solid rgba(79,70,229,.35); outline-offset: 2px; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c4cedd; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
h1, h2, h3, h4, h5, h6 { color: var(--t-ink); font-weight: 700; letter-spacing: -.015em; }
.text-muted { color: var(--t-muted) !important; }

/* ---------- Navbar ---------- */
.navbar, .app-navbar {
  position: sticky; top: 0; z-index: 1030;
  background: linear-gradient(90deg, #4f46e5, #7c3aed 55%, #0ea5e9) !important;
  box-shadow: 0 6px 22px rgba(79,70,229,.28) !important;
  padding-top: .4rem; padding-bottom: .4rem;
}
.navbar-brand { font-weight: 700; letter-spacing: -.01em; }
.navbar .nav-link { border-radius: 10px; padding: .45rem .8rem !important; color: rgba(255,255,255,.86) !important; transition: background .15s; }
.navbar .nav-link:hover { background: rgba(255,255,255,.16); color: #fff !important; }
.navbar .nav-link.active { background: rgba(255,255,255,.25); color: #fff !important; box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.nav-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.55); display: inline-flex; align-items: center; justify-content: center; }
.nav-avatar-ph { background: rgba(255,255,255,.2); color: #fff; }

/* ---------- Layout ---------- */
.app-main { padding: 24px 24px 48px; max-width: 1400px; margin: 0 auto; width: 100%; }
.card-lite, .card, .stat-card, .task-card, .search-container, .modal-content, .login-container {
  border-radius: var(--t-radius) !important;
}
.card-lite {
  background: #fff; border: 1px solid var(--t-border); box-shadow: var(--t-shadow); overflow: hidden;
}
.card-lite.table-responsive { overflow-x: auto; }
.card-lite .table { margin-bottom: 0; }
.filters { display: grid; grid-template-columns: 2fr 1.2fr 1.2fr 1.2fr auto auto auto; gap: 10px; padding: 14px; align-items: center; overflow: visible; }

/* ---------- Unified page header & containers ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head h4 { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; }
.page-head h4 i { width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; color: #fff; background: linear-gradient(135deg, #6366f1, #7c3aed); box-shadow: 0 6px 14px rgba(79,70,229,.28); }
.page-head small { display: block; margin-top: 2px; }
.app-main > .alert:first-child, .app-main .alert { margin-bottom: 16px; }
.app-main section, .app-main .search-container { margin-bottom: 20px; }
.app-narrow { max-width: 900px; }

/* ---------- Profile pages ---------- */
.profile-card {
  background: #fff !important; border: 1px solid var(--t-border) !important; border-radius: var(--t-radius) !important;
  box-shadow: var(--t-shadow) !important; padding: 32px !important; margin-top: 0 !important;
}
.profile-card h4 { font-size: 1.25rem; }
.profile-image-container { border: 4px solid #6366f1 !important; background: #eef0ff !important; box-shadow: 0 8px 22px rgba(79,70,229,.25); color: #6366f1; }
.floating-back-btn { background: linear-gradient(135deg, #6366f1, #4f46e5) !important; color: #fff !important; border-radius: 999px !important; box-shadow: 0 8px 20px rgba(79,70,229,.3) !important; }

/* ---------- Dashboard blocks ---------- */
.task-card {
  background: #fff !important; border: 1px solid var(--t-border) !important;
  box-shadow: var(--t-shadow) !important; transition: transform .2s ease, box-shadow .2s ease;
}
.task-card { margin-bottom: 14px; padding: 20px !important; }
.task-card:hover { transform: translateY(-3px); box-shadow: var(--t-shadow-lg) !important; }

/* Stat cards keep their coloured gradient with white numbers (modern palette) */
.stat-card {
  border: 0 !important; color: #fff !important; position: relative; overflow: hidden;
  box-shadow: 0 10px 26px rgba(79,70,229,.18) !important;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.14); pointer-events: none; }
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(79,70,229,.28) !important; }
.stat-card.total-tasks, .stat-card.total { background: linear-gradient(135deg, #6366f1, #8b5cf6) !important; }
.stat-card.employees { background: linear-gradient(135deg, #0ea5e9, #38bdf8) !important; }
.stat-card.completed { background: linear-gradient(135deg, #10b981, #34d399) !important; }
.stat-card.pending { background: linear-gradient(135deg, #f59e0b, #fbbf24) !important; }
.stat-card.in-progress { background: linear-gradient(135deg, #0ea5e9, #6366f1) !important; }
.stat-card.overdue { background: linear-gradient(135deg, #f43f5e, #fb7185) !important; }
.stat-number { color: #fff !important; letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-shadow: 0 2px 6px rgba(0,0,0,.12) !important; }
.stat-label { color: rgba(255,255,255,.92) !important; font-weight: 600; }
.stat-card .stat-icon, .stat-card i { color: rgba(255,255,255,.95); }
.task-card.completed { background: linear-gradient(180deg, #fff, #f0fdf8) !important; }
.search-container { background: #fff !important; border: 1px solid var(--t-border); box-shadow: var(--t-shadow) !important; }
.progress { background: #eef0ff; border-radius: 999px; overflow: hidden; }
.progress-bar { background: linear-gradient(90deg, #6366f1, #0ea5e9) !important; border-radius: 999px; }

/* ---------- Forms & buttons ---------- */
.form-label { font-weight: 600; font-size: .9rem; color: #334155; }
.form-control, .form-select {
  border: 1px solid #d6ddea !important; border-radius: 12px !important; min-height: 42px; box-shadow: none !important;
  transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { min-height: auto; }
.form-control:focus, .form-select:focus { border-color: #818cf8 !important; box-shadow: 0 0 0 4px rgba(99,102,241,.16) !important; }
.form-check-input:checked { background-color: #4f46e5; border-color: #4f46e5; }
.form-range::-webkit-slider-thumb { background: #4f46e5; }
.btn { border-radius: 12px !important; font-weight: 600; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary, .btn-login { background: linear-gradient(135deg, #6366f1, #4f46e5) !important; border-color: transparent !important; box-shadow: 0 6px 16px rgba(79,70,229,.25); color: #fff !important; }
.btn-primary:hover, .btn-login:hover { background: linear-gradient(135deg, #4f46e5, #4338ca) !important; box-shadow: 0 8px 20px rgba(79,70,229,.35); }
.btn-success { background: linear-gradient(135deg, #34d399, #10b981) !important; border-color: transparent !important; color: #fff !important; }
.btn-danger { background: linear-gradient(135deg, #fb7185, #f43f5e) !important; border-color: transparent !important; }
.btn-warning { background: linear-gradient(135deg, #fbbf24, #f59e0b) !important; border-color: transparent !important; color: #3b2a00 !important; }
.btn-outline-secondary { border-color: #cfd8e6; color: #475467; }
.btn-outline-secondary:hover { background: #f1f2ff; color: var(--t-ink); border-color: #b9c5d8; }
.btn-sm { border-radius: 9px !important; }

/* ---------- Tables, badges, alerts, modals ---------- */
.table { --bs-table-bg: transparent; color: var(--t-ink); }
.table thead th { background: #eef0ff; color: #4f46e5; border-color: #dfe3fb; font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.table tbody td { border-color: #edf0f7; vertical-align: middle; }
.table-hover tbody tr:hover > * { background: #f5f6ff; }
.tbadge { display: inline-block; padding: .3em .75em; border-radius: 999px; font-size: .78rem; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); border: 1px solid color-mix(in srgb, var(--c) 30%, #fff); white-space: nowrap; }
.badge { border-radius: 999px; padding: .42em .75em; font-weight: 600; }
.alert { border: 0 !important; border-radius: 14px !important; }
.modal-content { border: 0 !important; box-shadow: 0 24px 70px rgba(30,27,75,.3); }
.modal-header { background: #f3f4ff; border-bottom-color: var(--t-border); border-radius: var(--t-radius) var(--t-radius) 0 0; }
.modal-footer { border-top-color: var(--t-border); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 8px; bottom: 8px; width: 2px; background: #e0e7ff; }
.timeline li { position: relative; display: flex; gap: 14px; padding: 8px 0; }
.tl-icon { z-index: 1; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #eef0ff; color: #4f46e5; font-size: .8rem; border: 2px solid #fff; }
.tl-comment .tl-icon { background: #4f46e5; color: #fff; }
.tl-progress .tl-icon { background: #d1fae5; color: #059669; }

/* ---------- Reports ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--t-border); border-top: 4px solid #6366f1; border-radius: 16px; padding: 14px 16px; box-shadow: var(--t-shadow); display: flex; flex-direction: column; gap: 4px; }
.kpi span { color: var(--t-muted); font-size: .8rem; font-weight: 600; }
.kpi strong { font-size: 1.7rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 280px; }
@media (max-width: 991.98px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 575.98px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Manager overview ---------- */
.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.boss-filters { grid-template-columns: 2fr 1.4fr 1.2fr 1.2fr auto auto auto; }
.boss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.person summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.person summary::-webkit-details-marker { display: none; }
.person summary::after { content: "\f078"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: .7rem; color: var(--t-muted); transition: transform .2s; }
.person[open] summary::after { transform: rotate(180deg); }
.person[open] summary { border-bottom: 1px solid var(--t-border); }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: 0 0 42px; }
.avatar-ph { display: inline-flex; align-items: center; justify-content: center; background: #eef0ff; color: #4f46e5; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.person-bar { padding: 10px 16px 6px; }
.task-list { list-style: none; margin: 0; padding: 6px 16px 14px; max-height: 420px; overflow-y: auto; }
.task-list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--t-border); }
.task-list li:last-child { border-bottom: 0; }
.min-w-0 { min-width: 0; }
@media (max-width: 991.98px) { .kpi-5 { grid-template-columns: repeat(3, 1fr); } .boss-filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 575.98px) { .kpi-5 { grid-template-columns: repeat(2, 1fr); } .boss-filters { grid-template-columns: 1fr; } .boss-grid { grid-template-columns: 1fr; } }
@media print { .no-print, .navbar { display: none !important; } body { background: #fff !important; } .card-lite, .kpi { box-shadow: none !important; break-inside: avoid; } .person { page-break-inside: avoid; } details:not([open]) > :not(summary) { display: block; } }

/* ---------- Subtasks / files ---------- */
.subtask-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--t-border); }
.subtask-row:last-of-type { border-bottom: 0; }
.subtask-check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #cbd5e1; background: #fff; color: transparent; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; padding: 0; transition: .15s; }
.subtask-check:hover { border-color: #6366f1; }
.subtask-check.done { background: #10b981; border-color: #10b981; color: #fff; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kcol { background: rgba(255,255,255,.65); backdrop-filter: blur(8px); border: 1px solid var(--t-border); border-top: 4px solid var(--c); border-radius: 16px; padding: 12px; min-height: 220px; transition: box-shadow .15s, background .15s; }
.kcol.over { background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent); }
.kcol header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.kcount { background: color-mix(in srgb, var(--c) 16%, #fff); color: var(--c); border-radius: 999px; padding: 0 .6em; font-size: .8rem; }
.kdrop { display: flex; flex-direction: column; gap: 10px; min-height: 140px; }
.kcard { background: #fff; border: 1px solid var(--t-border); border-radius: 14px; padding: 12px; box-shadow: var(--t-shadow); cursor: grab; transition: transform .15s, box-shadow .15s; }
.kcard:hover { transform: translateY(-2px); box-shadow: var(--t-shadow-lg); }
.kcard.dragging { opacity: .45; cursor: grabbing; }
.ktitle { display: block; color: var(--t-ink); font-weight: 600; text-decoration: none; margin-bottom: 8px; }
.kmeta { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; }
.toast-lite { position: fixed; right: 20px; bottom: 20px; padding: 10px 18px; border-radius: 12px; color: #fff; font-weight: 600; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 2000; }
.toast-lite.show { opacity: 1; transform: none; }
.toast-lite.ok { background: #10b981; } .toast-lite.err { background: #f43f5e; }

/* ---------- Login ---------- */
body:has(.login-container) {
  background:
    radial-gradient(600px 400px at 10% 10%, rgba(244,114,182,.45), transparent 60%),
    radial-gradient(700px 500px at 95% 15%, rgba(56,189,248,.5), transparent 60%),
    radial-gradient(700px 500px at 60% 100%, rgba(167,139,250,.55), transparent 60%),
    linear-gradient(135deg, #6366f1, #7c3aed 55%, #0ea5e9) !important;
  background-attachment: fixed !important;
}
.login-container { box-shadow: 0 24px 70px rgba(30,27,75,.35) !important; border: 0 !important; }
.login-container .nav-tabs { border-bottom: 0; gap: 10px; }
.login-container .nav-tabs .nav-link { border: 2px solid var(--t-border) !important; border-radius: 12px !important; color: #475467 !important; background: #fff !important; font-weight: 600; transition: .15s; }
.login-container .nav-tabs .nav-link:hover { border-color: #a5b4fc !important; color: #4f46e5 !important; }
.login-container .nav-tabs .nav-link.active { background: linear-gradient(135deg, #6366f1, #4f46e5) !important; border-color: transparent !important; color: #fff !important; box-shadow: 0 6px 16px rgba(79,70,229,.3); }
.login-container .nav-tabs .nav-link.active i { color: #fff !important; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .btn, .filters .form-check { grid-column: auto; }
}
@media (max-width: 575.98px) {
  .app-main { padding: 14px 10px 30px; }
  .filters { grid-template-columns: 1fr; }
  .kanban { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
