/* Sales Analytics Dashboard - Custom Styles */

/* Base styles */
:root {
  --primary: #3b82f6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --purple: #8b5cf6;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
}

/* Header */
.header {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
  color: white;
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.25rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
}

.logo-subtitle {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Navigation */
.nav {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 60px;
  z-index: 99;
}

.nav-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 0;
  padding: 0 1rem;
}

/* Dropdown group */
.nav-group {
  position: relative;
}

.nav-group-label {
  padding: 0.875rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}

.nav-group-label::after {
  content: '';
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid #94a3b8;
  transition: transform 0.2s;
}

.nav-group:hover .nav-group-label {
  color: var(--primary);
}

.nav-group.has-active .nav-group-label {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #eff6ff;
  font-weight: 700;
}

.nav-group.has-active .nav-group-label::after {
  border-top-color: var(--primary);
}

.nav-group.has-active .nav-active-page {
  display: inline;
}

.nav-active-page {
  display: none;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--primary);
  opacity: 0.7;
  margin-left: 0.15rem;
}

.nav-group:hover .nav-group-label::after {
  border-top-color: var(--primary);
  transform: rotate(180deg);
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  z-index: 200;
}

.nav-group:hover .nav-dropdown {
  display: block;
}

.nav-dropdown .nav-link {
  display: block;
  padding: 0.65rem 1.25rem;
  text-decoration: none;
  color: #64748b;
  font-size: 0.825rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-dropdown .nav-link:last-child {
  border-bottom: none;
  border-radius: 0 0 0.5rem 0.5rem;
}

.nav-dropdown .nav-link:hover {
  color: var(--primary);
  background: #f1f5f9;
  border-left-color: var(--primary);
}

.nav-dropdown .nav-link.active {
  color: var(--primary);
  background: #eff6ff;
  border-left-color: var(--primary);
  font-weight: 600;
}

@media (max-width: 768px) {
  .nav-content {
    flex-wrap: wrap;
  }
  .nav-group-label {
    font-size: 0.78rem;
    padding: 0.75rem 0.75rem;
  }
}

/* Main content */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Page header */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: #64748b;
  font-size: 1rem;
}

/* Alert banners */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.alert-danger {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.alert-warning {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  color: #92400e;
}

.alert-success {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  color: #166534;
}

.alert-icon {
  font-size: 1.5rem;
}

.alert-content h3 {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.alert-content p {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Cards */
.card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-card.danger::before {
  background: var(--danger);
}

.kpi-card.warning::before {
  background: var(--warning);
}

.kpi-card.success::before {
  background: var(--success);
}

.kpi-card.info::before {
  background: var(--info);
}

.kpi-label {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.kpi-value.danger {
  color: var(--danger);
}

.kpi-value.warning {
  color: var(--warning);
}

.kpi-value.success {
  color: var(--success);
}

.kpi-value.info {
  color: var(--info);
}

.kpi-change {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.kpi-change.negative {
  color: var(--danger);
}

.kpi-change.positive {
  color: var(--success);
}

/* Charts grid */
.charts-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.charts-grid.two-col {
  grid-template-columns: repeat(2, 1fr);
}

.charts-grid.three-col {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1024px) {
  .charts-grid.two-col,
  .charts-grid.three-col {
    grid-template-columns: 1fr;
  }
}

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

.chart-container.tall {
  height: 400px;
}

.chart-container.short {
  height: 200px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

td {
  font-size: 0.875rem;
}

tr:hover {
  background: #f8fafc;
}

.table-row-danger {
  background: #fef2f2 !important;
}

.table-row-warning {
  background: #fffbeb !important;
}

.table-row-success {
  background: #f0fdf4 !important;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-info {
  background: #cffafe;
  color: #0e7490;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

/* Progress bars */
.progress {
  height: 0.5rem;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.progress-bar.danger {
  background: var(--danger);
}

.progress-bar.warning {
  background: var(--warning);
}

.progress-bar.success {
  background: var(--success);
}

/* Comparison cards */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

.comparison-card {
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.comparison-card.before {
  border: 2px solid var(--danger);
}

.comparison-card.after {
  border: 2px solid var(--success);
}

.comparison-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.comparison-card.before .comparison-title {
  color: var(--danger);
}

.comparison-card.after .comparison-title {
  color: var(--success);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item {
  position: relative;
  padding-bottom: 2rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-content {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timeline-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.timeline-list {
  list-style: none;
  padding: 0;
}

.timeline-list li {
  font-size: 0.875rem;
  color: #64748b;
  padding: 0.25rem 0;
  padding-left: 1.25rem;
  position: relative;
}

.timeline-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  color: #64748b;
  font-size: 0.875rem;
  border-top: 1px solid #e2e8f0;
  margin-top: 2rem;
}

/* Print styles */
@media print {
  .header, .nav {
    position: static;
  }

  .nav {
    display: none;
  }

  .main {
    padding: 1rem;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #e2e8f0;
  }

  .chart-container {
    height: 250px !important;
  }
}

/* Utility classes */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.font-mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-success {
  color: var(--success);
}

.text-muted {
  color: #64748b;
}

.mb-0 {
  margin-bottom: 0;
}

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

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

.mb-3 {
  margin-bottom: 1.5rem;
}

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

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

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

.flex {
  display: flex;
}

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

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

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: #0f172a;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  z-index: 1000;
  pointer-events: none;
}

/* Account Portfolio styles */
.section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #0f172a;
}

.section-subtitle {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .kpi-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .kpi-grid-4 {
    grid-template-columns: 1fr;
  }
}

.kpi-danger {
  border-left: 4px solid var(--danger);
}

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

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

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: #f1f5f9;
}

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

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #64748b;
}

.data-table .row-danger {
  background: #fef2f2;
}

.data-table .row-success {
  background: #f0fdf4;
}

.data-table .row-warning {
  background: #fffbeb;
}

.table-footer {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #64748b;
  padding: 0.5rem 0;
  border-top: 1px solid #e2e8f0;
}
