/* DMP File Analyzer Styles - Polished Layout System */
:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.08);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --purple: #8b5cf6;
  --purple-light: rgba(139, 92, 246, 0.1);
  --blue: #3b82f6;
  --blue-light: rgba(59, 130, 246, 0.1);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

body.dark {
  --bg-main: #0b0f19;
  --bg-card: #111827;
  --bg-subtle: #1f2937;
  --border-color: #1f2937;
  --border-subtle: #1a2234;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --primary-light: rgba(99, 102, 241, 0.18);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 13.5px;
  min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

.dmp-app {
  display: flex;
  min-height: 100vh;
}

.dmp-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow-x: hidden;
}

/* Upload View */
.upload-container {
  max-width: 760px;
  margin: 60px auto;
  padding: 0 24px;
  text-align: center;
}

.brand-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.upload-header h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  color: var(--text-main);
}

.upload-header p {
  color: var(--text-muted);
  font-size: 14.5px;
  margin-bottom: 28px;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
}

.uploader {
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  padding: 44px 32px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  cursor: pointer;
}

.uploader:hover, .uploader.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.uploader-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.uploader h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.uploader p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--text-light);
}

/* Dashboard View Header */
.dashboard-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.title-text h2 {
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-completed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #dcfce7;
  color: #15803d;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
}

body.dark .badge-completed {
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
}

.meta-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  position: relative;
  width: 300px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

/* Main Dashboard Body */
.dashboard-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tab-content {
  display: none;
  width: 100%;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

/* Stat Cards Bar Grids */
.stat-cards-grid, .cards-row-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.stat-cards-grid-5, .cards-row-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.cards-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.cards-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.cards-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 1280px) {
  .stat-cards-grid, .cards-row-6 { grid-template-columns: repeat(3, 1fr); }
  .stat-cards-grid-5, .cards-row-5 { grid-template-columns: repeat(3, 1fr); }
  .cards-row-4, .cards-row-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .stat-cards-grid, .cards-row-6, .stat-cards-grid-5, .cards-row-5, .cards-row-4, .cards-row-3, .cards-row-2 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-info {
  min-width: 0;
  flex: 1;
}

.stat-info .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-info .stat-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 6px;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-icon.green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-icon.red { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

/* 4-Column Middle Row: Exception, Threads, Memory, System Info */
.cards-row-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.cards-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.cards-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1200px) {
  .cards-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-row-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .cards-row-4 { grid-template-columns: 1fr; }
  .cards-row-3 { grid-template-columns: 1fr; }
  .cards-row-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Donut & Chart Container */
.chart-donut-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.donut-relative {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.donut-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.donut-center-text .cnt {
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
}

.donut-center-text .lbl {
  font-size: 10px;
  color: var(--text-muted);
}

.chart-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  font-size: 11px;
}

.legend-left span {
  white-space: nowrap;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-val {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 11px;
  margin-left: 4px;
}

/* Memory Card */
.memory-stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.memory-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border-color);
}

.memory-stat-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.memory-stat-item .label {
  color: var(--text-muted);
}

.memory-stat-item .value {
  font-weight: 700;
}

/* System Information Card */
.system-info-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.sys-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.sys-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sys-row .sys-lbl {
  color: var(--text-muted);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.sys-row .sys-val {
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.35;
}

/* Specific formatting for Memory Statistics Card */
.memory-stats-card .sys-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
}

.memory-stats-card .sys-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.memory-stats-card .sys-val {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}

/* Thread Insights Styling */
.thread-insight-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}

.thread-insight-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.thread-insight-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.thread-insight-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Memory Highlights Styling */
.memory-highlight-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}

.memory-highlight-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.memory-highlight-title {
  font-size: 13px;
  font-weight: 700;
}

.memory-highlight-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tables Section */
.tables-insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
}

.modules-dashboard-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
}

@media (max-width: 1100px) {
  .tables-insights-grid,
  .modules-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .tables-row {
    grid-template-columns: 1fr;
  }
}

/* Crash Analysis Bottom Banner */
.crash-analysis-banner {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: grid;
  grid-template-columns: 40px 1.5fr 1fr 1.2fr;
  gap: 20px;
  align-items: start;
}

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

.crash-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.crash-banner-col h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: #dc2626;
  margin-bottom: 6px;
}

.crash-banner-col p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.crash-banner-list {
  list-style: disc;
  padding-left: 16px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Insights List */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.insight-card.danger {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.insight-card.warning {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.insight-card.info {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.insight-title {
  font-weight: 700;
  margin-bottom: 2px;
  word-break: break-word;
}

.insight-card.danger .insight-title { color: #dc2626; }
.insight-card.warning .insight-title { color: #d97706; }
.insight-card.info .insight-title { color: #2563eb; }

.insight-desc {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

.data-table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  padding: 7px 8px;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  white-space: nowrap;
}

/* Custom 3-Column Grid for Memory Analysis Dashboard */
.memory-middle-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(260px, 0.9fr);
  gap: 16px;
}

@media (max-width: 1200px) {
  .memory-middle-grid {
    grid-template-columns: 1fr;
  }
}

.data-table tr.highlight-red td {
  background: rgba(239, 68, 68, 0.06);
  color: #ef4444;
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: var(--bg-subtle);
}

.font-mono {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11.5px;
}

.link-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  margin-top: 12px;
}

.link-more:hover {
  text-decoration: underline;
}

/* Code Snippet Box */
.code-box {
  background: #0f172a;
  color: #f8fafc;
  padding: 14px;
  border-radius: 8px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
}

/* Register Grid */
.register-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.register-card {
  background: var(--bg-subtle);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
}

.register-card .reg-name {
  color: var(--text-muted);
  font-size: 10.5px;
  margin-bottom: 2px;
}

.register-card .reg-val {
  font-weight: 700;
  color: var(--primary);
}

/* Modal Overlay & Card System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

.modal-telemetry-item {
  background: var(--bg-subtle);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.modal-telemetry-item .lbl {
  font-size: 10.5px;
  color: var(--text-muted);
}

.modal-telemetry-item .val {
  font-weight: 700;
  font-size: 13px;
  margin-top: 2px;
}

tr.clickable-row {
  cursor: pointer;
}

tr.clickable-row:hover {
  background: var(--primary-light) !important;
}
