/*
 * inDigitall BI Platform — Design System
 * Migrated from Demo/app/styles.py → Dash class-based selectors
 *
 * Brand: inDigital
 * Primary: #1E88E5 (Blue), Secondary: #76C043 (Green)
 * Font: Inter
 */

/* === CSS Variables (Design Tokens) === */
:root {
  /* Brand Colors */
  --id-primary: #1E88E5;
  --id-primary-dark: #1565C0;
  --id-primary-light: #42A5F5;
  --id-secondary: #76C043;
  --id-secondary-dark: #5EA832;

  /* Neutral Palette */
  --id-text-primary: #1A1A2E;
  --id-text-secondary: #6E7191;
  --id-text-muted: #A0A3BD;
  --id-bg-page: #F5F7FA;
  --id-bg-card: #FFFFFF;
  --id-border: #E4E4E7;

  /* Semantic Colors */
  --id-success: #76C043;
  --id-warning: #FFC107;
  --id-error: #EF4444;
  --id-info: #1E88E5;

  /* Typography */
  --id-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --id-font-size-xs: 12px;
  --id-font-size-sm: 13px;
  --id-font-size-base: 15px;
  --id-font-size-lg: 18px;
  --id-font-size-xl: 24px;
  --id-font-size-2xl: 32px;

  /* Spacing */
  --id-space-xs: 4px;
  --id-space-sm: 8px;
  --id-space-md: 16px;
  --id-space-lg: 24px;
  --id-space-xl: 32px;

  /* Border Radius */
  --id-radius-sm: 8px;
  --id-radius-md: 12px;
  --id-radius-lg: 16px;
  --id-radius-pill: 24px;

  /* Shadows */
  --id-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --id-shadow-md: 0 4px 24px rgba(0, 0, 0, 0.06);
  --id-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);

  /* Chat */
  --id-chat-user-bg: linear-gradient(135deg, #1565C0 0%, #42A5F5 100%);
  --id-chat-assistant-bg: #F5F7FA;
  --id-chat-assistant-border: #E4E4E7;

  /* Chart Color Sequence */
  --id-chart-1: #1E88E5;
  --id-chart-2: #76C043;
  --id-chart-3: #A0A3BD;
  --id-chart-4: #42A5F5;
  --id-chart-5: #1565C0;
  --id-chart-6: #FFC107;
  --id-chart-7: #9C27B0;
  --id-chart-8: #FF5722;

  /* Dashboard Grid */
  --id-grid-columns: 6;
  --id-grid-gap: 16px;
  --id-grid-row-height: 80px;

  /* Z-Index Scale */
  --id-z-navbar: 1000;
  --id-z-modal-backdrop: 1040;
  --id-z-modal: 1050;
  --id-z-offcanvas: 1045;
  --id-z-toast: 1090;
  --id-z-fab: 1030;

  /* Layout */
  --id-navbar-height: 56px;
  --id-offcanvas-width: 400px;
  --id-max-content-width: 1400px;
}

/* === Global === */
html, body {
  font-family: var(--id-font-family);
  background-color: var(--id-bg-page);
  color: var(--id-text-primary);
}

/* === Navbar === */
.navbar-indigitall {
  border-bottom: 1px solid var(--id-border);
  background: var(--id-bg-card) !important;
  height: var(--id-navbar-height);
  box-shadow: var(--id-shadow-sm);
  z-index: var(--id-z-navbar);
}

.navbar-brand-custom {
  text-decoration: none !important;
}

.brand-text {
  font-size: var(--id-font-size-lg);
  font-weight: 700;
  background: linear-gradient(135deg, var(--id-primary-dark) 0%, var(--id-primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-indigitall .nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--id-text-secondary) !important;
  padding: 8px 16px !important;
  border-radius: var(--id-radius-sm);
  transition: all 150ms ease-out;
}

.navbar-indigitall .nav-link:hover {
  color: var(--id-primary) !important;
  background: rgba(30, 136, 229, 0.06);
}

.navbar-indigitall .nav-link.active {
  color: var(--id-primary) !important;
  font-weight: 600;
  background: rgba(30, 136, 229, 0.1);
}

.create-dropdown .dropdown-toggle {
  border-radius: var(--id-radius-sm) !important;
  font-weight: 600;
  font-size: 13px;
}

/* Tenant dropdown in navbar */
.tenant-dropdown .Select-control {
  border: 1px solid var(--id-border);
  border-radius: var(--id-radius-sm);
  font-size: 13px;
  min-height: 32px;
}

/* === Page Content === */
.page-content {
  padding-top: var(--id-space-md);
  max-width: var(--id-max-content-width);
  margin: 0 auto;
}

/* === Typography === */
.page-title {
  font-size: var(--id-font-size-2xl);
  font-weight: 600;
  color: var(--id-text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: var(--id-font-size-base);
  color: var(--id-text-secondary);
  margin-bottom: var(--id-space-xl);
}

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

.panel-title {
  font-size: var(--id-font-size-lg);
  font-weight: 600;
  color: var(--id-text-primary);
}

/* === Cards === */
.card,
.kpi-card {
  background: var(--id-bg-card);
  border-radius: var(--id-radius-lg);
  box-shadow: var(--id-shadow-md);
  border: none;
  padding: var(--id-space-lg);
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--id-text-primary);
}

.kpi-card .kpi-label {
  font-size: var(--id-font-size-sm);
  font-weight: 500;
  color: var(--id-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Buttons === */
.btn-primary {
  background: var(--id-primary) !important;
  border-color: var(--id-primary) !important;
  border-radius: var(--id-radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: all 200ms ease-out;
}

.btn-primary:hover {
  background: var(--id-primary-dark) !important;
  border-color: var(--id-primary-dark) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3);
}

.btn-secondary {
  border-radius: var(--id-radius-sm);
  font-weight: 500;
  font-size: 14px;
}

/* === Search Input === */
.search-input {
  border: 1px solid var(--id-border);
  border-radius: var(--id-radius-md);
  padding: 10px 16px;
  font-size: var(--id-font-size-base);
}

.search-input:focus {
  border-color: var(--id-primary);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

/* === Chat === */
.chat-panel {
  background: var(--id-bg-card);
  border-radius: var(--id-radius-lg);
  box-shadow: var(--id-shadow-md);
  padding: var(--id-space-lg);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--id-navbar-height) - 48px);
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--id-space-md) 0;
}

.chat-message {
  padding: 16px 20px;
  border-radius: var(--id-radius-md);
  margin-bottom: var(--id-space-md);
  max-width: 90%;
}

.chat-message.user-msg {
  background: var(--id-chat-user-bg);
  color: white;
  margin-left: auto;
}

.chat-message.assistant-msg {
  background: var(--id-chat-assistant-bg);
  border: 1px solid var(--id-chat-assistant-border);
  margin-right: auto;
}

.chat-input-group {
  margin-top: var(--id-space-md);
}

.chat-input-field {
  border: 1px solid var(--id-border);
  border-radius: var(--id-radius-md) 0 0 var(--id-radius-md);
  padding: 12px 16px;
  font-size: var(--id-font-size-base);
}

.chat-input-field:focus {
  border-color: var(--id-primary);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

.chat-send-btn {
  border-radius: 0 var(--id-radius-md) var(--id-radius-md) 0 !important;
}

.suggestion-chip {
  border-radius: var(--id-radius-pill) !important;
  font-size: var(--id-font-size-sm);
  border-color: var(--id-border) !important;
  color: var(--id-text-secondary) !important;
  padding: 6px 14px;
  transition: all 150ms ease-out;
}

.suggestion-chip:hover {
  border-color: var(--id-primary) !important;
  color: var(--id-primary) !important;
  background: rgba(30, 136, 229, 0.06) !important;
}

/* === Results Panel === */
.results-wrapper {
  background: var(--id-bg-card);
  border-radius: var(--id-radius-lg);
  box-shadow: var(--id-shadow-md);
  padding: var(--id-space-lg);
  height: calc(100vh - var(--id-navbar-height) - 48px);
  overflow-y: auto;
}

.results-panel .dash-table-container {
  border-radius: var(--id-radius-md);
  overflow: hidden;
}

/* === Query Page === */
.query-page-row {
  height: calc(100vh - var(--id-navbar-height) - 32px);
}

/* === Dashboard Grid === */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(var(--id-grid-columns), 1fr);
  gap: var(--id-grid-gap);
  min-height: 300px;
}

.chart-widget {
  background: var(--id-bg-card);
  border-radius: var(--id-radius-lg);
  box-shadow: var(--id-shadow-sm);
  padding: var(--id-space-md);
  border: 1px solid var(--id-border);
}

.chart-widget:hover {
  box-shadow: var(--id-shadow-md);
}

/* === Floating Action Button (Chat on Dashboard) === */
.fab-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--id-z-fab);
  border-radius: var(--id-radius-pill) !important;
  padding: 12px 20px !important;
  box-shadow: var(--id-shadow-lg);
  font-weight: 600;
}

.fab-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(30, 136, 229, 0.3);
}

/* === Data Tables === */
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner th {
  background: var(--id-bg-page) !important;
  font-weight: 600;
  font-size: var(--id-font-size-sm);
  color: var(--id-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--id-border) !important;
}

.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td {
  font-size: var(--id-font-size-sm);
  color: var(--id-text-primary);
  border-bottom: 1px solid var(--id-border) !important;
}

/* === Plotly Chart Container === */
.js-plotly-plot {
  border-radius: var(--id-radius-lg);
  overflow: hidden;
}

/* === Empty States === */
.empty-state-text {
  font-size: var(--id-font-size-base);
}

/* === Toast Notifications === */
.toast-notification {
  z-index: var(--id-z-toast);
}

/* === Favorite Button === */
.favorite-btn {
  border: none !important;
  background: transparent !important;
  color: var(--id-text-muted) !important;
  padding: 4px 8px !important;
  transition: color 150ms ease-out;
}

.favorite-btn:hover,
.favorite-btn.active {
  color: var(--id-warning) !important;
}

/* === Data Explorer — Table Cards === */
.table-card {
  transition: all 200ms ease-out;
  border: 2px solid transparent;
}

.table-card:hover {
  border-color: var(--id-primary-light);
  box-shadow: var(--id-shadow-md);
  transform: translateY(-2px);
}

.table-card.selected {
  border-color: var(--id-primary);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15);
}

/* Sync status cards */
.sync-card {
  border-left: 3px solid var(--id-primary);
}

.sync-card .bi-check-circle-fill { color: var(--id-success); }
.sync-card .bi-exclamation-triangle-fill { color: var(--id-error); }
.sync-card .bi-arrow-repeat { color: var(--id-primary); }
.sync-card .bi-clock { color: var(--id-text-muted); }

/* === Responsive === */
@media (max-width: 1200px) {
  .query-page-row .chat-column { flex: 0 0 45%; max-width: 45%; }
  .query-page-row .results-column { flex: 0 0 55%; max-width: 55%; }
}

@media (max-width: 768px) {
  .query-page-row {
    flex-direction: column;
    height: auto;
  }
  .query-page-row .chat-column,
  .query-page-row .results-column {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .chat-panel,
  .results-wrapper {
    height: auto;
    max-height: 60vh;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
