/* =============================================
   MS Project Alternative — Main Stylesheet
   ============================================= */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1e2a3a;
  --sidebar-text: #c8d6e5;
  --sidebar-active: #4a9eff;
  --sidebar-hover: rgba(74, 158, 255, 0.12);
  --brand-blue: #4a9eff;
  --brand-blue-dark: #2d7dd2;
  --top-bar-height: 56px;
  --gantt-header-h: 40px;
  --gantt-row-h: 36px;
}

/* ---- Layout ---- */
html, body { height: 100%; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f4f8; overflow: hidden; }

.app-wrapper { display: flex; height: 100vh; overflow: hidden; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 18px 20px 14px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 4px;
}
.sidebar-brand i { color: var(--brand-blue); font-size: 20px; }

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

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(200,214,229,0.45);
  padding: 4px 20px 4px;
  text-transform: uppercase;
}

.sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 8px 20px;
  border-radius: 0;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
}
.sidebar .nav-link i { font-size: 15px; width: 18px; text-align: center; }
.sidebar .nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar .nav-link.active { background: var(--sidebar-hover); color: var(--brand-blue); font-weight: 600; border-left: 3px solid var(--brand-blue); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.avatar-circle {
  width: 34px; height: 34px;
  background: var(--brand-blue);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.top-bar {
  height: var(--top-bar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.top-bar h1 { font-size: 16px; font-weight: 700; margin: 0; color: #1e2a3a; }
.top-bar .breadcrumb { margin: 0; font-size: 12.5px; }

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---- Cards ---- */
.card { border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.card-header { background: #fff; border-bottom: 1px solid #e2e8f0; font-weight: 600; font-size: 14px; }

/* ---- Stat Cards ---- */
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; line-height: 1; color: #1e2a3a; }
.stat-card .stat-label { font-size: 12px; color: #64748b; margin-top: 3px; }

/* ---- Progress Bar ---- */
.progress { height: 7px; border-radius: 10px; background: #e2e8f0; }
.progress-bar { border-radius: 10px; }

/* ---- Status Badges ---- */
.badge-planning    { background: #dbeafe; color: #1d4ed8; }
.badge-active      { background: #dcfce7; color: #15803d; }
.badge-on_hold     { background: #fef9c3; color: #a16207; }
.badge-completed   { background: #f0fdf4; color: #166534; }
.badge-cancelled   { background: #fee2e2; color: #991b1b; }
.badge-not_started { background: #f1f5f9; color: #475569; }
.badge-in_progress { background: #eff6ff; color: #1d4ed8; }

/* ---- Priority ---- */
.priority-low      { color: #64748b; }
.priority-medium   { color: #d97706; }
.priority-high     { color: #dc2626; }
.priority-critical { color: #7c3aed; font-weight: 700; }

/* =====================
   GANTT CHART STYLES
   ===================== */
.gantt-container {
  display: flex;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.gantt-left {
  min-width: 340px;
  max-width: 340px;
  border-right: 2px solid #e2e8f0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gantt-right {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.gantt-header-row {
  height: var(--gantt-header-h);
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  flex-shrink: 0;
}

.gantt-left .gantt-header-row {
  padding: 0 12px;
  gap: 8px;
}

.gantt-table { overflow-y: auto; flex: 1; }
.gantt-canvas-area { overflow-x: auto; flex: 1; position: relative; }

.gantt-row {
  height: var(--gantt-row-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
}
.gantt-row:hover { background: #f8fafc; }

.gantt-row .wbs   { width: 55px; padding: 0 8px; color: #94a3b8; font-size: 11px; flex-shrink: 0; }
.gantt-row .tname { flex: 1; padding-right: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gantt-row .tname.summary { font-weight: 700; color: #1e2a3a; }
.gantt-row .tname.milestone { color: #7c3aed; }
.gantt-row .tdur  { width: 50px; text-align: right; padding-right: 8px; color: #64748b; font-size: 11px; flex-shrink: 0; }
.gantt-row .tprog { width: 45px; text-align: right; padding-right: 8px; color: #64748b; font-size: 11px; flex-shrink: 0; }

/* Gantt canvas */
#ganttCanvas { display: block; }

/* =====================
   WBS TABLE — Modern Grid
   ===================== */
.wbs-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
  table-layout: fixed;
}
/* Dark gradient header */
.wbs-table thead { position: sticky; top: 0; z-index: 2; }
.wbs-table th {
  background: linear-gradient(180deg, #1e2d3d 0%, #243447 100%);
  border-bottom: none;
  padding: 10px 10px;
  font-weight: 600; font-size: 11px; letter-spacing: .4px;
  color: #94a3b8; text-transform: uppercase;
  white-space: nowrap;
}
.wbs-table th:first-child { border-radius: 0; }
.wbs-table td {
  padding: 0; border-bottom: 1px solid #f0f4f8;
  vertical-align: middle; height: 36px;
}
.wbs-table td > * { padding: 0 10px; }
.wbs-table td.td-wbs { padding: 0 10px; }
.wbs-table td.td-name { padding: 0; }
.wbs-table td.td-gantt { padding: 0 4px; }
.wbs-table td.td-pct   { padding: 0 10px; }
.wbs-table td.td-status{ padding: 0 6px; }
.wbs-table td.td-actions{ padding: 0 4px; text-align:center; }

/* Row types */
.wbs-table tr { transition: background 0.1s; }
.wbs-table tr:hover td { background: #f7f9fc; }

.summary-row td { background: #f1f5f9 !important; }
.summary-row:hover td { background: #e8eef5 !important; }
.summary-row .wbs-task-name { font-weight: 700; color: #1e2d3d; }

.milestone-row .wbs-task-name { color: #6d28d9; font-style: italic; }

.critical-row td { border-left: 2px solid #ef4444; }
.critical-row .wbs-task-name { color: #b91c1c; font-weight: 600; }
.critical-row:hover td { background: #fff8f8 !important; }

/* Task name cell */
.wbs-task-name {
  display: flex; align-items: center; gap: 5px;
  height: 38px; padding: 0 8px;
  font-size: 12.5px; color: #1e293b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wbs-task-name .name-text {
  overflow: hidden; text-overflow: ellipsis;
}

/* Toggle button */
.toggle-btn {
  flex-shrink: 0; border: none; background: none; padding: 0 2px;
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #64748b; transition: transform 0.15s;
  border-radius: 3px;
}
.toggle-btn:hover { background: #e2e8f0; color: #334155; }
.toggle-btn.collapsed { transform: rotate(-90deg); }
.toggle-spacer { width: 18px; flex-shrink: 0; }

/* Status badges */
.wbs-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap;
}
.badge-not_started { background: #f1f5f9; color: #64748b; }
.badge-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-completed   { background: #dcfce7; color: #15803d; }
.badge-on_hold     { background: #fef9c3; color: #854d0e; }
.badge-cancelled   { background: #fee2e2; color: #b91c1c; }

/* WBS number */
.wbs-num {
  font-size: 11px; color: #94a3b8; font-family: monospace;
  white-space: nowrap;
}

/* Mini Gantt */
.mini-gantt-wrap {
  position: relative; width: 100%; height: 38px;
  display: flex; align-items: center;
}
.mini-gantt-track {
  position: relative; flex: 1; height: 16px;
  background: #f1f5f9; border-radius: 3px; overflow: hidden;
}
.mini-gantt-bar {
  position: absolute; height: 100%; border-radius: 3px;
  min-width: 3px; overflow: hidden;
}
.mini-gantt-bar:hover { opacity: .85; cursor: default; }
/* Today line — garis tipis vertikal, tanpa pin */
.mini-gantt-today {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: #ef4444; z-index: 3; pointer-events: none;
}
/* Milestone diamond */
.mini-gantt-diamond {
  position: absolute; width: 10px; height: 10px;
  background: #7c3aed; transform: rotate(45deg);
  top: 50%; margin-top: -5px; border-radius: 1px;
  z-index: 2;
}

/* Progress */
.wbs-progress-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px; user-select: none;
}
.wbs-progress-wrap:hover .wbs-progress-track { background: #cbd5e1; }
.wbs-progress-track {
  flex: 1; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden;
  min-width: 50px; transition: background .15s;
}
.wbs-progress-fill {
  height: 100%; border-radius: 0 3px 3px 0; transition: width .3s;
  min-width: 0;
}
.wbs-pct-label { font-size: 11px; color: #64748b; min-width: 30px; text-align: right; font-weight: 600; }

/* Actions */
.task-actions { opacity: 0; transition: opacity 0.15s; display: flex; gap: 2px; justify-content: center; }
.wbs-table tr:hover .task-actions { opacity: 1; }

/* Read Only mode — CSS-only toggle, zero re-render */
.wbs-table.readonly-mode .task-actions { display: none !important; }
.wbs-table.readonly-mode .wbs-progress-wrap { cursor: default !important; pointer-events: none !important; }
.wbs-table.readonly-mode .wbs-progress-wrap:hover .wbs-progress-track { background: #e2e8f0 !important; }
.wbs-action-btn {
  border: none; background: transparent; padding: 3px 5px;
  border-radius: 4px; cursor: pointer; font-size: 12px; color: #64748b;
  transition: background 0.1s, color 0.1s;
}
.wbs-action-btn:hover { background: #e2e8f0; color: #1e293b; }
.wbs-action-btn.del:hover { background: #fee2e2; color: #b91c1c; }
.wbs-action-btn.add:hover { background: #dcfce7; color: #15803d; }

/* ── Inline Quick-Add Row ─────────────────────────────────────── */
.inline-add-row { background: #f0f9ff !important; }
.inline-add-row td { padding: 4px 4px !important; vertical-align: middle; border-top: 2px solid #93c5fd !important; border-bottom: 2px solid #93c5fd !important; }
.inline-inp {
  background: #fff; border: 1px solid #93c5fd; border-radius: 4px;
  padding: 4px 7px; font-size: 12px; color: #1e293b; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.inline-inp:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.inline-inp.is-invalid { border-color: #ef4444; animation: shake .2s; }
.inline-inp-name { width: 100%; min-width: 140px; }
.inline-inp-date { width: 105px; }
.inline-inp-dur  { width: 42px; text-align: center; }
.inline-sel-type {
  background: #fff; border: 1px solid #93c5fd; border-radius: 4px;
  padding: 4px 4px; font-size: 12px; color: #1e293b; cursor: pointer;
}
.inline-add-actions { display: flex; gap: 3px; justify-content: center; }
.inline-btn-save {
  background: #3b82f6; color: #fff; border: none; border-radius: 4px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.inline-btn-save:hover:not(:disabled) { background: #2563eb; }
.inline-btn-save:disabled { opacity: .6; cursor: default; }
.inline-btn-full {
  background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1;
  border-radius: 4px; padding: 4px 7px; font-size: 12px; cursor: pointer;
}
.inline-btn-full:hover { background: #e2e8f0; }
.inline-btn-cancel {
  background: none; color: #94a3b8; border: none;
  border-radius: 4px; padding: 4px 6px; font-size: 14px; cursor: pointer;
}
.inline-btn-cancel:hover { color: #ef4444; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* =====================
   RESOURCE TABLE
   ===================== */
.workload-bar {
  height: 8px; border-radius: 4px; background: #e2e8f0;
  overflow: hidden; min-width: 80px;
}
.workload-bar-fill { height: 100%; border-radius: 4px; background: var(--brand-blue); }
.workload-bar-fill.over { background: #ef4444; }

/* =====================
   KURVA S
   ===================== */
.kurva-chart-wrapper { position: relative; height: 400px; }

/* =====================
   IMPORT / EXPORT
   ===================== */
.import-drop-zone {
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: #f8fafc;
}
.import-drop-zone:hover, .import-drop-zone.drag-over {
  border-color: var(--brand-blue);
  background: #eff6ff;
}
.import-drop-zone i { font-size: 48px; color: #94a3b8; display: block; margin-bottom: 12px; }
.import-drop-zone.drag-over i { color: var(--brand-blue); }

/* =====================
   MODAL / FORMS
   ===================== */
.modal-header { background: var(--sidebar-bg); color: #fff; }
.modal-header .btn-close { filter: invert(1); }

/* Scroll sync for gantt */
.sync-scroll-h { overflow-x: scroll; }
.sync-scroll-h::-webkit-scrollbar { height: 8px; }

/* =====================
   LOGIN PAGE
   ===================== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e2a3a 0%, #2d3f55 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 44px; color: var(--brand-blue); }
.login-logo h1 { font-size: 20px; font-weight: 800; margin: 8px 0 2px; color: #1e2a3a; }
.login-logo p { font-size: 13px; color: #64748b; margin: 0; }

/* =====================
   UTILITIES
   ===================== */
.text-blue { color: var(--brand-blue); }
.bg-blue { background: var(--brand-blue); }
.cursor-pointer { cursor: pointer; }

.milestone-diamond {
  display: inline-block;
  width: 12px; height: 12px;
  background: #7c3aed;
  transform: rotate(45deg);
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-body { padding: 14px; }
}

/* ── Critical Path ─────────────────────────────────────── */
.critical-row td { background: #fff5f5 !important; }
.critical-row:hover td { background: #fee2e2 !important; }
.critical-row .task-name { color: #b91c1c; font-weight: 600; }
