/* AI Dashboard Generator — Frontend Styles
   Design: Clean data-centric UI with dark accents, glass-morphism cards,
   high-contrast KPI tiles, and professional chart containers.
   Font: System stack (fast, no external dependency required).
   ─────────────────────────────────────────────────────────── */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --aidg-bg:            #f0f4f8;
  --aidg-surface:       #ffffff;
  --aidg-surface-2:     #f8fafc;
  --aidg-border:        #e2e8f0;
  --aidg-text:          #0f172a;
  --aidg-text-muted:    #64748b;
  --aidg-text-light:    #94a3b8;
  --aidg-accent:        #1e40af;
  --aidg-accent-light:  #3b82f6;
  --aidg-accent-glow:   rgba(59, 130, 246, 0.15);
  --aidg-success:       #16a34a;
  --aidg-danger:        #dc2626;
  --aidg-warning:       #d97706;
  --aidg-radius:        12px;
  --aidg-radius-sm:     8px;
  --aidg-shadow:        0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --aidg-shadow-lg:     0 4px 6px rgba(0,0,0,.05), 0 10px 40px rgba(0,0,0,.1);
  --aidg-transition:    .2s cubic-bezier(.4,0,.2,1);
}

/* ── Base Reset ──────────────────────────────────────────── */
.aidg-app *,
.aidg-app *::before,
.aidg-app *::after {
  box-sizing: border-box;
}

.aidg-app {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--aidg-text);
  line-height: 1.6;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Cards ───────────────────────────────────────────────── */
.aidg-card {
  background: var(--aidg-surface);
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius);
  padding: 28px 32px;
  box-shadow: var(--aidg-shadow);
  margin-bottom: 24px;
}

/* ── Form Card ───────────────────────────────────────────── */
.aidg-form-card {
  position: relative;
  overflow: hidden;
}

.aidg-form-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--aidg-accent), var(--aidg-accent-light), #8b5cf6);
}

.aidg-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.aidg-card-icon {
  width: 48px; height: 48px;
  background: var(--aidg-accent-glow);
  border-radius: var(--aidg-radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.aidg-card-icon svg { width: 22px; height: 22px; stroke: var(--aidg-accent); }

.aidg-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--aidg-text);
  margin: 0 0 4px;
}

.aidg-card-subtitle {
  font-size: 13px;
  color: var(--aidg-text-muted);
  margin: 0;
}

/* ── Usage Badge ─────────────────────────────────────────── */
.aidg-usage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--aidg-surface-2);
  border: 1px solid var(--aidg-border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--aidg-text-muted);
  margin-bottom: 20px;
}

.aidg-usage-badge svg { width: 13px; height: 13px; }

/* ── Form Elements ───────────────────────────────────────── */
.aidg-form-row { margin-bottom: 20px; }

.aidg-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--aidg-text);
  margin-bottom: 6px;
}

.aidg-required { color: var(--aidg-danger); margin-left: 2px; }

.aidg-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--aidg-text-muted);
  min-height: 16px;
}

/* Select */
.aidg-select-wrapper {
  position: relative;
}

.aidg-select {
  width: 100%;
  padding: 10px 40px 10px 14px;
  border: 1.5px solid var(--aidg-border);
  border-radius: var(--aidg-radius-sm);
  font-size: 14px;
  color: var(--aidg-text);
  background: var(--aidg-surface);
  appearance: none;
  cursor: pointer;
  transition: border-color var(--aidg-transition), box-shadow var(--aidg-transition);
  outline: none;
}

.aidg-select:focus {
  border-color: var(--aidg-accent-light);
  box-shadow: 0 0 0 3px var(--aidg-accent-glow);
}

.aidg-select-arrow {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; stroke: var(--aidg-text-muted);
  pointer-events: none;
}

/* Drop Zone */
.aidg-drop-zone {
  position: relative;
  border: 2px dashed var(--aidg-border);
  border-radius: var(--aidg-radius-sm);
  background: var(--aidg-surface-2);
  transition: border-color var(--aidg-transition), background var(--aidg-transition);
  cursor: pointer;
}

.aidg-drop-zone:hover,
.aidg-drop-zone.dragover {
  border-color: var(--aidg-accent-light);
  background: var(--aidg-accent-glow);
}

.aidg-file-input {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.aidg-drop-zone-content {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 20px; gap: 8px;
  text-align: center; pointer-events: none;
}

.aidg-drop-zone-content svg {
  width: 40px; height: 40px;
  stroke: var(--aidg-text-light);
  margin-bottom: 4px;
}

.aidg-drop-text { font-weight: 600; color: var(--aidg-text-muted); margin: 0; }
.aidg-drop-hint { font-size: 12px; color: var(--aidg-text-light); margin: 0; }

/* File selected state */
.aidg-file-selected {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  color: var(--aidg-accent);
  font-weight: 500;
}

.aidg-file-selected svg { width: 18px; height: 18px; flex-shrink: 0; }

.aidg-remove-file {
  margin-left: auto;
  background: none; border: none;
  font-size: 18px; color: var(--aidg-text-muted);
  cursor: pointer; padding: 0 4px; line-height: 1;
}

.aidg-remove-file:hover { color: var(--aidg-danger); }

/* ── Alerts ──────────────────────────────────────────────── */
.aidg-alert {
  padding: 12px 16px;
  border-radius: var(--aidg-radius-sm);
  font-size: 13px;
  margin-top: 16px;
}

.aidg-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* ── Buttons ─────────────────────────────────────────────── */
.aidg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 22px;
  border-radius: var(--aidg-radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  text-decoration: none;
  transition: transform var(--aidg-transition), box-shadow var(--aidg-transition), opacity var(--aidg-transition);
  white-space: nowrap;
}

.aidg-btn svg { width: 16px; height: 16px; }

.aidg-btn:active { transform: translateY(1px); }

.aidg-btn-primary {
  background: linear-gradient(135deg, var(--aidg-accent), var(--aidg-accent-light));
  color: #fff;
  box-shadow: 0 2px 8px rgba(30, 64, 175, .35);
  margin-top: 20px;
  width: 100%;
  padding: 14px 22px;
}

.aidg-btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(30, 64, 175, .45);
  transform: translateY(-1px);
}

.aidg-btn-primary:disabled {
  opacity: .6; cursor: not-allowed;
}

.aidg-btn-secondary {
  background: var(--aidg-surface);
  color: var(--aidg-text-muted);
  border: 1.5px solid var(--aidg-border);
}

.aidg-btn-secondary:hover { background: var(--aidg-surface-2); }

.aidg-btn-pdf {
  background: linear-gradient(135deg, #065f46, #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,.3);
}

.aidg-btn-pdf:hover { box-shadow: 0 4px 16px rgba(5,150,105,.4); transform: translateY(-1px); }

/* ── Loader ──────────────────────────────────────────────── */
.aidg-loader {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}

.aidg-loader-inner { text-align: center; }

.aidg-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--aidg-border);
  border-top-color: var(--aidg-accent-light);
  border-radius: 50%;
  animation: aidg-spin .8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes aidg-spin { to { transform: rotate(360deg); } }

.aidg-loader-msg {
  color: var(--aidg-text-muted);
  font-size: 14px;
  margin: 0;
}

/* ── Dashboard Header ────────────────────────────────────── */
.aidg-dashboard-header {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-bottom: 24px;
}

.aidg-dashboard-title {
  font-size: 22px; font-weight: 800;
  color: var(--aidg-text); margin: 0 0 6px;
}

.aidg-dashboard-type-badge {
  display: inline-block;
  background: var(--aidg-accent-glow);
  color: var(--aidg-accent);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
}

.aidg-dashboard-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── KPI Grid ────────────────────────────────────────────── */
.aidg-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.aidg-kpi-card {
  background: var(--aidg-surface);
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius);
  padding: 20px 22px;
  box-shadow: var(--aidg-shadow);
  position: relative;
  overflow: hidden;
  transition: transform var(--aidg-transition), box-shadow var(--aidg-transition);
}

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

.aidg-kpi-label {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--aidg-text-muted); margin-bottom: 8px;
}

.aidg-kpi-value {
  font-size: 28px; font-weight: 800;
  color: var(--aidg-text); line-height: 1;
  margin-bottom: 8px;
}

.aidg-kpi-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}

.aidg-kpi-trend.up    { background: #dcfce7; color: var(--aidg-success); }
.aidg-kpi-trend.down  { background: #fee2e2; color: var(--aidg-danger); }
.aidg-kpi-trend.neutral { background: #f1f5f9; color: var(--aidg-text-muted); }

.aidg-kpi-desc {
  font-size: 11px; color: var(--aidg-text-light);
  margin-top: 8px; line-height: 1.4;
}

.aidg-kpi-accent-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px;
}

/* ── Charts Grid ─────────────────────────────────────────── */
.aidg-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.aidg-chart-card {
  background: var(--aidg-surface);
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius);
  padding: 22px 24px;
  box-shadow: var(--aidg-shadow);
}

.aidg-chart-title {
  font-size: 14px; font-weight: 700;
  color: var(--aidg-text); margin: 0 0 16px;
}

.aidg-chart-container {
  position: relative;
  height: 240px;
}

/* ── Section Title ───────────────────────────────────────── */
.aidg-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700;
  color: var(--aidg-text); margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--aidg-border);
}

.aidg-section-title svg { width: 16px; height: 16px; stroke: var(--aidg-accent); }

/* ── Insights ────────────────────────────────────────────── */
.aidg-insights-list {
  list-style: none; padding: 0; margin: 0;
}

.aidg-insights-list li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--aidg-border);
  font-size: 14px; color: var(--aidg-text);
  line-height: 1.5;
}

.aidg-insights-list li:last-child { border-bottom: none; }

.aidg-insight-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--aidg-accent-light);
  flex-shrink: 0; margin-top: 6px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .aidg-card { padding: 20px 16px; }
  .aidg-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .aidg-charts-grid { grid-template-columns: 1fr; }
  .aidg-dashboard-header { flex-direction: column; align-items: flex-start; }
  .aidg-kpi-value { font-size: 22px; }
}

/* ── Guest badge ── */
.aidg-guest-badge {
    background: #fefce8;
    border-color: #fde047;
    color: #854d0e;
}
.aidg-guest-badge svg { stroke: #ca8a04; }
