/* ===========================
   OPTIMIZED MODERN-STYLES.CSS
   =========================== */

/* ===== CSS VARIABLES ===== */
:root {
  /* Base colors */
  --color-primary: #4f46e5;
  --color-primary-light: #6366f1;
  --color-primary-dark: #4338ca;
  --color-danger: #ef4444;
  --color-danger-light: #f87171;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;
  
  /* Grays */
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
  
  /* Status colors (consolidated) */
  --color-status-active: var(--color-success);
  --color-status-paused: var(--color-warning);
  --color-status-draft: var(--color-gray-400);
  --color-status-failed: var(--color-danger);
  --color-status-archived: var(--color-gray-600);
  --color-status-completed: var(--color-success);
  --color-status-processing: var(--color-info);
  --color-status-pending: var(--color-gray-500);
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Borders */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.375rem;
  --border-radius-lg: 0.5rem;
  --border-radius-xl: 0.75rem;
  --border-radius-2xl: 1rem;
  --border-radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
}

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-gray-50);
  color: var(--color-gray-800);
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== TYPOGRAPHY ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xl);
  gap: var(--spacing-lg);
}

.page-header > div:first-child {
  flex: 1;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-gray-900);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--color-gray-500);
  margin: 0.5rem 0 0 0;
  font-size: 1rem;
  line-height: 1.5;
}

/* ===== COMPONENTS ===== */

/* Cards */
.card {
  background-color: white;
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-gray-100);
  overflow: hidden;
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-gray-100);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-body {
  padding: var(--spacing-lg);
}

.card-footer {
  padding: var(--spacing-lg);
  background-color: var(--color-gray-50);
  border-top: 1px solid var(--color-gray-100);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 0.5rem;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
}

.btn-secondary {
  background-color: white;
  color: var(--color-gray-700);
  border: 1px solid var(--color-gray-300);
}

.btn-secondary:hover {
  background-color: var(--color-gray-50);
  border-color: var(--color-gray-400);
}

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

.btn-danger:hover {
  background-color: var(--color-danger-light);
}

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

.btn-lg {
  padding: 0.75rem 1.5rem;
}

.btn-full {
  width: 100%;
}

/* Status Badges - Consolidated */
.status-badge,
.dataset-status {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.25rem;
}

/* Status variants using data attributes for cleaner HTML */
[data-status="completed"],
.status-completed {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-status-completed);
}

[data-status="processing"],
.status-processing {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--color-status-processing);
}

[data-status="failed"],
.status-failed {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-status-failed);
}

[data-status="pending"],
.status-pending {
  background-color: rgba(156, 163, 175, 0.1);
  color: var(--color-status-pending);
}

[data-status="draft"],
.status-draft {
  background-color: rgba(156, 163, 175, 0.1);
  color: var(--color-status-draft);
}

[data-status="active"],
.status-active {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-status-active);
}

[data-status="paused"],
.status-paused {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-status-paused);
}

[data-status="archived"],
.status-archived {
  background-color: rgba(107, 114, 128, 0.1);
  color: var(--color-status-archived);
}

.status-indicator {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-right: 0.5rem;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  color: var(--color-gray-700);
}

.form-input, 
.form-textarea, 
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-gray-300);
  background-color: white;
  font-size: 0.875rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, 
.form-textarea:focus, 
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.form-hint {
  margin-top: var(--spacing-xs);
  font-size: 0.75rem;
  color: var(--color-gray-500);
}

/* Search Bar */
.search-bar {
  margin-bottom: 2rem;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3.5rem;
  background: white;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--border-radius-lg);
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.15);
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-gray-400);
  transition: color 0.3s ease;
  pointer-events: none;
}

.search-bar input:focus + .search-icon {
  color: var(--color-primary);
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  overflow-x: auto;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  padding: 0.75rem 1.25rem;
  background: white;
  border-radius: var(--border-radius-lg);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-gray-600);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--color-gray-200);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-tab:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
  background-color: rgba(99, 102, 241, 0.03);
}

.filter-tab.active {
  background: var(--color-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

/* Pills */
.dataset-pill, 
.chatbot-pill {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  background-color: rgba(79, 70, 229, 0.1);
  color: var(--color-primary);
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s ease;
}

.chatbot-pill:hover {
  background-color: rgba(79, 70, 229, 0.12);
  transform: translateY(-1px);
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal:not(.hidden) .modal-content {
  transform: translateY(0);
}

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

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-gray-100);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-gray-500);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--color-gray-700);
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 12rem;
  background-color: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-gray-100);
  z-index: 50;
  overflow: hidden;
}

.dropdown-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.dropdown-toggle:hover {
  background-color: var(--color-gray-100);
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--color-gray-700);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  gap: 0.5rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--color-gray-50);
}

.dropdown-item-delete {
  color: var(--color-danger);
}

.dropdown-item-delete:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

/* Status Messages */
.status-message {
  padding: 0.75rem;
  border-radius: 0.375rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.status-message.warning {
  background-color: #fff7ed;
  color: #c2410c;
}

.status-message.info {
  background-color: #eff6ff;
  color: #1d4ed8;
}

.status-message.success {
  background-color: #ecfdf5;
  color: #047857;
}

/* Code Preview */
.code-preview {
  background-color: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: monospace;
  font-size: 0.875rem;
  max-height: 300px;
  overflow-y: auto;
}

/* Footer */
footer {
  background-color: white;
  border-top: 1px solid var(--color-gray-100);
  padding: 2rem 0;
  margin-top: 4rem;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.03);
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light), transparent 80%);
}

.footer-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-gray-100);
}

footer p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-gray-600);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--color-gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  position: relative;
  transition: all 0.2s ease;
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-primary);
  transition: width 0.2s ease;
}

.footer-links a:hover::after {
  width: 100%;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.spinner-icon {
  animation: spin 1.5s linear infinite;
}

/* ===== UTILITY CLASSES ===== */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-col {
  flex-direction: column;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

.hidden { 
  display: none !important;
}

.relative { 
  position: relative; 
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.cursor-pointer { cursor: pointer; }

/* ===== RESPONSIVE DESIGN ===== */
@media (min-width: 768px) {
  .grid-cols-md-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-cols-lg-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }
  
  .page-header > div:first-child {
    width: 100%;
  }
  
  .page-header .btn {
    width: 100%;
    justify-content: center;
  }
  
  .page-title {
    font-size: 1.5rem;
  }
  
  .page-subtitle {
    font-size: 0.875rem;
  }
  
  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding-top: 1rem;
  }
  
  .footer-links {
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
  }
}