/*
 * TaskFlow PM – app.css
 * Layout, sidebar, cards, custom components
 */

/* ─── CSS Variables ─────────────────────────────────── */
:root {
  --tf-header-height: 60px;
  --tf-sidebar-left-width: 240px;
  --tf-sidebar-right-width: 280px;
  --tf-footer-height: 44px;
  --tf-primary: #0d6efd;
  --tf-bg: #f8f9fa;
  --tf-sidebar-bg: #1e2a3a;
  --tf-sidebar-text: #c9d1d9;
  --tf-sidebar-active: #0d6efd;
  --tf-header-bg: #ffffff;
  --tf-header-border: #e9ecef;
  --tf-body-bg: #f2f4f7;
}

/* ─── Base Layout ───────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--tf-body-bg);
  overflow-x: hidden;
}

/* ─── Header ─────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tf-header-height);
  background: var(--tf-header-bg);
  border-bottom: 1px solid var(--tf-header-border);
  z-index: 1030;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.header-logo,
.app-header .brand-logo {
  height: 32px;
  max-width: 160px;
  object-fit: contain;
}

.header-brand,
.app-header .brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--tf-primary);
  text-decoration: none;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right .dropdown > .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

@media (max-width: 576px) {
  .app-header { padding: 0 .75rem; }
  .header-left { gap: .5rem; }
  .header-right { gap: .35rem; }
  .header-right .dropdown > .btn { padding-left: .55rem; padding-right: .55rem; }
}

/* ─── Body wrapper ───────────────────────────────────── */
.app-body {
  display: flex;
  padding-top: var(--tf-header-height);
  min-height: 100vh;
}

/* ─── Left Sidebar ───────────────────────────────────── */
.sidebar-left {
  position: fixed;
  top: var(--tf-header-height);
  left: 0;
  width: var(--tf-sidebar-left-width);
  height: calc(100vh - var(--tf-header-height));
  background: var(--tf-sidebar-bg);
  color: var(--tf-sidebar-text);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1020;
  transition: width .25s ease, transform .25s ease;
  flex-shrink: 0;
}

.sidebar-left::-webkit-scrollbar { width: 4px; }
.sidebar-left::-webkit-scrollbar-track { background: transparent; }
.sidebar-left::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

/* Nav items */
.sidebar-left .nav-section {
  padding: .5rem 1rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  margin-top: .75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1rem;
  color: var(--tf-sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--tf-sidebar-active);
  color: #fff;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #fff;
  border-radius: 0 3px 3px 0;
}

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: .9rem; }
.nav-label { flex: 1; }
.nav-arrow { font-size: .7rem; color: rgba(255,255,255,.4); transition: transform .2s; }
.sidebar-link.open .nav-arrow { transform: rotate(180deg); }

.sidebar-submenu {
  display: none;
  background: rgba(0,0,0,.15);
}
.sidebar-submenu.show { display: block; }
.sidebar-submenu .sidebar-link {
  padding-left: 2.5rem;
  font-size: .825rem;
  font-weight: 400;
}

/* ─── Main Content ───────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--tf-sidebar-left-width);
  margin-right: var(--tf-sidebar-right-width);
  padding: 1.5rem;
  min-height: calc(100vh - var(--tf-header-height));
  transition: margin-left .25s ease;
}

.sidebar-right-spacer {
  /* Keeps layout when sidebar-right is fixed */
  display: none;
}

/* ─── Right Sidebar ──────────────────────────────────── */
.sidebar-right {
  position: fixed;
  top: var(--tf-header-height);
  right: 0;
  width: var(--tf-sidebar-right-width);
  height: calc(100vh - var(--tf-header-height));
  background: #fff;
  border-left: 1px solid #e9ecef;
  overflow-y: auto;
  z-index: 1010;
  flex-shrink: 0;
}

.sidebar-right::-webkit-scrollbar { width: 4px; }
.sidebar-right::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 2px; }

/* Widget inside right sidebar */
.widget { border-bottom: 1px solid #e9ecef; }
.widget-header {
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #6c757d;
  background: #f8f9fa;
}
.widget-body { padding: 1rem; }

/* ─── Footer ─────────────────────────────────────────── */
.app-footer {
  background: #fff;
  border-top: 1px solid #e9ecef;
  padding: .6rem 1rem;
  font-size: .75rem;
  color: #adb5bd;
  text-align: center;
}

/* ─── Collapsed Sidebar ──────────────────────────────── */
body.sidebar-collapsed .sidebar-left { width: 58px; }
body.sidebar-collapsed .sidebar-left .nav-label,
body.sidebar-collapsed .sidebar-left .nav-arrow,
body.sidebar-collapsed .sidebar-left .nav-section { display: none; }
body.sidebar-collapsed .sidebar-left .sidebar-link { justify-content: center; padding: .6rem .5rem; }
body.sidebar-collapsed .sidebar-left .sidebar-submenu { display: none !important; }
body.sidebar-collapsed .main-content { margin-left: 58px; }

/* ─── Stat Cards ─────────────────────────────────────── */
.stat-card {
  border-radius: .75rem;
  border: none;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.1) !important; }
.stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6c757d;
  font-weight: 600;
  margin-bottom: .25rem;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.1;
}
.stat-trend { font-size: .72rem; color: #6c757d; }

/* ─── Page Header ─────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h4 { color: #1a1a2e; }

/* ─── Task Stack Board ───────────────────────────────── */
.stack-board { min-height: 400px; }
.stack-row { padding-bottom: 1rem; }
.col-stack { flex: 0 0 300px; }
.task-card { transition: box-shadow .15s, opacity .15s; }
.task-card:hover { box-shadow: 0 .25rem .75rem rgba(0,0,0,.12); }
.sortable-ghost { opacity: .4; background: #cfe2ff !important; }
.sortable-chosen { box-shadow: 0 .5rem 1rem rgba(0,0,0,.2); }

/* ─── Rating Badges ──────────────────────────────────── */
.rating-A  { background: #198754; color: #fff; }
.rating-B  { background: #0d6efd; color: #fff; }
.rating-C  { background: #ffc107; color: #000; }
.rating-D  { background: #dc3545; color: #fff; }
.rating-N  { background: #6c757d; color: #fff; }

/* ─── Project Tree ───────────────────────────────────── */
.project-tree { padding-left: 0; }
.project-tree-item { border-left: 2px solid #dee2e6; padding-left: .5rem; }
.project-tree-item .hover-bg { transition: background .1s; }
.project-tree-item .hover-bg:hover { background: #f0f4ff; border-radius: .375rem; }

/* ─── Heatmap Table ──────────────────────────────────── */
.heatmap-table td, .heatmap-table th { min-width: 30px; padding: 4px 2px; font-size: .72rem; }
.heatmap-table th { font-size: .68rem; font-weight: 600; }

/* ─── Avatar Placeholder ─────────────────────────────── */
.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
}

/* ─── Utility ─────────────────────────────────────────── */
.btn-xs { padding: .2rem .45rem; font-size: .75rem; }
.cursor-pointer { cursor: pointer; }
.hover-bg { transition: background .1s; }

/* ─── DataTables Overrides ───────────────────────────── */
table.dataTable thead th { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
table.dataTable tbody td { vertical-align: middle; }
.dataTables_wrapper .dataTables_filter input { border-radius: .375rem !important; }
.dataTables_wrapper .dataTables_length select { border-radius: .375rem !important; }

/* Add spacing when DataTables are mounted in card-body.p-0 containers */
.card .card-body.p-0 .dataTables_wrapper { padding: .9rem 1rem; }
.card .card-body.p-0 .dataTables_wrapper .table { margin-bottom: 0; }

/* ─── Login Page ─────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
}
.login-brand-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--tf-primary), #0a47a9);
  color: #fff;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}
.login-brand-side img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .2;
}
.login-form-side {
  width: 440px;
  min-width: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #fff;
}
@media (max-width: 768px) {
  .login-brand-side { display: none; }
  .login-form-side { width: 100%; }
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 1200px) {
  .sidebar-right { display: none; }
  .main-content { margin-right: 0; }
}

@media (max-width: 768px) {
  .sidebar-left { transform: translateX(-100%); }
  .sidebar-left.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  body.sidebar-collapsed .main-content { margin-left: 0; }
}

/* ─── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* ─── Page Color Override support ───────────────────── */
/* Injected inline by header.php per page */

/* ─── Animations ─────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeSlideIn .25s ease forwards; }

/* ─── Active task pulse ──────────────────────────────── */
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(25,135,84,.4); }
  70%  { box-shadow: 0 0 0 8px rgba(25,135,84,0); }
  100% { box-shadow: 0 0 0 0 rgba(25,135,84,0); }
}
.pulse-active { animation: pulse-green 1.5s infinite; }
