/*! HTML5 Boilerplate v9.0.1 | MIT License | https://html5boilerplate.com/ */

/* ==========================================================================
   Base styles
   ========================================================================== */

::-moz-selection { background: #b3d4fc; text-shadow: none; }
::selection { background: #b3d4fc; text-shadow: none; }

hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }

audio, canvas, iframe, img, svg, video { vertical-align: middle; }

fieldset { border: 0; margin: 0; padding: 0; }

textarea { resize: vertical; }

.hidden, [hidden] { display: none !important; }

/* ==========================================================================
   PM Ops Map - Application Styles
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #455a64 0%, #263238 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #37474f 0%, #263238 100%);
  color: white;
  padding: 30px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 { font-size: 32px; font-weight: 700; }
.header-meta { text-align: right; }
.header-meta p { margin: 5px 0; opacity: 0.9; font-size: 14px; }

/* Three-way nav tabs */
.nav-tabs {
  display: flex;
  background: #546e7a;
}

.nav-tab {
  flex: 1;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  color: white;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
}

.nav-tab:hover { background: #455a64; }
.nav-tab.active {
  background: white;
  color: #263238;
  border-bottom: 3px solid #00897b;
}

.controls {
  padding: 20px 40px;
  background: #eceff1;
  border-bottom: 2px solid #cfd8dc;
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary { background: #546e7a; color: white; }
.btn-primary:hover { background: #455a64; transform: translateY(-2px); }
.btn-secondary { background: #78909c; color: white; }
.btn-secondary:hover { background: #607d8b; }

.legend { display: flex; gap: 20px; margin-left: auto; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-color { width: 20px; height: 20px; border-radius: 4px; }

.content { padding: 40px; min-height: 600px; }

/* Hide inactive views */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* Department cards for tracking view */
.departments { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 30px; }
.department { background: white; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); overflow: hidden; }
.department-header {
  padding: 20px 25px;
  color: white;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
.department-body {
  padding: 25px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}
.department.expanded .department-body {
  max-height: 4000px;
  opacity: 1;
}

.task-item {
  background: #f5f5f5;
  padding: 15px 20px;
  margin-bottom: 12px;
  border-radius: 8px;
  border-left: 4px solid #78909c;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.task-item.unowned { border-left-color: #d32f2f; background: #ffebee; }
.task-name { font-weight: 600; color: #263238; flex: 1; }
.task-owner {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  margin-left: 10px;
}

/* Owner colors */
.owner-nathan { background: #ff6f00; }
.owner-patrick { background: #1976d2; }
.owner-austin { background: #00897b; }
.owner-cathryn { background: #6a1b9a; }
.owner-linda { background: #00695c; }
.owner-jason { background: #263238; }
.owner-carlos { background: #c62828; }
.owner-kevin { background: #5e35b1; }
.owner-unowned { background: #d32f2f; animation: pulse 2s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Map view SVG wrapper - allow horizontal scroll on small screens */
.map-scroll-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#flowMap { display: block; }

/* Stats */
.stats {
  padding: 20px 40px;
  background: #eceff1;
  border-top: 2px solid #cfd8dc;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}
.stat-card { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.stat-label { font-size: 13px; color: #546e7a; font-weight: 600; text-transform: uppercase; }
.stat-value { font-size: 32px; font-weight: 700; color: #263238; margin-top: 8px; }
.stat-card.danger .stat-value { color: #d32f2f; }
.stats-reset-btn { align-self: center; justify-self: end; font-size: 12px; padding: 8px 14px; }

/* Tracking view hero banner */
.tracking-hero {
  background: linear-gradient(135deg, #37474f 0%, #263238 100%);
  color: white;
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  margin-bottom: 40px;
}
.tracking-hero h2 { font-size: 28px; }
.tracking-hero p  { margin-top: 10px; opacity: 0.9; }

/* Shared section heading used in models view */
.section-heading { margin-bottom: 30px; color: #263238; }
.section-heading--spaced { margin-top: 40px; }

/* Strategic Models page styling */
.models-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 25px; margin-bottom: 40px; }
.model-card {
  background: white;
  border: 2px solid #cfd8dc;
  border-radius: 12px;
  padding: 25px;
  transition: all 0.3s;
}
.model-card:hover { transform: translateY(-5px); box-shadow: 0 12px 24px rgba(0,0,0,0.15); }
.model-card h3 { color: #00897b; margin-bottom: 15px; }
.model-card ul { list-style: none; padding: 0; }
.model-card li { padding: 6px 0; padding-left: 20px; position: relative; }
.model-card li:before { content: "→"; position: absolute; left: 0; color: #00897b; }

/* Model card inner elements (moved from inline styles) */
.model-subtitle       { color: #546e7a; font-style: italic; margin-bottom: 15px; }
.model-best-for       { background: #f5f5f5; padding: 12px; border-radius: 8px; margin-bottom: 15px; }
.model-structure-heading { margin-bottom: 10px; color: #263238; }
.model-pros-cons      { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.model-pros           { background: #f0fdf4; padding: 15px; border-radius: 8px; border-left: 3px solid #00897b; }
.model-pros h5        { margin-bottom: 8px; color: #00897b; }
.model-cons           { background: #fef2f2; padding: 15px; border-radius: 8px; border-left: 3px solid #d32f2f; }
.model-cons h5        { margin-bottom: 8px; color: #d32f2f; }
.model-pros ul,
.model-cons ul        { font-size: 13px; }
.model-example        { margin-top: 15px; font-size: 14px; color: #546e7a; }

/* Case study inner elements (moved from inline styles) */
.case-study { background: white; border: 2px solid #cfd8dc; border-radius: 12px; padding: 25px; margin-bottom: 25px; }
.case-study h3 { color: #1976d2; margin-bottom: 10px; }
.case-study ul { margin: 15px 0; }
.case-study-source    { color: #546e7a; font-size: 14px; margin-bottom: 15px; }
.case-study-link      { margin-top: 15px; }
.case-study-link a    { color: #1976d2; font-weight: 600; }

/* ==========================================================================
   Search & Filter Bar
   ========================================================================== */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid #cfd8dc;
  margin-bottom: 4px;
}

.search-input {
  padding: 9px 14px;
  border: 2px solid #b0bec5;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  min-width: 220px;
  flex: 1;
  max-width: 360px;
  transition: border-color 0.2s;
  background: white;
}

.search-input:focus {
  outline: none;
  border-color: #546e7a;
}

.owner-select {
  padding: 9px 12px;
  border: 2px solid #b0bec5;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.owner-select:focus {
  outline: none;
  border-color: #546e7a;
}

.filter-count {
  display: none;
  align-items: center;
  padding: 5px 12px;
  background: #263238;
  color: white;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* "No results" message */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: #546e7a;
  font-size: 16px;
  grid-column: 1 / -1;  /* span full grid width if departments is a grid */
}

.btn-link {
  background: none;
  border: none;
  color: #1976d2;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover { color: #0d47a1; }

/* ==========================================================================
   Inline Task Editing
   ========================================================================== */

.task-name {
  cursor: text;
  transition: background 0.15s;
  border-radius: 4px;
  padding: 2px 4px;
}

.task-name:hover {
  background: #e8f0fe;
}

.task-name::after {
  content: ' ✏';
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.15s;
  color: #546e7a;
}

.task-name:hover::after {
  opacity: 1;
}

.task-name-input {
  width: 100%;
  font: inherit;
  font-weight: 600;
  color: #263238;
  border: 2px solid #1976d2;
  border-radius: 6px;
  padding: 4px 8px;
  background: #e8f4fd;
  outline: none;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

/* Owner badge: click to reassign */
.task-owner {
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.task-owner:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}

/* ==========================================================================
   Owner Picker Dropdown
   ========================================================================== */

.owner-picker {
  position: fixed;
  background: white;
  border: 2px solid #cfd8dc;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 9999;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.owner-picker-btn {
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  text-align: left;
  transition: filter 0.1s, transform 0.1s;
}

.owner-picker-btn:hover {
  filter: brightness(1.15);
  transform: translateX(3px);
}

/* ==========================================================================
   Map View Controls
   ========================================================================== */

.map-controls {
  padding: 12px 16px;
  background: #f5f7fa;
  border-bottom: 1px solid #cfd8dc;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map-control-label {
  font-size: 13px;
  font-weight: 600;
  color: #546e7a;
  white-space: nowrap;
  margin-right: 4px;
}

.map-filter-pill {
  border: 2px solid var(--pill-color, #546e7a);
  background: var(--pill-color, #546e7a);
  color: white;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.map-filter-pill:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.map-filter-pill--hidden {
  background: transparent;
  color: var(--pill-color, #546e7a);
  opacity: 0.6;
}

.map-filter-pill--hidden:hover {
  opacity: 1;
}

.map-filter-pill--focused {
  outline: 3px solid white;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--pill-color, #546e7a);
}

.map-reset-btn {
  margin-left: 8px;
  font-size: 12px;
  padding: 5px 14px;
}

/* ==========================================================================
   Map Layout (SVG + detail panel side-by-side)
   ========================================================================== */

.map-layout {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-height: 500px;
}

.map-scroll-wrapper {
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

#flowMap { display: block; }

/* Dept detail panel */
.map-dept-panel {
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease, padding 0.3s ease;
  border-left: 0px solid #cfd8dc;
  background: #fafafa;
  flex-shrink: 0;
  height: 100%;
  min-height: 500px;
  font-size: 13px;
}

.map-dept-panel.active {
  width: 320px;
  padding: 0;
  border-left: 2px solid #cfd8dc;
}

.map-panel-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  color: #90a4ae;
  text-align: center;
  gap: 12px;
}

.map-panel-placeholder span { font-size: 40px; }
.map-panel-placeholder p { font-size: 14px; line-height: 1.5; }

.map-panel-header {
  padding: 16px 16px 12px 16px;
  background: white;
  border-bottom: 2px solid #eceff1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
}

.map-panel-header strong {
  font-size: 14px;
  color: #263238;
  flex: 1;
}

.map-panel-header .task-count-badge {
  font-size: 12px;
  background: #eceff1;
  color: #546e7a;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.map-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #90a4ae;
  padding: 0 4px;
  line-height: 1;
}
.map-panel-close:hover { color: #263238; }

.map-panel-body {
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 300px);
}

.map-panel-owner-group {
  margin-bottom: 14px;
}

.map-panel-owner-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
}

.map-panel-owner-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.map-panel-owner-group li {
  padding: 5px 10px;
  border-radius: 6px;
  color: #37474f;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 3px;
  background: white;
  border: 1px solid #eceff1;
  cursor: pointer;
  transition: background 0.1s;
}

.map-panel-owner-group li:hover {
  background: #e8f4fd;
  border-color: #90caf9;
}

/* ==========================================================================
   Map Tooltip
   ========================================================================== */

.map-tooltip {
  position: fixed;
  background: rgba(38, 50, 56, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  pointer-events: none;
  z-index: 9000;
  max-width: 240px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: none;
  line-height: 1.5;
}

.map-tooltip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */

@media (max-width: 768px) {
  body { padding: 10px; }

  .header {
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    text-align: center;
  }
  .header h1 { font-size: 22px; }
  .header-meta { text-align: center; }

  .nav-tab { font-size: 12px; padding: 12px 6px; }

  .controls { padding: 15px; gap: 10px; }
  .legend { margin-left: 0; gap: 12px; }
  .filter-bar { gap: 8px; }
  .search-input { min-width: 0; max-width: 100%; }
  .owner-select { width: 100%; }

  .content { padding: 15px; }

  /* Stack department cards to single column */
  .departments { grid-template-columns: 1fr; gap: 20px; }

  /* Stack model cards to single column */
  .models-grid { grid-template-columns: 1fr; }
  .model-pros-cons { grid-template-columns: 1fr; }

  .stats { padding: 15px; gap: 12px; }

  /* Let task-item wrap owner badge below task name on narrow screens */
  .task-item { flex-wrap: wrap; gap: 8px; }
  .task-owner { margin-left: 0; }

  /* Map panel stacks below the SVG on mobile */
  .map-layout { flex-direction: column; }
  .map-dept-panel.active { width: 100%; border-left: none; border-top: 2px solid #cfd8dc; }
}

@media (max-width: 480px) {
  .nav-tab { font-size: 11px; padding: 10px 4px; }
  .header h1 { font-size: 18px; }
}

/* ==========================================================================
   Save Toast Notification
   ========================================================================== */

.save-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #37474f;
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.save-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.save-toast--error {
  background: #c62828;
}

/* ==========================================================================
   Onboarding modal
   ========================================================================== */

.onboarding-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(38, 50, 56, 0.88);
  z-index: 20000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.onboarding-overlay.visible {
  display: flex;
}

.onboarding-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: onboardingIn 0.25s ease;
}

@keyframes onboardingIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.onboarding-logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1976d2;
  margin-bottom: 4px;
}

.onboarding-title {
  font-size: 26px;
  font-weight: 700;
  color: #263238;
  margin: 0;
}

.onboarding-subtitle {
  font-size: 14px;
  color: #607d8b;
  line-height: 1.5;
  margin-bottom: 8px;
}

.onboarding-label {
  font-size: 13px;
  font-weight: 600;
  color: #37474f;
}

.onboarding-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #cfd8dc;
  border-radius: 8px;
  font-size: 15px;
  color: #263238;
  outline: none;
  transition: border-color 0.15s ease;
}

.onboarding-input:focus {
  border-color: #1976d2;
}

.onboarding-input.shake {
  animation: inputShake 0.35s ease;
  border-color: #d32f2f;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  60%       { transform: translateX(6px); }
  80%       { transform: translateX(-3px); }
}

.onboarding-btn {
  margin-top: 4px;
  padding: 13px 20px;
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.onboarding-btn:hover {
  background: #1565c0;
}

/* ==========================================================================
   Print styles
   ========================================================================== */

@media print {
  body { background: white; padding: 0; }
  .container { box-shadow: none; border-radius: 0; }
  .nav-tabs, .controls { display: none; }
  .view-panel { display: block !important; }
  .department-body { display: block !important; }
  .stats { border-top: 1px solid #ccc; }
}
