/* Scandinavian Minimalist Design System */
/* Based on the wireframe design principles */

:root {
  /* Colors */
  --bg: #ffffff;
  --bg-2: #f6f7f8;
  --fg: #0b1320;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0ea5e9;
  --accent-2: #111827;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #ef4444;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  --space-4xl: 40px;
  
  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  
  /* Shadows */
  --shadow: 0 1px 2px rgba(17,24,39,.06), 0 4px 12px rgba(17,24,39,.04);
  --shadow-lg: 0 4px 6px rgba(17,24,39,.1), 0 10px 15px rgba(17,24,39,.1);
  
  /* Typography */
  --font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;
  --font-size-4xl: 28px;
  --font-size-5xl: 36px;
  
  /* Layout */
  --sidebar-width: 240px;
  --header-height: 64px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-2: #0f172a;
    --fg: #f8fafc;
    --muted: #94a3b8;
    --line: #1f2937;
    --accent: #22b3f0;
    --accent-2: #ffffff;
  }
}

/* Reset and base styles */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas: "side head" "side main";
  height: 100vh;
}

/* Sidebar */
.sidebar {
  grid-area: side;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
}

.nav-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-2xl);
}

.logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--accent);
}

.nav-header h1 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}

.nav-items {
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  color: var(--fg);
  text-decoration: none;
  transition: background-color 0.15s ease;
  margin-bottom: var(--space-xs);
}

.nav-item:hover {
  background: var(--bg-2);
}

.nav-item.active {
  background: var(--bg-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  font-size: var(--font-size-lg);
}

.nav-label {
  font-weight: 500;
}

.nav-footer {
  margin-top: auto;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--line);
}

.version {
  font-size: var(--font-size-xs);
  color: var(--muted);
  text-align: center;
}

/* Header */
.header {
  grid-area: head;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.search-box {
  position: relative;
}

.search-input {
  height: 40px;
  padding: 0 var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  font-size: var(--font-size-sm);
  color: var(--fg);
  width: 200px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

/* Main content */
.main-content {
  grid-area: main;
  overflow: auto;
  background: var(--bg);
}

.page-content {
  padding: var(--space-xl);
  max-width: 1400px;
  margin: 0 auto;
}

/* Buttons */
.btn {
  height: 40px;
  padding: 0 var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
}

.btn:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

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

.btn-primary:hover {
  background: #0284c7;
  border-color: #0284c7;
}

.btn-secondary {
  background: var(--bg-2);
  border-color: var(--line);
}

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

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

.btn-sm {
  height: 32px;
  padding: 0 var(--space-md);
  font-size: var(--font-size-xs);
}

.btn-icon {
  font-size: var(--font-size-sm);
}

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

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

.card-actions {
  padding: var(--space-lg);
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* Dataset cards */
.datasets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.dataset-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
}

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

.dataset-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}

.status-badge {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
}

.status-completed {
  background: rgba(22, 163, 74, 0.1);
  color: var(--ok);
}

.status-processing {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warn);
}

.status-failed {
  background: rgba(239, 68, 68, 0.1);
  color: var(--bad);
}

.status-uploaded {
  background: rgba(14, 165, 233, 0.1);
  color: var(--accent);
}

.dataset-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.metric {
  text-align: center;
}

.metric-value {
  display: block;
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--fg);
}

.metric-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dataset-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.info-item {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
}

.info-label {
  color: var(--muted);
}

.info-value {
  color: var(--fg);
  font-weight: 500;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: var(--font-size-4xl);
  font-weight: 600;
  color: var(--fg);
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Page toolbar */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--line);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.filter-group {
  display: flex;
  gap: var(--space-sm);
}

.filter-select {
  height: 40px;
  padding: 0 var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  font-size: var(--font-size-sm);
  color: var(--fg);
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-4xl);
  color: var(--muted);
}

.empty-icon {
  font-size: var(--font-size-5xl);
  margin-bottom: var(--space-lg);
}

.empty-state h3 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--fg);
}

.empty-state p {
  margin-bottom: var(--space-xl);
}

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

.modal-content {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  color: var(--muted);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
}

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

.modal-body {
  padding: var(--space-xl);
  overflow-y: auto;
  max-height: calc(80vh - 120px);
}

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

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--fg);
  margin-bottom: var(--space-xs);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  font-size: var(--font-size-sm);
  color: var(--fg);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

.form-group textarea {
  height: 100px;
  resize: vertical;
  padding: var(--space-md);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  height: auto;
}

.form-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-xl);
}

/* File info */
.file-info {
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-2);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.file-details {
  color: var(--muted);
}

/* Dataset details */
.dataset-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.detail-section h4 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0 0 var(--space-lg) 0;
  color: var(--fg);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.detail-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--line);
}

.detail-label {
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.detail-value {
  color: var(--fg);
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.sentiment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
}

.sentiment-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-2);
  border-radius: var(--radius-md);
}

.sentiment-label {
  font-size: var(--font-size-xs);
  color: var(--muted);
  text-align: center;
  margin-bottom: var(--space-xs);
}

.sentiment-value {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--fg);
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
}

.demo-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) 0;
}

.demo-label {
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.demo-value {
  color: var(--fg);
  font-weight: 500;
  font-size: var(--font-size-sm);
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-lg);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: var(--font-size-sm);
  color: var(--muted);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  color: var(--fg);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  min-width: 300px;
}

.toast-show {
  transform: translateX(0);
}

.toast-success {
  border-left: 4px solid var(--ok);
}

.toast-error {
  border-left: 4px solid var(--bad);
}

.toast-warning {
  border-left: 4px solid var(--warn);
}

.toast-info {
  border-left: 4px solid var(--accent);
}

/* Responsive design */
@media (max-width: 1200px) {
  .datasets-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "main";
  }
  
  .sidebar {
    display: none;
  }
  
  .page-content {
    padding: var(--space-lg);
  }
  
  .datasets-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .page-toolbar {
    flex-direction: column;
    gap: var(--space-lg);
    align-items: stretch;
  }
  
  .toolbar-left,
  .toolbar-right {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .dataset-metrics {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    width: 95%;
  }
}
