/* ── Titan Design System Variables ───────────────────────────────────────────── */
:root {
  --titan-red:       #e94560;
  --titan-orange:    #ff6b35;
  --titan-green:     #22c55e;
  --titan-blue:      #3b82f6;
  --titan-purple:    #a855f7;
  --bg-primary:      #111827;
  --bg-dark:         #0d1117;
  --bg-card:         #1f2937;
  --border:          #1f2937;
  --border-light:    #374151;
  --text-primary:    #f1f5f9;
  --text-secondary:  #9ca3af;
  --text-muted:      #6b7280;
  --sidebar-width:   230px;
  --topbar-h:        54px;
}

/* ── Reset / Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  margin: 0;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ── Auth Layout ─────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-alerts {
  width: 100%;
  max-width: 420px;
  margin-bottom: 1rem;
}
.auth-card-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-logo {
  font-size: 2rem;
  color: var(--titan-orange);
  text-align: center;
  margin-bottom: 0.5rem;
}
.auth-brand {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  color: var(--titan-orange);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.auth-title { font-weight: 700; font-size: 1.25rem; text-align: center; margin-bottom: 0.25rem; color: var(--text-primary); }
.auth-subtitle { color: var(--text-muted); text-align: center; font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-dark);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.25s ease;
}
.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-light);
}
.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--titan-orange);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.sidebar-nav {
  flex-grow: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}
.sidebar-section-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.35rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; width: 1.2rem; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.sidebar-link.active {
  border-left-color: var(--titan-orange);
  background: rgba(255,107,53,0.08);
  color: #fff;
}
.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-light);
}
.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.sidebar-footer-link {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color 0.15s;
}
.sidebar-footer-link:hover { color: var(--text-primary); }

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: 900;
}
.topbar-title {
  flex-grow: 1;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-toggle { display: none; }

/* ── Main Wrapper ────────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.content-area { padding: 1.5rem; flex-grow: 1; }

/* ── Mobile Sidebar ──────────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.sidebar-open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main-wrapper { margin-left: 0; }
  .topbar { left: 0; }
  .sidebar-toggle { display: flex; }
}

/* ── Titan Cards ─────────────────────────────────────────────────────────────── */
.titan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.titan-card-header {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Override Bootstrap card with Titan dark style */
.card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: 10px;
  color: var(--text-primary);
}
.card-header {
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border-light) !important;
  color: var(--text-primary);
}
.card-footer {
  background: var(--bg-card) !important;
  border-top: 1px solid var(--border-light) !important;
}

/* ── Flash / Alerts ──────────────────────────────────────────────────────────── */
.titan-alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.titan-alert-success {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.3);
  color: #86efac;
}
.titan-alert-danger, .titan-alert-error {
  background: rgba(233,69,96,0.12);
  border-color: rgba(233,69,96,0.3);
  color: #fca5a5;
}
.titan-alert-warning {
  background: rgba(234,179,8,0.12);
  border-color: rgba(234,179,8,0.3);
  color: #fde68a;
}
.titan-alert-info {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.3);
  color: #93c5fd;
}

/* ── Stat Widgets ────────────────────────────────────────────────────────────── */
.stat-widget { text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--text-primary); }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 4px; }

/* Legacy stat-card (used in dashboard) — titan-ified */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-titan {
  background: var(--titan-orange);
  border-color: var(--titan-orange);
  color: #fff;
}
.btn-titan:hover {
  background: #e55a26;
  border-color: #e55a26;
  color: #fff;
}
.btn-primary {
  background: var(--titan-orange) !important;
  border-color: var(--titan-orange) !important;
}
.btn-primary:hover, .btn-primary:focus {
  background: #e55a26 !important;
  border-color: #e55a26 !important;
}
.btn-outline-primary {
  color: var(--titan-orange) !important;
  border-color: var(--titan-orange) !important;
}
.btn-outline-primary:hover {
  background: var(--titan-orange) !important;
  color: #fff !important;
}

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table {
  color: var(--text-primary);
  border-color: var(--border-light);
}
.table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  border-color: var(--border-light);
  background: var(--bg-card);
}
.table td { border-color: var(--border-light); vertical-align: middle; }
.table-hover tbody tr:hover { background: rgba(255,255,255,0.03); }
.table-light { background: var(--bg-card) !important; }
.table-light th, .table-light td { color: var(--text-muted) !important; background: var(--bg-card) !important; }
.table-dark, .table-dark th, .table-dark td { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-light); }

/* ── Status Badges ───────────────────────────────────────────────────────────── */
.badge-status-planning  { background: rgba(107,114,128,0.2); color: #9ca3af; border-radius: 6px; padding: 3px 8px; font-size: 0.72rem; }
.badge-status-active    { background: rgba(59,130,246,0.2);  color: #93c5fd; border-radius: 6px; padding: 3px 8px; font-size: 0.72rem; }
.badge-status-on_hold   { background: rgba(234,179,8,0.2);   color: #fde68a; border-radius: 6px; padding: 3px 8px; font-size: 0.72rem; }
.badge-status-completed { background: rgba(34,197,94,0.2);   color: #86efac; border-radius: 6px; padding: 3px 8px; font-size: 0.72rem; }
.badge-status-cancelled { background: rgba(233,69,96,0.2);   color: #fca5a5; border-radius: 6px; padding: 3px 8px; font-size: 0.72rem; }

/* Role badges */
.badge-role-admin   { background: rgba(233,69,96,0.2);  color: #fca5a5; font-size: 0.7rem; border-radius: 6px; padding: 2px 8px; }
.badge-role-manager { background: rgba(59,130,246,0.2); color: #93c5fd; font-size: 0.7rem; border-radius: 6px; padding: 2px 8px; }
.badge-role-staff   { background: rgba(107,114,128,0.2);color: #9ca3af; font-size: 0.7rem; border-radius: 6px; padding: 2px 8px; }

/* Utility */
.bg-purple { background: var(--titan-purple) !important; }
.text-purple { color: var(--titan-purple) !important; }

/* ── Nav Pills / Tabs ────────────────────────────────────────────────────────── */
.nav-pills .nav-link { color: var(--text-secondary); }
.nav-pills .nav-link.active { background: var(--titan-orange); color: #fff; }
.nav-tabs { border-color: var(--border-light); }
.nav-tabs .nav-link { color: var(--text-secondary); border-color: transparent; }
.nav-tabs .nav-link.active {
  background: var(--bg-card);
  border-color: var(--border-light) var(--border-light) var(--bg-card);
  color: var(--text-primary);
}
.nav-tabs .nav-link:hover { border-color: var(--border-light); color: var(--text-primary); }

/* ── Modals (dark) ───────────────────────────────────────────────────────────── */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}
.modal-header { border-bottom-color: var(--border-light); }
.modal-footer { border-top-color: var(--border-light); }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-primary);
  border-color: var(--border-light);
  color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
  background: var(--bg-primary);
  border-color: var(--titan-orange);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem rgba(255,107,53,0.25);
}
.form-control::placeholder { color: var(--text-muted); }
.form-check-input:checked { background-color: var(--titan-orange); border-color: var(--titan-orange); }
.form-range::-webkit-slider-thumb { background: var(--titan-orange); }
.form-range::-moz-range-thumb { background: var(--titan-orange); border: none; }

/* ── List Groups ─────────────────────────────────────────────────────────────── */
.list-group-item {
  background: var(--bg-card);
  border-color: var(--border-light);
  color: var(--text-primary);
}
.list-group-item-action:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }

/* ── Dropdown ────────────────────────────────────────────────────────────────── */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
}
.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.dropdown-item.text-danger { color: var(--titan-red) !important; }

/* ── Project Cards ───────────────────────────────────────────────────────────── */
.project-card { transition: transform 0.15s, box-shadow 0.15s; }
.project-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.3) !important; }
.project-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.description-truncate { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.min-w-0 { min-width: 0; }

/* ── Progress bars ───────────────────────────────────────────────────────────── */
.progress { background: rgba(255,255,255,0.08); }
.progress-bar { background: var(--titan-orange) !important; }
/* Tasks table progress bar stays titan-orange unless custom color set */
.progress-bar.bg-primary { background: var(--titan-orange) !important; }

/* ── Resources ───────────────────────────────────────────────────────────────── */
.resource-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.resource-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  cursor: default;
}
.color-swatch {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.15);
}
.user-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.75rem;
  flex-shrink: 0;
}

/* ── Resource Picker ─────────────────────────────────────────────────────────── */
.resource-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 150px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-primary);
}
.resource-pick-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 0.5rem;
  border: 2px solid var(--border-light);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-card);
  user-select: none;
  color: var(--text-primary);
}
.resource-pick-item:hover { background: rgba(255,255,255,0.06); }
.resource-pick-item.selected { border-color: var(--titan-orange); background: rgba(255,107,53,0.08); }
.resource-pick-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
}
.resource-pick-name { font-size: 0.85rem; color: var(--text-primary); }
.resource-pick-check { display: none; color: var(--titan-orange); }
.resource-pick-item.selected .resource-pick-check { display: inline-block; }

/* ── Gantt Dark Theme Overrides ──────────────────────────────────────────────── */
.gantt-container { overflow-x: auto; }
#ganttContainer { background: var(--bg-card); border-radius: 8px; }

/* Gantt SVG global dark */
.gantt .grid-background { fill: var(--bg-card); }
.gantt .grid-row { fill: var(--bg-card); }
.gantt .grid-row:nth-child(even) { fill: rgba(255,255,255,0.015); }
.gantt .grid-header { fill: var(--bg-primary); }
.gantt .row-line { stroke: var(--border-light); }
.gantt .tick { stroke: var(--border-light); stroke-width: 0.2; }

/* Text in gantt */
.gantt .lower-text, .gantt .upper-text { fill: var(--text-secondary) !important; }
.gantt .bar-label { fill: var(--text-primary) !important; font-size: 11px; }

/* Default task bars — titan-blue */
.gantt .bar { fill: rgba(59,130,246,0.7); stroke: var(--titan-blue); }
.gantt .bar-progress { fill: var(--titan-blue); }

/* Milestone bars — titan-orange diamond */
.gantt .bar-wrapper.bar-milestone .bar {
  fill: var(--titan-orange) !important;
  stroke: #e55a26 !important;
}
.gantt .bar-wrapper.bar-milestone .bar-progress { fill: #e55a26 !important; }
.gantt .bar-wrapper.bar-milestone .bar-label { fill: #fff !important; }

/* Deadline bars — titan-red */
.gantt .bar-wrapper.bar-deadline .bar {
  fill: var(--titan-red) !important;
  stroke: #c73050 !important;
}
.gantt .bar-wrapper.bar-deadline .bar-progress { fill: #c73050 !important; }
.gantt .bar-wrapper.bar-deadline .bar-label { fill: #fff !important; }

/* Today highlight */
.gantt .today-highlight { fill: rgba(255,107,53,0.06); }
.gantt .arrow { stroke: var(--border-light); }

/* Gantt handle/drag area */
.gantt .handle { fill: var(--titan-orange); }
.gantt .bar-wrapper:hover .bar { fill-opacity: 0.85; }

/* ── Toast Notifications ─────────────────────────────────────────────────────── */
.toast-container-custom {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast-item {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
  min-width: 220px;
  max-width: 380px;
  border: 1px solid rgba(255,255,255,0.08);
}
.toast-item.success { background: rgba(34,197,94,0.9); color: #fff; }
.toast-item.danger  { background: rgba(233,69,96,0.9); color: #fff; }
.toast-item.info    { background: rgba(59,130,246,0.9); color: #fff; }
.toast-item.warning { background: rgba(234,179,8,0.9); color: #111; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.flash-container { }
.btn-group .btn { border-radius: 6px !important; }
.btn-group .btn + .btn { margin-left: 2px; }
.text-primary { color: var(--titan-orange) !important; }
a { color: var(--titan-orange); }
a:hover { color: #e55a26; }
