/* TD&R Web Frontend - Component Styles */

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: linear-gradient(135deg, var(--secondary-dark) 0%, rgba(30, 42, 58, 0.8) 100%);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-number {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Data tables */
.data-table-container {
  background-color: var(--secondary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.table tbody tr {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background-color: rgba(96, 165, 250, 0.05);
}

.expand-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background-color: rgba(30, 42, 58, 0.5);
}

.table-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.search-box {
  position: relative;
  width: 300px;
}

.search-box input {
  width: 100%;
  padding-left: 2.5rem;
}

.search-box i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.pagination-btn {
  padding: 0.5rem 0.75rem;
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn.active {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.pagination-info {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* Filters */
.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.filter-select {
  padding: 0.5rem;
  background-color: var(--primary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  min-width: 150px;
}

/* Code blocks */
.code-block {
  background-color: var(--primary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  color: var(--text-secondary);
}

.code-block code {
  color: var(--light-blue);
}

/* Expandable content */
.expandable {
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
}

.expandable-header {
  padding: 1rem;
  background-color: rgba(30, 42, 58, 0.3);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
}

.expandable-header:hover {
  background-color: rgba(30, 42, 58, 0.5);
}

.expandable-title {
  font-weight: 500;
  color: var(--text-primary);
}

.expandable-icon {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.expandable.expanded .expandable-icon {
  transform: rotate(180deg);
}

.expandable-content {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: none;
}

.expandable.expanded .expandable-content {
  display: block;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal {
  background-color: var(--secondary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-xl);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 70vh;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Tabs */
.tabs {
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-list {
  display: flex;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tab-item {
  padding: 1rem 1.5rem;
  background-color: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  font-size: var(--font-size-base);
}

.tab-item:hover {
  color: var(--text-primary);
  background-color: rgba(96, 165, 250, 0.05);
}

.tab-item.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.tab-content {
  display: none;
}

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

/* Progress bars */
.progress {
  background-color: var(--primary-dark);
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--accent-blue);
  transition: width 0.3s ease;
}

.progress-bar.success {
  background-color: var(--success-green);
}

.progress-bar.warning {
  background-color: var(--warning-orange);
}

.progress-bar.error {
  background-color: var(--error-red);
}

/* Tooltips */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--primary-dark);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
  border: 1px solid var(--border);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Agent status indicators */
.agent-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  background-color: rgba(30, 42, 58, 0.3);
}

.agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-secondary);
}

.agent-status-dot.running {
  background-color: var(--success-green);
  animation: pulse 2s infinite;
}

.agent-status-dot.error {
  background-color: var(--error-red);
}

.agent-status-dot.warning {
  background-color: var(--warning-orange);
}

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

.agent-status-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Activity List Styles */
.activity-list {
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(30, 42, 58, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.activity-icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  margin-bottom: 4px;
  word-wrap: break-word;
}

.activity-time {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* Agent Flow Chart Styles */
.agent-flow-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  overflow-x: auto;
  padding: 24px 16px;
}

.agent-flow-item {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.agent-flow-box {
  background: linear-gradient(135deg, rgba(30, 42, 58, 0.8) 0%, rgba(25, 35, 50, 0.9) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  min-width: 200px;
  text-align: center;
  transition: all 0.3s ease;
}

.agent-flow-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

.agent-flow-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.agent-flow-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.agent-flow-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flow-stat-number {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-blue);
  line-height: 1;
}

.flow-stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.agent-flow-arrow {
  margin: 0 16px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.agent-flow-arrow svg {
  width: 20px;
  height: 20px;
}

/* Responsive flow chart */
@media (max-width: 768px) {
  .agent-flow-chart {
    flex-direction: column;
    align-items: stretch;
  }
  
  .agent-flow-item {
    flex-direction: column;
  }
  
  .agent-flow-arrow {
    transform: rotate(90deg);
    margin: 8px 0;
  }
  
  .agent-flow-box {
    min-width: auto;
    width: 100%;
  }
}

/* Dropdown Styles */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 42, 58, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-toggle:hover {
  background: rgba(30, 42, 58, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--secondary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  min-width: 160px;
  z-index: 1000;
  display: none;
  margin-top: 4px;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.2s ease;
  font-size: var(--font-size-sm);
}

.dropdown-item:hover {
  background: rgba(96, 165, 250, 0.1);
  color: var(--light-blue);
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
}

/* Expandable Row Styles */
.expanded-row {
  background: rgba(30, 42, 58, 0.5);
  border-top: 1px solid var(--border);
}

.expanded-content {
  padding: 1.5rem;
  border-left: 3px solid var(--accent-blue);
  max-width: 100%;
  overflow: hidden;
}

.rule-details {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background: rgba(19, 27, 42, 0.6);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rule-meta span {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.rule-content h4 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.yaml-content {
  background: var(--primary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
  overflow-wrap: break-word;
}

.yaml-content pre {
  margin: 0;
  padding: 1.5rem;
  background: transparent;
  color: var(--text-primary);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  width: 100%;
}

.yaml-content code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
}

/* Platform Content Styles */
.platform-content {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

/* Summary Content Styles */
.summary-content {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(30, 42, 58, 0.7);
  border-bottom: 1px solid var(--border);
}

.summary-header h5 {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.summary-text {
  padding: 1rem;
  background: var(--primary-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Executive Report Styles */
.executive-report {
  padding: 1rem;
  background: var(--primary-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}

.report-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.report-header h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.report-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.report-section {
  margin-bottom: 1.5rem;
}

.report-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--accent-color);
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.report-section p {
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.report-section ul {
  margin: 0.5rem 0 0.75rem 1.5rem;
  padding: 0;
}

.report-section li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.platform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(30, 42, 58, 0.7);
  border-bottom: 1px solid var(--border);
}

.platform-header h5 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.platform-text {
  padding: 1rem;
  background: var(--primary-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.copy-btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  transform: translateY(-1px);
}

/* YAML Syntax Highlighting */
.language-yaml .token.key {
  color: var(--light-blue);
}

.language-yaml .token.string {
  color: var(--success-green);
}

.language-yaml .token.number {
  color: var(--warning-orange);
}

.language-yaml .token.boolean {
  color: var(--error-red);
}

.language-yaml .token.comment {
  color: var(--text-secondary);
  font-style: italic;
}

/* Login form specific styles */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  background-color: var(--secondary-dark);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}

.login-form .form-group {
  margin-bottom: 1.5rem;
}

.login-form .btn {
  width: 100%;
  padding: 0.75rem;
  font-size: var(--font-size-base);
}
