/**
 * GradeCompass Stylesheet
 * Author: Abdul Hayy
 * Design: Clean, modern, accessible educational analytics interface
 */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #475569;
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --pass-color: #10b981;
  --pass-bg: #ecfdf5;
  --pass-border: #a7f3d0;
  --risk-color: #ef4444;
  --risk-bg: #fef2f2;
  --risk-border: #fecaca;
  --neutral-gauge: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navigation */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-title span {
  color: var(--primary);
}

nav a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

nav a:hover, nav a.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

/* Main Container */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Hero Section */
.hero {
  margin-bottom: 2rem;
  text-align: center;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.hero p {
  color: var(--text-muted);
  max-width: 650px;
  margin: 0 auto;
  font-size: 1.05rem;
}

/* App Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}

@media (min-width: 880px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1.15fr;
  }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--secondary);
  border: 1px solid var(--surface-border);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

/* Prediction Output Cards */
.results-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.prediction-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 540px) {
  .prediction-panel {
    grid-template-columns: 1fr 1fr;
  }
}

/* Metric Display Tile */
.metric-tile {
  background: #f8fafc;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.metric-label {
  font-size: 0.825rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Gauge Component */
.gauge-container {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 0.25rem 0;
}

.gauge-svg {
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--neutral-gauge);
  stroke-width: 10;
}

.gauge-circle {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 339.29;
  stroke-dashoffset: 339.29;
  transition: stroke-dashoffset 0.6s ease, stroke 0.4s ease;
}

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

.gauge-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.gauge-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Classification Badge & Probability */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.5rem 1.15rem;
  border-radius: 9999px;
  margin: 0.5rem 0;
  transition: all 0.3s ease;
}

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

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

.prob-container {
  width: 100%;
  margin-top: 0.75rem;
}

.prob-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.prob-bar-bg {
  width: 100%;
  height: 8px;
  background-color: var(--surface-border);
  border-radius: 9999px;
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease, background-color 0.4s ease;
}

.prob-fill.pass {
  background-color: var(--pass-color);
}

.prob-fill.risk {
  background-color: var(--risk-color);
}

/* Chart Canvas Section */
.chart-card {
  margin-top: 0.5rem;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
}

canvas#prep-impact-chart {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Disclaimer Banner */
.disclaimer-card {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-top: 2rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.disclaimer-icon {
  color: #b45309;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.disclaimer-text {
  font-size: 0.85rem;
  color: #92400e;
  line-height: 1.5;
}

/* Footer */
footer {
  margin-top: auto;
  border-top: 1px solid var(--surface-border);
  background: var(--surface);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

@media (min-width: 640px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Loading & Error States */
.state-box {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
  max-width: 500px;
  margin: 3rem auto;
}

.spinner {
  border: 4px solid var(--surface-border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-title {
  color: var(--risk-color);
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

/* About Page Styles */
.about-container {
  max-width: 800px;
  margin: 0 auto;
}

.about-section {
  margin-bottom: 2rem;
}

.about-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--surface-border);
  padding-bottom: 0.4rem;
}

.about-section p, .about-section li {
  color: #334155;
  font-size: 0.975rem;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.about-section ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

/* Table styling for metrics */
.metrics-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.925rem;
}

.metrics-table th, .metrics-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--surface-border);
}

.metrics-table th {
  background-color: #f8fafc;
  color: var(--text-main);
  font-weight: 600;
}

.metrics-table tr:hover {
  background-color: #f1f5f9;
}

.code-block {
  background: #1e293b;
  color: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  margin: 1rem 0;
}
