/* ═══════════════════════════════════════════════════════
   Project Management System - Main Stylesheet
   ═══════════════════════════════════════════════════════ */

:root {
  --primary:     #2563eb;
  --primary-dark:#1d4ed8;
  --sidebar-bg:  #0f172a;
  --sidebar-w:   260px;
  --header-h:    60px;
  --body-bg:     #f1f5f9;
  --card-bg:     #ffffff;
  --text:        #1e293b;
  --muted:       #64748b;
  --border:      #e2e8f0;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
}
.sidebar-brand .brand-text {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  color: rgba(255,255,255,.5);
  font-size: 11px;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
  padding: 14px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 0;
  transition: all .15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(37,99,235,.25);
  color: #fff;
  border-left-color: var(--primary);
}
.sidebar-link i { width: 18px; text-align: center; font-size: 14px; }

/* ── Main Layout ─────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Tables ──────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Progress Bar ────────────────────────────────────── */
.progress {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .3s;
}
.progress-bar.bg-success { background: #22c55e; }
.progress-bar.bg-warning { background: #f59e0b; }
.progress-bar.bg-danger  { background: #ef4444; }

/* ── Forms ───────────────────────────────────────────── */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  outline: none;
}
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 24px 0 16px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 15px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f8fafc; color: var(--text); }
.btn-danger    { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-success   { background: #22c55e; color: #fff; border-color: #22c55e; }
.btn-warning   { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── Alerts ──────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
  padding: 0;
  background: none;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }

/* ── Detail Info Grid ────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
}
.info-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.info-item:nth-child(odd) { border-right: 1px solid var(--border); }
.info-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 3px;
}
.info-value { font-size: 14px; font-weight: 500; }

/* ── Severity colors ─────────────────────────────────── */
.sev-low      { background: #dcfce7; color: #15803d; }
.sev-medium   { background: #fef9c3; color: #854d0e; }
.sev-high     { background: #fee2e2; color: #b91c1c; }
.sev-critical { background: #fae8ff; color: #7e22ce; }

/* ── Login Page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  margin-bottom: 12px;
}
.login-logo h2 { font-size: 20px; font-weight: 700; margin: 0; }
.login-logo p  { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ── Charts ──────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.chart-container {
  position: relative;
  height: 240px;
}

/* ── Tabs ────────────────────────────────────────────── */
.nav-tabs { border-bottom: 2px solid var(--border); gap: 0; }
.nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 0;
}
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: none;
}
.tab-content { padding-top: 20px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .info-item:nth-child(odd) { border-right: none; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ── Misc ────────────────────────────────────────────── */
.text-muted { color: var(--muted) !important; }
.fw-600 { font-weight: 600; }
.gap-2 { gap: .5rem; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.ms-auto { margin-left: auto; }
.mt-3 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.w-100 { width: 100%; }
a { color: var(--primary); }
.pagination .page-link { font-size: 13px; }
.form-check-input { cursor: pointer; }
.required::after { content: ' *'; color: #ef4444; }
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; margin: 0; }

/* ═══════════════════════════════════════════════════════
   Dashboard
   ═══════════════════════════════════════════════════════ */

/* ── Stat Cards ─────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }

/* ── Chart Cards ─────────────────────────────────────── */
.chart-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .chart-grid-2x2 { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chart-card-header {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chart-card-title {
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin: 0;
}
.chart-card-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chart-card-body { padding: 16px 20px 20px; }

/* ── Donut centre label ──────────────────────────────── */
.donut-wrap {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.donut-centre {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.donut-centre-value { font-size: 26px; font-weight: 800; line-height: 1; color: var(--text); }
.donut-centre-label {
  font-size: 10px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; margin-top: 2px;
}

/* ── Chart legend ────────────────────────────────────── */
.chart-legend { margin-top: 4px; display: flex; flex-direction: column; gap: 7px; }
.legend-item  { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: default; }
.legend-dot   { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-count { font-weight: 700; color: var(--text); }
.legend-pct   { color: var(--muted); font-size: 11px; margin-left: 2px; }

/* ── Status Cards ────────────────────────────────────── */
.status-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
}
.status-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  text-align: center;
  position: relative;
  overflow: hidden;
  text-decoration: none !important;
  display: block;
}
.status-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--sc-color, #2563eb);
  border-radius: 12px 12px 0 0;
}
.status-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.1);
}
.status-card-icon  { font-size: 22px; margin-bottom: 10px; color: var(--sc-color, #2563eb); opacity: .75; }
.status-card-count { font-size: 40px; font-weight: 900; line-height: 1; color: var(--sc-color, #2563eb); margin-bottom: 8px; }
.status-card-name  { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.status-card-hint  { font-size: 11px; color: var(--muted); }

/* ── Status Modal project list ───────────────────────── */
.modal-project-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.modal-project-row:last-child { border-bottom: none; }
.modal-project-row:hover { background: #f8fafc; }
.modal-project-index {
  width: 26px; height: 26px; border-radius: 50%;
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--muted);
  flex-shrink: 0;
}
.modal-project-link {
  font-weight: 600; font-size: 13.5px;
  text-decoration: none; color: var(--primary);
}
.modal-project-link:hover { text-decoration: underline; }
.modal-project-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-search-box {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px 7px 34px;
  font-size: 13px; width: 100%;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  transition: border-color .15s, box-shadow .15s;
}
.modal-search-box:focus {
  outline: none; border-color: var(--primary); background-color: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
/* ═══════════════════════════════════════════════════════
   DataTables
   ═══════════════════════════════════════════════════════ */

/* Table */
table.dataTable {
    width: 100% !important;
    margin: 0 !important;
}

.dataTables_wrapper {
    width: 100%;
    padding: 0;
}

.dataTables_wrapper .row {
    margin-left: 0;
    margin-right: 0;
}

/* ── Top Toolbar ───────────────────────────────────── */
.dt-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
}

/* ── Bottom Toolbar ────────────────────────────────── */
.dt-bot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
}

/* ── Length Dropdown ──────────────────────────────── */
div.dataTables_wrapper div.dataTables_length {
    margin: 0;
}

div.dataTables_wrapper div.dataTables_length label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

div.dataTables_wrapper div.dataTables_length select {
    width: auto !important;
    min-width: 75px;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

/* ── Search Box ───────────────────────────────────── */
div.dataTables_wrapper div.dataTables_filter {
    margin-left: auto !important;
    text-align: right !important;
}

div.dataTables_wrapper div.dataTables_filter label {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

div.dataTables_wrapper div.dataTables_filter input {
    width: 260px !important;
    max-width: 260px !important;
    margin-left: 0 !important;
    padding: 6px 10px !important;
    font-size: 13px;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    background: #fff;
    outline: none;
    box-shadow: none;
}

div.dataTables_wrapper div.dataTables_filter input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,.15) !important;
}

/* ── Processing / Empty State ─────────────────────── */
.dataTables_empty {
    text-align: center;
    padding: 30px !important;
    color: var(--muted);
}

/* ── Info ─────────────────────────────────────────── */
div.dataTables_wrapper div.dataTables_info {
    padding: 0 !important;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

/* ── Pagination ───────────────────────────────────── */
div.dataTables_wrapper div.dataTables_paginate {
    padding: 0 !important;
}

div.dataTables_wrapper .paginate_button {
    padding: 4px 10px !important;
    margin-left: 2px !important;
}

div.dataTables_wrapper .paginate_button.current {
    border-radius: 6px !important;
}

/* ── Scroll Wrapper ───────────────────────────────── */
.dataTables_scrollHeadInner,
.dataTables_scrollHeadInner table {
    width: 100% !important;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {

    .dt-top,
    .dt-bot {
        flex-direction: column;
        align-items: stretch;
    }

    div.dataTables_wrapper div.dataTables_filter {
        margin-left: 0 !important;
        text-align: left !important;
    }

    div.dataTables_wrapper div.dataTables_filter label,
    div.dataTables_wrapper div.dataTables_length label {
        width: 100%;
    }

    div.dataTables_wrapper div.dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
    }
}