@import url('design-tokens.css');

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: var(--shadow-glow);
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

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

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-approved-text);
  box-shadow: 0 0 8px var(--status-approved-text);
}

/* Ingestion Panel */
.ingestion-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.input-group {
  position: relative;
  margin-bottom: 1.25rem;
}

.html-textarea {
  width: 100%;
  height: 150px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.html-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

/* Drag and Drop Zone */
.dropzone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  background: rgba(13, 19, 34, 0.4);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 1.25rem;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.05);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dropzone-icon {
  font-size: 1.75rem;
  color: var(--accent-primary);
}

.dropzone-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.dropzone-text strong {
  color: var(--text-primary);
}

/* Action Buttons */
.action-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  font-family: var(--font-main);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-primary-glow);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* Diagnostic Results Section */
.results-container {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.results-container.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Top Overview Grid */
.overview-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

/* Score Card */
.score-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.score-radial {
  position: relative;
  width: 140px;
  height: 140px;
  margin-bottom: 1rem;
}

.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-circle-bg {
  fill: none;
  stroke: var(--bg-surface);
  stroke-width: 10;
}

.score-circle-val {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease-out, stroke 0.5s ease;
}

.score-text-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-number {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
}

.score-max {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.score-rating {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.score-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Metrics Grid */
.metrics-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.listing-meta-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.metric-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.metric-box-title {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.metric-box-val {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Fee & Margin Box */
.finance-box {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.finance-item {
  display: flex;
  flex-direction: column;
}

.finance-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.finance-val {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.finance-val.margin {
  color: var(--status-approved-text);
}

/* Section Dividers & Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2.5rem 0 1.25rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Pillars Grid */
.pillars-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.pillar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  transition: all var(--transition-fast);
}

.pillar-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-card-hover);
}

.pillar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pillar-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pillar-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--accent-cyan);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pillar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pillar-score-badge {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-badge.approved {
  background: var(--status-approved-bg);
  color: var(--status-approved-text);
  border: 1px solid var(--status-approved-border);
}

.status-badge.requires-adjustment {
  background: var(--status-adjustment-bg);
  color: var(--status-adjustment-text);
  border: 1px solid var(--status-adjustment-border);
}

.status-badge.not-found {
  background: var(--status-notfound-bg);
  color: var(--status-notfound-text);
  border: 1px solid var(--status-notfound-border);
}

/* Pillar Content Details */
.pillar-findings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

.finding-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.finding-icon {
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.finding-text strong {
  color: var(--text-primary);
}

/* Priority Actions Matrix */
.priority-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-top: 1.25rem;
}

.action-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.action-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(4px);
}

.priority-badge {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.priority-badge.high {
  background: var(--priority-high-bg);
  color: var(--priority-high-text);
  border: 1px solid var(--priority-high-border);
}

.priority-badge.medium {
  background: var(--priority-med-bg);
  color: var(--priority-med-text);
  border: 1px solid var(--priority-med-border);
}

.priority-badge.low {
  background: var(--priority-low-bg);
  color: var(--priority-low-text);
  border: 1px solid var(--priority-low-border);
}

.action-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.action-issue {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.action-solution {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.action-pillar-name {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Toast / Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--accent-primary);
  color: #fff;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-normal);
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.app-footer {
  margin-top: 4rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.5rem;
}
