/* FUTURE & PAST TRACKABLES MODALS */


.past-trackables-content {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: min(500px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

/* Past Trackables Modal Styling */

.past-trackables-body {
  padding: var(--space-lg);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Trackable Item Styling */

.trackable-title {
  font-weight: 500;
  color: var(--color-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.move-to-today-btn,
.restore-trackable-btn {
  background: var(--color-success);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--size-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  margin: 0;
  min-width: auto;
}

.move-to-today-btn:hover,
.restore-trackable-btn:hover {
  background: #218838;
  transform: scale(1.05);
}

.empty-state {
  text-align: center;
  color: var(--color-gray);
  font-style: italic;
  padding: var(--space-xl);
}

/* Sprint 4: Enhanced Crisis Support Styles */
/* Crisis intro styling in tree library */
.crisis-intro {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.crisis-intro h3 {
  color: #92400e;
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.crisis-intro p {
  color: #78350f;
  margin: 0;
  font-weight: 500;
  line-height: 1.5;
}

.tree-section {
  margin-bottom: 2rem;
}

.tree-section-header {
  color: #1e293b;
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  padding: 0.5rem 0;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-item {
  border-left: 4px solid #10b981;
  background: rgba(16, 185, 129, 0.02);
}

.user-item {
  border-left: 4px solid #6366f1;
  background: rgba(99, 102, 241, 0.02);
}

.tree-item-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex: 1;
}

.tree-icon {
  font-size: 2rem;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.tree-info {
  flex: 1;
  min-width: 0;
}

.tree-info h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
}

.tree-description {
  margin: 0 0 0.5rem 0;
  font-size: var(--size-xs);
  color: #64748b;
  line-height: 1.4;
}

.template-badge {
  display: inline-block;
  background: #10b981;
  color: white;
  font-size: var(--size-xxs);
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tree-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 100px;
}

.tree-action {
  white-space: nowrap;
  font-weight: 600;
  font-size: var(--size-xs);
}

.section-empty {
  text-align: center;
  color: #64748b;
  font-style: italic;
  padding: 2rem;
}

.inline-create-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: var(--size-xs);
  cursor: pointer;
  font-weight: 600;
  margin-left: 0.5rem;
  transition: all 0.2s;
}

.inline-create-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

/* Enhanced tree list items */
.tree-list .tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  background: white;
  border-radius: 12px;
  margin-bottom: 1rem;
  border: 2px solid #f1f5f9;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tree-list .tree-item:hover {
  border-color: #e2e8f0;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  
  .tree-item-header {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .tree-icon {
    font-size: 1.5rem;
    align-self: flex-start;
  }
  
  .tree-actions {
    flex-direction: row;
    width: 100%;
  }
  
  .tree-actions .btn {
    flex: 1;
  }
}

/* DECISION TREE LIBRARY MODAL */

.tree-library-modal-content {
  width: min(600px, calc(100vw - 2rem));
}

.tree-library-header {
  padding: var(--modal-padding);
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: var(--modal-border-radius) var(--modal-border-radius) 0 0;
}

.tree-library-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
}

.tree-library-body {
  padding: var(--modal-padding);
  flex: 1;
  overflow-y: auto;
  background: white; /* Add explicit white background */
  border-radius: 0 0 var(--modal-border-radius) var(--modal-border-radius);
}

.tree-library-modal-content {
  background: white; /* Ensure solid white background */
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: min(700px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  overflow: hidden; /* Prevent any content bleeding */
}

.library-actions {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.tree-list {
  min-height: 200px;
}

.tree-list .tree-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--color-light-gray);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  transition: all 0.2s;
}

.tree-list .tree-item:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.tree-item .tree-info {
  flex: 1;
}

.tree-item .tree-info h4 {
  margin: 0 0 var(--space-xs) 0;
  color: var(--color-dark);
}

.tree-item .tree-info p {
  margin: 0;
  font-size: var(--size-sm);
  color: var(--color-gray);
}

.tree-item .tree-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.tree-item .tree-action,
.tree-item .tree-edit {
  width: auto;
  padding: var(--space-sm) var(--space-lg);
  margin: 0;
  font-size: var(--size-sm);
}

.tree-item .tree-edit {
  background: var(--color-gray);
}

.tree-item .tree-edit:hover {
  background: #5a6268;
}

/* GOAL MODAL */

.goal-modal-content {
  width: min(600px, calc(100vw - 2rem));
}

.goal-modal h2 {
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-border-light);
}

.trackables-selection {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-xs);
  max-height: 200px;
  overflow-y: auto;
}

.trackable-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xs);
  border-bottom: 1px solid var(--color-border-light);
  transition: background 0.2s;
}

.trackable-checkbox-item:hover {
  background: rgba(0, 123, 255, 0.05);
}

.trackable-checkbox-item:last-child {
  border-bottom: none;
}

.trackable-checkbox-item input[type="checkbox"] {
  width: auto !important;
  margin: 0 !important;
  margin-top: 2px !important;
}

.trackable-checkbox-item label {
  margin: 0 !important;
  flex: 1;
  font-size: var(--size-sm) !important;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.trackable-item-title {
  font-weight: 500;
  color: var(--color-dark);
  line-height: 1.3;
}

/* Two-panel goal modal layout */
.goal-modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  min-height: 500px;
  max-height: 60vh;
  margin-bottom: 2rem;
}

.goal-form-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.motivation-panel {
  border-left: 1px solid #e2e8f0;
  padding-left: 2rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.motivation-panel.desktop-only {
  display: flex;
}

.motivation-details {
  display: none; /* Hidden on desktop */
}

.motivation-intro {
  font-size: var(--size-sm);
  color: var(--color-gray);
  margin-bottom: var(--space-lg);
}

.motivation-section {
  margin-bottom: var(--space-lg);
}

.motivation-section h4 {
  font-size: var(--size-sm);
  color: #495057;
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.motivation-input {
  width: 100%;
  min-height: 120px;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--size-sm);
  resize: vertical;
  line-height: 1.5;
}

.motivation-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Collapsible motivation section styling */
.motivation-details {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
}

.motivation-details summary {
  font-weight: 600;
  color: var(--color-dark);
  font-size: var(--size-md);
  margin-bottom: var(--space-md);
  cursor: pointer;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border-light);
  transition: all 0.2s;
}

.motivation-details summary:hover {
  color: var(--color-primary);
}

.motivation-details summary::marker {
  font-size: var(--size-lg);
}

.motivation-panel-content {
  padding-top: var(--space-md);
}

/* Modal button row spans full width */
.goal-modal .modal-button-row {
  grid-column: 1 / -1;
  margin-top: 2rem;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border-light);
}

/* SETTINGS MODAL */

.settings-content { 
  width: min(700px, calc(100vw - 2rem)); 
}

.settings-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  min-height: 500px;
  max-height: 70vh;
}

.settings-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.debug-panel {
  border-left: 1px solid #e2e8f0;
  padding-left: 2rem;
  display: flex;
  flex-direction: column;
  height: 70vh;
}

.debug-tabs {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1rem;
  gap: 0;
}

.debug-tab {
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: var(--size-xs);
  font-weight: 500;
  color: var(--color-gray);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin: 0;
  width: auto;
}

.debug-tab:hover {
  color: var(--color-primary);
  background: rgba(0, 123, 255, 0.05);
}

.debug-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: rgba(0, 123, 255, 0.1);
}

.debug-content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.debug-tab-content {
  display: none;
  height: 100%;
  overflow-y: auto;
  background: #f8fafc;
  border-radius: 8px;
  padding: 1rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: var(--size-xxs);
  line-height: 1.4;
  border: 1px solid #e2e8f0;
}

.debug-tab-content.active {
  display: block;
}

.debug-loading {
  color: var(--color-gray);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

.debug-item {
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: white;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.debug-item-header {
  font-weight: bold;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.debug-item-content {
  white-space: pre-wrap;
  word-break: break-all;
  background: #f1f5f9;
  padding: 0.5rem;
  border-radius: 4px;
}

/* MOBILE RESPONSIVENESS */

@media (max-width: 768px) {
  
  .goal-modal-content,
  .settings-content,
  .game-settings-content {
    width: calc(100vw - 1rem);
    margin: 0.5rem;
    border-radius: 20px;
    max-height: 95vh;
  }
  
  .settings-body {
    grid-template-columns: 1fr;
    gap: 0;
    max-height: none;
  }
  
  .debug-panel {
    border-left: none;
    border-top: 1px solid #e2e8f0;
    padding-left: 0;
    padding-top: 2rem;
    margin-top: 2rem;
  }
  
  .debug-tabs {
    flex-wrap: wrap;
  }
  
  .debug-tab {
    flex: 1;
    min-width: 80px;
  }
  
  .goal-modal-body {
    grid-template-columns: 1fr;
    gap: 0;
    max-height: none;
  }
  
  .motivation-panel.desktop-only {
    display: none; /* Hide desktop version */
  }
  
  .motivation-details {
    display: block; /* Show mobile collapsible version */
  }
  
  .goal-modal-content {
    max-height: 95vh;
    overflow-y: auto;
  }
  
  .goal-modal .modal-button-row {
    margin-top: 0;
    position: sticky;
    bottom: 0;
    background: white;
    grid-column: auto;
  }
}

/* ENHANCED: Hierarchy Search and Filter Controls */

.hierarchy-controls-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1; /* Fill available space */
  min-width: 0; /* Allow shrinking */
}

.hierarchy-filter-group {
  display: flex;
  flex: 1; /* Fill available space in the controls container */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: white;
  min-width: 200px; /* Ensure minimum readable width */
}

.filter-btn {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.8rem;
  border: none;
  background: white;
  color: var(--color-gray);
  font-size: var(--size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.filter-btn:last-child {
  border-right: none;
}

.filter-btn:hover {
  background: var(--color-light-gray);
  color: var(--color-primary);
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
  font-weight: 600;
}

.search-dropdown-toggle {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--color-gray);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.search-dropdown-toggle:hover {
  background: var(--color-light-gray);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.search-dropdown-toggle.expanded {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.search-dropdown-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.search-dropdown-toggle.expanded svg {
  transform: rotate(180deg);
}

.search-input-group {
  margin-top: 1rem;
  margin-bottom: 1rem;
  display: none;
  position: relative;
  animation: slideDown 0.2s ease-out;
}

.search-input-group.visible {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hierarchy-search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--size-sm);
  transition: border-color 0.2s ease;
}

.hierarchy-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.clear-search-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-gray);
  cursor: pointer;
  font-size: 1.2rem;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.clear-search-btn:hover {
  background: var(--color-danger);
  color: white;
}

/* Part of System Styles */
.connection-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid rgba(0, 123, 255, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(0, 123, 255, 0.02);
}

.connected-to-select {
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
}

.connected-to-select option[disabled] {
  background: #f8f9fa;
  color: var(--color-gray);
  font-weight: bold;
  font-style: italic;
}

.connected-to-select option[value^="goal:"] {
  color: #2563eb;
  font-weight: 500;
}

.connected-to-select option[value^="trackable:"] {
  color: #059669;
  font-weight: 500;
}

.goal-inheritance-display {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
}

.connection-errors {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(220, 53, 69, 0.05);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: var(--radius-sm);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  
  .hierarchy-controls-container {
    width: 100%;
    justify-content: space-between;
  }
  
  .hierarchy-filter-group {
    flex: 1;
    min-width: 0;
  }
  
  .filter-btn {
    font-size: var(--size-xs);
    padding: 0.3rem 0.5rem;
  }
}

/* Crisis Button - Orange/Red Gradient */
#crisisBtn {
  margin-left: 1rem;
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
  color: white;
  border-color: transparent;
  z-index: 1001; /* Ensure it's above other nav elements */
  pointer-events: auto; /* Ensure it's clickable */
}

#crisisBtn:hover {
  background: linear-gradient(135deg, #FF5722 0%, #FF8F00 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

/* Game Settings Button - Green Gradient */

/* Settings Toggle - Purple Gradient */
#settingsToggle {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

#settingsToggle:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#settingsToggle.active {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  transform: rotate(45deg) scale(1.1);
}
