/* Routing Rules Page Styles */

.routing-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
.routing-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.routing-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  color: #1e293b;
}

.routing-header .subtitle {
  margin: 0;
  color: #64748b;
}

/* Stats */
.routing-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border: 1px solid #e2e8f0;
}

.stat-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 10px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
}

.stat-label {
  font-size: 0.875rem;
  color: #64748b;
}

/* Destinations Section */
.destinations-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border: 1px solid #e2e8f0;
}

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

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #1e293b;
}

.filter-controls {
  display: flex;
  gap: 1rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #64748b;
  cursor: pointer;
}

/* Destinations Grid */
.destinations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.destination-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

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

.destination-card.inactive {
  opacity: 0.6;
}

.destination-card.inactive:hover {
  opacity: 0.8;
}

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

.dest-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: white;
  border: 1px solid #e2e8f0;
}

.dest-name {
  font-weight: 600;
  color: #1e293b;
  font-size: 1.1rem;
}

.dest-description {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dest-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #94a3b8;
}

.dest-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dest-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* Rules Panel */
.rules-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 480px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.rules-panel.open {
  right: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.panel-icon {
  font-size: 1.5rem;
}

.panel-title h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #1e293b;
}

.panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.panel-close:hover {
  color: #1e293b;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.panel-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.panel-stat {
  display: flex;
  flex-direction: column;
}

.panel-stat .stat-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
}

.panel-stat .stat-text {
  font-size: 0.8rem;
  color: #64748b;
}

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

.panel-section .section-header {
  margin-bottom: 0.75rem;
}

.panel-section h4 {
  margin: 0;
  font-size: 0.9rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Rules List */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rule-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

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

.rule-name {
  font-weight: 600;
  color: #1e293b;
}

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

.rule-actions button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.875rem;
}

.rule-actions button:hover {
  color: #1e293b;
}

.rule-type {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: white;
  background: #3b82f6;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.rule-config-preview {
  font-size: 0.8rem;
  color: #64748b;
  background: white;
  padding: 0.5rem;
  border-radius: 4px;
  font-family: monospace;
}

.rule-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.rule-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Recent Docs */
.recent-docs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-doc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 0.875rem;
}

.recent-doc-icon {
  font-size: 1.25rem;
}

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

.recent-doc-name {
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-doc-date {
  font-size: 0.75rem;
  color: #94a3b8;
}

.recent-doc.unread {
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
}

/* Panel Footer */
.panel-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.75rem;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-large {
  max-width: 650px;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #1e293b;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.5rem;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.625rem 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[type="color"] {
  height: 40px;
  padding: 0.25rem;
  cursor: pointer;
}

/* Rule Builder */
.rule-builder {
  padding: 0 1.5rem 1.5rem;
}

.rule-builder h4 {
  margin: 0 0 1rem 0;
  color: #1e293b;
}

.rule-type-selector {
  margin-bottom: 1.5rem;
}

.rule-type-selector > label {
  display: block;
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.rule-type-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rule-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 80px;
}

.rule-type-btn:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.rule-type-btn.active {
  border-color: #3b82f6;
  background: #3b82f6;
  color: white;
}

.type-icon {
  font-size: 1.25rem;
}

.type-label {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Rule Config Panels */
.rule-config {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.rule-config.hidden {
  display: none;
}

.rule-config > label {
  display: block;
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

/* Category Grid */
.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-chip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.category-chip:hover {
  border-color: #3b82f6;
}

.category-chip:has(input:checked) {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.category-chip input {
  display: none;
}

/* Checkbox Group */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
}

/* Source/Org List */
.source-list,
.org-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.source-item,
.org-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
}

.source-item:hover,
.org-item:hover {
  border-color: #3b82f6;
}

.source-item:has(input:checked),
.org-item:has(input:checked) {
  border-color: #3b82f6;
  background: #eff6ff;
}

.source-item input,
.org-item input {
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-secondary {
  background: #f1f5f9;
  color: #374151;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: #94a3b8;
  font-size: 0.9rem;
}

.loading-placeholder {
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
}

/* Responsive */
@media (max-width: 1024px) {
  .routing-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .rules-panel {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 640px) {
  .routing-container {
    padding: 1rem;
  }

  .routing-header {
    flex-direction: column;
    gap: 1rem;
  }

  .routing-stats {
    grid-template-columns: 1fr;
  }

  .destinations-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .rule-type-buttons {
    justify-content: center;
  }
}
