/* Data Intelligence Studio - Modern Premium Styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Light Mode Palette */
  --bg: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-text: #f8fafc;
  --sidebar-nav-active: #2563eb;
  --sidebar-nav-hover: rgba(255, 255, 255, 0.1);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37, 99, 235, 0.1);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --table-hdr-bg: #f1f5f9;
  --table-hover: #f8fafc;
}

[data-theme="dark"] {
  /* Dark Mode Palette */
  --bg: #0b0f19;
  --sidebar-bg: #030712;
  --sidebar-text: #f3f4f6;
  --sidebar-nav-active: #3b82f6;
  --sidebar-nav-hover: rgba(255, 255, 255, 0.08);
  --card-bg: rgba(17, 24, 39, 0.75);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #1f2937;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.15);
  --danger: #f87171;
  --table-hdr-bg: #1f2937;
  --table-hover: #1e293b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--border);
  z-index: 10;
}

.sidebar-header {
  margin-bottom: 2.5rem;
}

.app-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-sub {
  font-size: 0.8rem;
  opacity: 0.6;
  font-weight: 500;
  margin-top: 0.2rem;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  padding: 0.8rem 1rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 0.5rem;
  cursor: pointer;
  opacity: 0.75;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.nav-btn:hover {
  opacity: 1;
  background-color: var(--sidebar-nav-hover);
  transform: translateX(3px);
}

.nav-btn.active {
  opacity: 1;
  background-color: var(--sidebar-nav-active);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.recent-section {
  margin-top: 2rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.recent-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.recent-item {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.recent-item:hover {
  opacity: 1;
  background-color: var(--sidebar-nav-hover);
}

.no-recent {
  font-size: 0.8rem;
  opacity: 0.4;
  font-style: italic;
  padding: 0.5rem 0.75rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
}

.btn-primary {
  width: 100%;
  padding: 0.875rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ── Main Content Area ─────────────────────────────────────────────── */
.main-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  min-height: 3rem;
}

.dataset-info {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

.dataset-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.dataset-dims {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.15rem;
}

.no-data-prompt {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-muted);
  font-style: italic;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-action {
  padding: 0.6rem 1.25rem;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background-color: var(--table-hdr-bg);
  border-color: var(--text-muted);
}

#btn-export {
  background-color: var(--accent-light);
  border-color: transparent;
  color: var(--accent);
}

#btn-export:hover {
  background-color: var(--accent);
  color: white;
}

/* ── Panels & Cards ────────────────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeIn 0.4s ease-out;
}

.panel.hidden {
  display: none;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px -5px rgba(0,0,0,0.08);
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.025em;
}

/* Charts and Tables containers */
.chart-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
}

.chart-card.full {
  min-height: 500px;
}

.chart-img {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  border-radius: 0.5rem;
  animation: scaleIn 0.3s ease-out;
}

.table-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ── Tables ────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background-color: var(--table-hdr-bg);
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--table-hover);
}

/* Scrollable table container */
.table-card.full {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

/* ── Animations & Helpers ──────────────────────────────────────────── */
.hidden {
  display: none !important;
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.no-data-prompt-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.btn-sample-data {
  padding: 0.6rem 1.25rem;
  background-color: var(--accent-light);
  border: 1px solid transparent;
  color: var(--accent);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.05);
}

.btn-sample-data:hover {
  background-color: var(--accent);
  color: white;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-sample-data:active {
  transform: translateY(0);
}

/* ── Settings Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2.25rem;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--card-shadow);
  animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  padding: 0.75rem 1rem;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-secondary {
  padding: 0.75rem 1.5rem;
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: var(--table-hdr-bg);
}
