/* public/static/app.css — KBI Platform Styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  line-height: 1.5;
}

/* ── Sidebar Nav Links ─────────────────────────────────────── */
.nav-link {
  color: #6b7280;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover {
  background-color: #f3f4f6;
  color: #111827;
}
.nav-link.active {
  background-color: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}
.dark .nav-link { color: #9ca3af; }
.dark .nav-link:hover { background-color: #1f2937; color: #f9fafb; }
.dark .nav-link.active { background-color: #1e1b4b; color: #a5b4fc; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.25rem;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.07); }
.dark .card { background: #1f2937; border-color: #374151; }

/* ── Kanban Board ──────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 200px);
}
.kanban-column {
  flex: 0 0 280px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}
.dark .kanban-column { background: #1e293b; border-color: #334155; }
.kanban-column-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.75rem 0.75rem 0 0;
  flex-shrink: 0;
}
.dark .kanban-column-header { border-color: #334155; }
.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.kanban-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.625rem;
  padding: 0.875rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); transform: translateY(-1px); }
.dark .kanban-card { background: #0f172a; border-color: #1e293b; }

/* ── Gantt Chart ───────────────────────────────────────────── */
.gantt-container {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: white;
}
.dark .gantt-container { background: #1f2937; border-color: #374151; }
.gantt-header {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}
.dark .gantt-header { background: #1e293b; border-color: #374151; }
.gantt-label-col { width: 240px; flex-shrink: 0; padding: 0.625rem 1rem; font-weight: 600; font-size: 0.75rem; border-right: 1px solid #e5e7eb; }
.dark .gantt-label-col { border-color: #374151; }
.gantt-timeline { flex: 1; display: flex; }
.gantt-month { border-right: 1px solid #e5e7eb; padding: 0.625rem 0.5rem; font-size: 0.75rem; font-weight: 600; text-align: center; flex: 1; min-width: 80px; }
.dark .gantt-month { border-color: #374155; }
.gantt-row {
  display: flex;
  border-bottom: 1px solid #f1f5f9;
  min-height: 44px;
  align-items: center;
}
.dark .gantt-row { border-color: #1e293b; }
.gantt-row:hover { background: #f8fafc; }
.dark .gantt-row:hover { background: #1e293b; }
.gantt-row-label { width: 240px; flex-shrink: 0; padding: 0.5rem 1rem; font-size: 0.8rem; border-right: 1px solid #e5e7eb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.dark .gantt-row-label { border-color: #374151; }
.gantt-bar-track { flex: 1; position: relative; padding: 6px 0; min-width: 0; }
.gantt-bar {
  position: absolute;
  height: 24px;
  border-radius: 4px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s;
}
.gantt-bar:hover { opacity: 0.85; }

/* ── Calendar Grid ─────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e5e7eb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
}
.dark .cal-grid { background: #374151; border-color: #374151; }
.cal-day-header {
  background: #f8fafc;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}
.dark .cal-day-header { background: #1e293b; }
.cal-day {
  background: white;
  min-height: 90px;
  padding: 0.375rem;
  position: relative;
}
.dark .cal-day { background: #1f2937; }
.cal-day.other-month { background: #f9fafb; }
.dark .cal-day.other-month { background: #111827; }
.cal-day.today { background: #eef2ff; }
.dark .cal-day.today { background: #1e1b4b; }
.cal-event-dot {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: white;
}

/* ── List View ─────────────────────────────────────────────── */
.list-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding: 0.625rem 0.75rem;
  gap: 0.75rem;
  cursor: pointer;
  transition: background-color 0.1s;
  font-size: 0.875rem;
}
.list-row:hover { background-color: #f8fafc; }
.dark .list-row { border-color: #1e293b; }
.dark .list-row:hover { background-color: #1e293b; }

/* ── Status / Priority Badges ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Item Detail Modal ─────────────────────────────────────── */
.detail-tab {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: #6b7280;
  transition: color 0.15s;
}
.detail-tab.active { border-color: #6366f1; color: #6366f1; }
.dark .detail-tab.active { border-color: #818cf8; color: #818cf8; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slide-up 0.3s ease;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #4f46e5;
  flex-shrink: 0;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.dark ::-webkit-scrollbar-thumb { background: #374151; }

/* ── Utilities ─────────────────────────────────────────────── */
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  font-size: 0.75rem;
  cursor: pointer;
  background: white;
  transition: border-color 0.15s;
}
.filter-pill:hover { border-color: #6366f1; color: #6366f1; }
.filter-pill.active { border-color: #6366f1; background: #eef2ff; color: #4f46e5; }
.dark .filter-pill { background: #1f2937; border-color: #374151; color: #9ca3af; }
.dark .filter-pill.active { background: #1e1b4b; border-color: #818cf8; color: #a5b4fc; }

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spinner-spin 0.7s linear infinite;
}
@keyframes spinner-spin { to { transform: rotate(360deg); } }
.dark .spinner { border-color: #374151; border-top-color: #818cf8; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: #4f46e5;
  color: white;
}
.btn-primary:hover { background: #4338ca; }
.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.dark .btn-secondary { background: #374151; color: #d1d5db; border-color: #4b5563; }
.dark .btn-secondary:hover { background: #4b5563; }

/* ── Inputs ──────────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  color: #111827;
  background: white;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}
.input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.dark .input { background: #1f2937; border-color: #374151; color: #f9fafb; }
.dark .input:focus { border-color: #818cf8; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 1rem;
  overflow-y: auto;
}
.modal-box {
  background: white;
  border-radius: 1.25rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.dark .modal-box { background: #1f2937; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.625rem 0.75rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; border-bottom: 1px solid #e5e7eb; }
td { padding: 0.75rem; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.dark th { border-color: #374151; }
.dark td { border-color: #1f2937; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge-active { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-rejected { background: #fce7f3; color: #9d174d; }
.dark .badge-active { background: #064e3b; color: #6ee7b7; }
.dark .badge-pending { background: #451a03; color: #fbbf24; }

/* ── Directorate Pill ─────────────────────────────────────────── */
.dir-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
}

/* ── Org Chart ───────────────────────────────────────────────── */
.org-tree { display: flex; flex-direction: column; align-items: center; gap: 2rem; }
.org-node { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.org-children { display: flex; gap: 1.5rem; position: relative; }
.org-children::before {
  content: '';
  position: absolute;
  top: -1rem;
  left: 50%; right: 50%;
  border-top: 2px solid #d1d5db;
}
.org-node-card {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 120px;
  max-width: 160px;
}
.org-node-card:hover { border-color: #6366f1; box-shadow: 0 4px 12px rgba(99,102,241,0.15); }
.dark .org-node-card { background: #1f2937; border-color: #374151; }

/* ── Calendar cells ──────────────────────────────────────────── */
.cal-cell {
  min-height: 80px;
  padding: 4px;
}
.cal-event {
  font-size: 0.65rem;
  padding: 1px 5px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

/* ── Workspace view transitions ──────────────────────────────── */
#workspace-view-content {
  animation: fade-in 0.2s ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Item modal close button ─────────────────────────────────── */
#item-modal { overflow-y: auto; }

/* ── Sidebar open on mobile ──────────────────────────────────── */
@media (max-width: 1023px) {
  #sidebar {
    position: fixed;
    left: -16rem;
    z-index: 40;
    transition: left 0.25s;
  }
  #sidebar.open { left: 0; }
}

/* ── Kanban col min-height ───────────────────────────────────── */
.kanban-col > div[data-status] {
  min-height: 100px;
}

/* ── Toast colors ─────────────────────────────────────────────── */
.toast-success { background: #d1fae5; color: #065f46; }
.toast-error   { background: #fee2e2; color: #991b1b; }
.toast-info    { background: #e0e7ff; color: #3730a3; }
.dark .toast-success { background: #064e3b; color: #6ee7b7; }
.dark .toast-error   { background: #450a0a; color: #fca5a5; }
.dark .toast-info    { background: #1e1b4b; color: #a5b4fc; }

/* ── Prose (markdown) ─────────────────────────────────────────── */
.prose h1, .prose h2, .prose h3 { font-weight: 700; margin: 0.75em 0 0.5em; }
.prose h1 { font-size: 1.25rem; }
.prose h2 { font-size: 1.1rem; }
.prose h3 { font-size: 1rem; }
.prose p  { margin: 0.5em 0; }
.prose ul, .prose ol { padding-left: 1.5rem; margin: 0.5em 0; }
.prose li { margin: 0.25em 0; }
.prose code { background: #f3f4f6; padding: 0.1em 0.4em; border-radius: 0.25rem; font-size: 0.85em; }
.dark .prose code { background: #374151; }
.prose pre { background: #1f2937; color: #e5e7eb; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; font-size: 0.8rem; }
.prose blockquote { border-left: 3px solid #e5e7eb; padding-left: 1rem; color: #6b7280; }
.prose a { color: #6366f1; text-decoration: underline; }
