/* ============================================================
   WBR Insights Platform - Custom Styles
   Amazon-inspired design language
   ============================================================ */

:root {
  --amz-navy: #232f3e;
  --amz-navy-light: #37475a;
  --amz-orange: #ff9900;
  --amz-orange-dark: #e88b00;
  --amz-orange-light: #ffad33;
  --amz-blue: #146eb4;
  --amz-blue-light: #1a8cff;
  --amz-green: #067d62;
  --amz-green-light: #00a86b;
  --amz-red: #d13212;
  --amz-red-light: #ff4d4d;
  --amz-amber: #f0ad4e;
  --amz-gray-100: #f8f9fa;
  --amz-gray-200: #e9ecef;
  --amz-gray-300: #dee2e6;
  --amz-gray-400: #ced4da;
  --amz-gray-500: #6c757d;
  --amz-gray-600: #495057;
  --amz-gray-700: #343a40;
  --amz-sidebar-width: 240px;
  --amz-topbar-height: 56px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Amazon Ember', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--amz-gray-100);
  color: var(--amz-gray-700);
  font-size: 14px;
  line-height: 1.5;
}

#root {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--amz-sidebar-width);
  background: var(--amz-navy);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--amz-navy-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-logo h1 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--amz-orange);
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.sidebar-nav-item.active {
  background: rgba(255,153,0,0.1);
  color: var(--amz-orange);
  border-left-color: var(--amz-orange);
}

.sidebar-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--amz-navy-light);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

/* --- Main Content Area --- */
.main-content {
  margin-left: var(--amz-sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Top Bar --- */
.topbar {
  height: var(--amz-topbar-height);
  background: white;
  border-bottom: 1px solid var(--amz-gray-300);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--amz-navy);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.week-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--amz-gray-100);
  border: 1px solid var(--amz-gray-300);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.week-selector select {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--amz-navy);
  cursor: pointer;
  outline: none;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--amz-gray-100);
  border-radius: 20px;
  font-size: 13px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--amz-navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* --- Page Content --- */
.page-content {
  padding: 24px;
  flex: 1;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--amz-gray-300);
  border-radius: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: 12px;
  font-weight: 600;
  color: var(--amz-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-bar select, .filter-bar input {
  padding: 6px 10px;
  border: 1px solid var(--amz-gray-300);
  border-radius: 4px;
  font-size: 13px;
  background: white;
  color: var(--amz-gray-700);
  outline: none;
}

.filter-bar select:focus, .filter-bar input:focus {
  border-color: var(--amz-blue);
  box-shadow: 0 0 0 2px rgba(20,110,180,0.1);
}

/* --- Metric Cards --- */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: white;
  border: 1px solid var(--amz-gray-300);
  border-radius: 8px;
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
  cursor: pointer;
}

.metric-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.metric-card.green::before { background: var(--amz-green); }
.metric-card.amber::before { background: var(--amz-amber); }
.metric-card.red::before { background: var(--amz-red); }

.metric-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--amz-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.metric-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--amz-navy);
  margin-bottom: 4px;
}

.metric-card-target {
  font-size: 12px;
  color: var(--amz-gray-500);
}

.metric-card-delta {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.metric-card-delta.up { background: #fde8e8; color: var(--amz-red); }
.metric-card-delta.down { background: #e6f9f0; color: var(--amz-green); }
.metric-card-delta.neutral { background: var(--amz-gray-200); color: var(--amz-gray-600); }

/* --- Charts --- */
.chart-container {
  background: white;
  border: 1px solid var(--amz-gray-300);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--amz-navy);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* --- Why Panel --- */
.why-panel {
  background: #fffbf0;
  border: 1px solid var(--amz-amber);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.why-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--amz-navy);
}

.why-panel-section {
  margin-bottom: 12px;
}

.why-panel-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--amz-gray-500);
  text-transform: uppercase;
  margin: 0 0 8px 0;
}

.why-panel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: white;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 13px;
}

.why-panel-item .delta {
  font-weight: 600;
  color: var(--amz-red);
}

/* --- Intervention Timeline --- */
.intervention-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.intervention-badge.drc { background: #e8f0fe; color: #1a73e8; }
.intervention-badge.upskill { background: #e6f9f0; color: var(--amz-green); }
.intervention-badge.campaign { background: #fef3e0; color: #e65100; }

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--amz-gray-100);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--amz-gray-600);
  border-bottom: 2px solid var(--amz-gray-300);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--amz-gray-200);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--amz-gray-100);
}

/* --- Kanban Board --- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  min-height: 500px;
}

.kanban-column {
  background: var(--amz-gray-100);
  border-radius: 8px;
  padding: 12px;
  min-height: 400px;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--amz-navy);
}

.kanban-column-count {
  background: var(--amz-gray-300);
  color: var(--amz-gray-600);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.kanban-card {
  background: white;
  border: 1px solid var(--amz-gray-300);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.kanban-card.priority-high { border-left-color: var(--amz-red); }
.kanban-card.priority-medium { border-left-color: var(--amz-amber); }
.kanban-card.priority-low { border-left-color: var(--amz-green); }

.kanban-card-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--amz-navy);
  margin-bottom: 4px;
}

.kanban-card-issue {
  font-size: 12px;
  color: var(--amz-gray-600);
  margin-bottom: 8px;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--amz-gray-500);
}

/* --- Badges & Tags --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active { background: #e6f9f0; color: var(--amz-green); }
.badge-paused { background: var(--amz-gray-200); color: var(--amz-gray-600); }
.badge-new { background: #e8f0fe; color: var(--amz-blue); }
.badge-under-review { background: #fef3e0; color: #e65100; }
.badge-actioned { background: #e6f9f0; color: var(--amz-green); }

.priority-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.priority-high { background: #fde8e8; color: var(--amz-red); }
.priority-medium { background: #fff3cd; color: #856404; }
.priority-low { background: #e6f9f0; color: var(--amz-green); }

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--amz-gray-200);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--amz-navy);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--amz-gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amz-gray-600);
  font-size: 18px;
}

.modal-close:hover {
  background: var(--amz-gray-200);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--amz-gray-200);
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--amz-gray-600);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--amz-gray-300);
  border-radius: 6px;
  font-size: 13px;
  color: var(--amz-gray-700);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--amz-blue);
  box-shadow: 0 0 0 3px rgba(20,110,180,0.1);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Buttons --- */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--amz-orange);
  color: white;
  border-color: var(--amz-orange-dark);
}

.btn-primary:hover {
  background: var(--amz-orange-dark);
}

.btn-secondary {
  background: white;
  color: var(--amz-gray-700);
  border-color: var(--amz-gray-300);
}

.btn-secondary:hover {
  background: var(--amz-gray-100);
}

.btn-danger {
  background: white;
  color: var(--amz-red);
  border-color: var(--amz-red);
}

.btn-danger:hover {
  background: #fde8e8;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--amz-gray-500);
}

.btn-icon:hover {
  background: var(--amz-gray-100);
  color: var(--amz-navy);
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideInRight 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
}

.toast-success { background: var(--amz-green); color: white; }
.toast-error { background: var(--amz-red); color: white; }
.toast-info { background: var(--amz-blue); color: white; }
.toast-warning { background: var(--amz-amber); color: var(--amz-gray-700); }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--amz-gray-500);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--amz-gray-600);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 400px;
  margin: 0 auto;
}

/* --- Loading State --- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--amz-gray-300);
  border-top-color: var(--amz-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- Detail Panel --- */
.detail-panel {
  background: white;
  border: 1px solid var(--amz-gray-300);
  border-radius: 8px;
  overflow: hidden;
}

.detail-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--amz-gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-panel-body {
  padding: 20px;
}

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--amz-gray-300);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
  padding-left: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amz-orange);
  border: 2px solid white;
}

.timeline-date {
  font-size: 11px;
  color: var(--amz-gray-500);
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 13px;
  color: var(--amz-gray-700);
}

/* --- Section Header --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--amz-navy);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--amz-gray-200);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--amz-gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}

.tab:hover {
  color: var(--amz-navy);
}

.tab.active {
  color: var(--amz-orange);
  border-bottom-color: var(--amz-orange);
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--amz-gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--amz-gray-500); }

/* --- Responsive tweaks for data density --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* --- Content Gap Card --- */
.content-gap-card {
  background: white;
  border: 1px solid var(--amz-gray-300);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  transition: box-shadow 0.15s ease;
}

.content-gap-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* --- Notification History --- */
.notification-log-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--amz-gray-200);
}

.notification-log-item:last-child { border-bottom: none; }

.notification-log-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fef3e0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Chip/Tag --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--amz-gray-100);
  border: 1px solid var(--amz-gray-300);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--amz-gray-600);
}

/* --- Action Row --- */
.action-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
