/**
 * NIST 800-53 Rev 5 Enhanced Styles
 * Styling for hierarchical tree view, baseline badges, and improved UI
 */

/* ============================================================
   HIERARCHICAL TREE VIEW
   ============================================================ */

.controls-tree {
  margin-top: 1.5rem;
  background: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tree-node {
  margin-bottom: 0.5rem;
}

.tree-node-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.tree-node-header:hover {
  background: #f3f4f6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tree-node-header.base-control {
  background: linear-gradient(135deg, #f0f9ff 0%, #f9fafb 100%);
  border-left: 3px solid #3b82f6;
}

.tree-node-header.enhancement {
  background: #fefce8;
  border-left: 3px solid #eab308;
  margin-left: 2rem;
}

.tree-expand-btn {
  background: none;
  border: none;
  padding: 0.25rem;
  margin-right: 0.5rem;
  cursor: pointer;
  color: #6b7280;
  transition: color 0.2s;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-expand-btn:hover {
  color: #3b82f6;
}

.tree-spacer {
  width: 24px;
  height: 24px;
  margin-right: 0.5rem;
  display: inline-block;
}

.tree-node-children {
  margin-top: 0.5rem;
  margin-left: 1rem;
  border-left: 2px solid #e5e7eb;
  padding-left: 1rem;
}

.tree-child-connector {
  width: 1rem;
  height: 1px;
  background: #e5e7eb;
  display: inline-block;
  margin-right: 0.5rem;
}

.control-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.875rem;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  min-width: 80px;
}

.control-id-badge i {
  color: #3b82f6;
  font-size: 1rem;
}

.control-id-badge.enhancement-badge {
  background: #fef3c7;
  border-color: #fcd34d;
}

.control-id-badge.enhancement-badge i {
  color: #f59e0b;
}

.control-name-inline {
  flex: 1;
  margin: 0 1rem;
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.5;
}

.control-actions-inline {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* ============================================================
   BASELINE BADGES
   ============================================================ */

.baseline-badges {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.baseline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.baseline-badge i {
  font-size: 0.875rem;
}

.baseline-low {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.baseline-low i {
  color: #22c55e;
}

.baseline-moderate {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.baseline-moderate i {
  color: #f59e0b;
}

.baseline-high {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.baseline-high i {
  color: #ef4444;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.813rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge i {
  font-size: 1rem;
}

.status-implemented {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.status-partial {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.status-planned {
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #93c5fd;
}

.status-alternative {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}

.status-na {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}

.status-not-started {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ============================================================
   VIEW TOGGLE
   ============================================================ */

.view-toggle {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.5rem;
  background: #f9fafb;
  border-radius: 6px;
}

.view-toggle button {
  flex: 1;
}

/* ============================================================
   CONTROLS HEADER
   ============================================================ */

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.controls-header h3 {
  margin: 0;
  font-size: 1.5rem;
}

.controls-stats {
  display: flex;
  gap: 1.5rem;
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: 500;
}

.stat-item i {
  font-size: 1.125rem;
}

/* ============================================================
   CONTROL CARDS (for flat view)
   ============================================================ */

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.control-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  transition: all 0.2s ease;
}

.control-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.control-card.base-card {
  border-left: 4px solid #3b82f6;
}

.control-card.enhancement-card {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, white 100%);
}

.control-card .control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.control-card .control-id {
  font-weight: 700;
  font-size: 1rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-card .control-id i {
  color: #3b82f6;
}

.control-card.enhancement-card .control-id i {
  color: #f59e0b;
}

.control-card .control-name {
  margin: 0.75rem 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #4b5563;
}

.control-card .control-maturity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.5rem;
  background: #f9fafb;
  border-radius: 4px;
}

.control-card .control-maturity label {
  font-weight: 600;
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
}

.control-card .control-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ============================================================
   MATURITY STARS
   ============================================================ */

.maturity-stars {
  display: inline-flex;
  gap: 0.25rem;
}

.maturity-stars i {
  font-size: 1rem;
}

.star-filled {
  color: #fbbf24;
}

.star-empty {
  color: #d1d5db;
}

.maturity-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-left: 0.5rem;
}

/* ============================================================
   COVERAGE CHART
   ============================================================ */

.coverage-chart-container {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin: 1.5rem 0;
}

.coverage-chart-container h4 {
  margin: 0 0 1rem 0;
  color: #1f2937;
}

#coverageChartCanvas {
  max-height: 300px;
}

/* ============================================================
   FAMILY LIST
   ============================================================ */

.family-item {
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.family-item:hover {
  background: #f9fafb;
  border-color: #3b82f6;
}

.family-item.active {
  background: linear-gradient(135deg, #dbeafe 0%, #f9fafb 100%);
  border-color: #3b82f6;
  border-left: 4px solid #3b82f6;
}

.family-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.family-header strong {
  color: #1f2937;
  font-size: 1rem;
}

.badge-count {
  background: #3b82f6;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.family-name {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.progress-bar-mini {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  transition: width 0.3s ease;
}

.coverage-text {
  font-size: 0.75rem;
  color: #3b82f6;
  font-weight: 600;
  margin-top: 0.25rem;
  text-align: right;
}

/* ============================================================
   COVERAGE BAR
   ============================================================ */

.coverage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.coverage-stats .stat {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.coverage-stats .stat label {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.coverage-stats .stat strong {
  font-size: 1.25rem;
  color: #1f2937;
}

.progress-bar-large {
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-content {
  background: white;
  border-radius: 8px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content.large {
  max-width: 1000px;
}

.control-details-view .control-header-info {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e5e7eb;
}

.control-details-view .control-header-info h2 {
  margin: 0 0 0.75rem 0;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-details-view .control-header-info h2 i {
  color: #3b82f6;
}

.control-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
}

.control-meta span {
  font-size: 0.875rem;
  color: #6b7280;
}

.section {
  margin-bottom: 1.5rem;
}

.section h4 {
  margin: 0 0 0.75rem 0;
  color: #1f2937;
  font-size: 1rem;
  font-weight: 600;
}

.section p {
  margin: 0;
  color: #4b5563;
  line-height: 1.6;
}

.response-summary {
  background: #f9fafb;
  padding: 1rem;
  border-radius: 6px;
  border-left: 4px solid #3b82f6;
}

.response-summary > div {
  margin-bottom: 0.75rem;
  color: #4b5563;
}

.response-summary > div:last-child {
  margin-bottom: 0;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.375rem;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-outline {
  background: white;
  color: #3b82f6;
  border: 1px solid #3b82f6;
}

.btn-outline:hover {
  background: #eff6ff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
  
  .coverage-stats {
    grid-template-columns: 1fr;
  }
  
  .controls-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .controls-stats {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }
  
  .tree-node-header {
    flex-wrap: wrap;
  }
  
  .control-name-inline {
    flex-basis: 100%;
    margin: 0.5rem 0;
  }
  
  .control-actions-inline {
    margin-left: auto;
  }
}

/* ============================================================
   PHASE 1 UX IMPROVEMENTS - NEW COMPONENTS
   ============================================================ */

/* Quick Actions Panel */
.quick-actions-panel {
  animation: slideIn 0.3s ease-out;
}

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

/* Search and Filter Bar */
.search-filter-bar input[type="text"]:focus {
  outline: none;
}

.search-filter-bar select:focus {
  outline: none;
}

.baseline-filter:checked + span {
  font-weight: bold;
}

/* Smart Family Tabs */
.smart-family-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.family-tab {
  min-width: 60px;
  text-align: center;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.family-tab:hover {
  transform: translateY(-2px);
}

.family-tab:active {
  transform: translateY(0);
}

/* Compact Card View */
.compact-card {
  transition: all 0.2s ease;
  position: relative;
}

.compact-card:hover {
  transform: translateY(-2px);
}

.compact-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 8px 8px 0 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.compact-card:hover::before {
  opacity: 1;
}

/* Status-specific top borders */
.compact-card.border-red-300::before {
  background: #EF4444;
}

.compact-card.border-yellow-300::before {
  background: #F59E0B;
}

.compact-card.border-blue-300::before {
  background: #3B82F6;
}

.compact-card.border-green-300::before {
  background: #10B981;
}

.compact-card.border-purple-300::before {
  background: #8B5CF6;
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Results Counter */
#filterResultsCounter {
  padding: 0.5rem 0;
  border-top: 1px solid #e5e7eb;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .quick-actions-panel .grid {
    grid-template-columns: 1fr;
  }
  
  .search-filter-bar .flex {
    flex-direction: column;
  }
  
  .search-filter-bar .flex-1 {
    width: 100%;
  }
  
  .smart-family-tabs .flex-wrap {
    max-height: 200px;
    overflow-y: auto;
  }
  
  .compact-card {
    margin-bottom: 1rem;
  }
}

/* Focus States for Accessibility */
.family-tab:focus,
.search-filter-bar input:focus,
.search-filter-bar select:focus,
.baseline-filter:focus {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}

/* Loading State */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Print Styles */
@media print {
  .quick-actions-panel,
  .search-filter-bar,
  .smart-family-tabs,
  .control-actions-inline {
    display: none !important;
  }
  
  .compact-card {
    page-break-inside: avoid;
    border: 1px solid #000 !important;
    margin-bottom: 1rem;
  }
}

/* ============================================================
 * CSF MAPPING STYLES (for Control Details Modal)
 * ============================================================ */
.csf-mappings-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.csf-mapping-item {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  transition: all 0.3s ease;
}

.csf-mapping-item:hover {
  border-color: #3B82F6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
}

.csf-mapping-item.primary {
  border-left: 4px solid #10B981;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}

.csf-mapping-item.secondary {
  border-left: 4px solid #3B82F6;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
}

.csf-mapping-item.supporting {
  border-left: 4px solid #8B5CF6;
  background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
}

.mapping-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.mapping-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mapping-badge.primary {
  background: #10B981;
  color: white;
}

.mapping-badge.secondary {
  background: #3B82F6;
  color: white;
}

.mapping-badge.supporting {
  background: #8B5CF6;
  color: white;
}

.csf-id {
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  padding: 0.25rem 0.5rem;
  background: #e2e8f0;
  border-radius: 4px;
}

.csf-function {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}

.mapping-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.csf-name {
  font-weight: 600;
  color: #334155;
  font-size: 0.95rem;
}

.csf-description {
  color: #64748b;
  font-size: 0.875rem;
  line-height: 1.5;
  padding-left: 1rem;
  border-left: 3px solid #e2e8f0;
}

.mapping-rationale {
  color: #94a3b8;
  font-size: 0.8rem;
  font-style: italic;
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 4px;
  margin-top: 0.25rem;
}

/* Responsive adjustments for CSF mappings */
@media (max-width: 768px) {
  .mapping-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .csf-mappings-list {
    gap: 0.75rem;
  }
  
  .csf-mapping-item {
    padding: 0.75rem;
  }
}

/* ============================================================
 * EDIT MODAL ADDITIONAL STYLES
 * ============================================================ */
details[open] summary i.fa-chevron-right {
  transform: rotate(90deg);
}

details summary {
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

.max-h-48 {
  max-height: 12rem;
}

.overflow-y-auto {
  overflow-y: auto;
}

.overflow-y-auto::-webkit-scrollbar {
  width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}


