/* Factotum Web App Mockup Styles */

:root {
  /* Grade color thresholds - easily configurable */
  --grade-a-min: 90;
  --grade-b-min: 80;
  --grade-c-min: 70;
  --grade-d-min: 60;
  /* F is < 60 */

  /* Colors - celebrate A's, make F's really stand out */
  --grade-a: #059669; /* Darker green - celebrate! */
  --grade-b: #3b82f6; /* Blue - pretty good */
  --grade-c: #d97706; /* Orange - caution */
  --grade-d: #dc2626; /* Red - concern */
  --grade-f: #991b1b; /* Dark red - critical! */

  --alert-critical: #fee2e2;
  --alert-critical-border: #ef4444;
  --alert-warning: #fef3c7;
  --alert-warning-border: #eab308;

  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;

  /* Accent/action colors */
  --accent: #3b82f6;
  --accent-hover: #2563eb;

  /* Error/validation colors */
  --error-bg: #fef2f2;
  --error-border: #dc2626;
  --error-text: #991b1b;

  /* Row background colors for table - very subtle */
  --row-grade-a: #f0fdf4; /* Very light green */
  --row-grade-b: #eff6ff; /* Very light blue */
  --row-grade-c: #fef3c7; /* Very light yellow */
  --row-grade-d: #fee2e2; /* Very light red */
  --row-grade-f: #fef2f2; /* Light red */

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Borders */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: var(--spacing-md);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  border-bottom: 2px solid var(--border);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.sync-button {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  transition: background 0.2s;
}

.sync-button:hover {
  background: var(--border);
}

/* Main content */
.content {
  padding: var(--spacing-lg);
}

.section {
  margin-bottom: var(--spacing-xl);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  font-size: 1.125rem;
  font-weight: 600;
}

.badge {
  background: var(--alert-critical-border);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Alert Cards */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.alert-card {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-md);
}

.alert-card.critical {
  background: var(--alert-critical);
  border-color: var(--alert-critical-border);
}

.alert-card.warning {
  background: var(--alert-warning);
  border-color: var(--alert-warning-border);
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

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

.alert-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.2s;
  font-size: 1.125rem;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Grade Cards */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--spacing-md);
}

.grade-card {
  background: var(--bg-primary);
  border: 2px solid;
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.grade-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.grade-card.grade-a {
  border-color: var(--grade-a);
}
.grade-card.grade-b {
  border-color: var(--grade-b);
}
.grade-card.grade-c {
  border-color: var(--grade-c);
}
.grade-card.grade-d {
  border-color: var(--grade-d);
}
.grade-card.grade-f {
  border-color: var(--grade-f);
  border-width: 3px; /* Thicker border for F */
}

.grade-card-subject {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
}

.grade-card-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.grade-card.grade-a .grade-card-number {
  color: var(--grade-a);
}
.grade-card.grade-b .grade-card-number {
  color: var(--grade-b);
}
.grade-card.grade-c .grade-card-number {
  color: var(--grade-c);
}
.grade-card.grade-d .grade-card-number {
  color: var(--grade-d);
}
.grade-card.grade-f .grade-card-number {
  color: var(--grade-f);
  font-size: 2.25rem; /* Slightly larger for emphasis */
}

.grade-card-letter {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.grade-card-trend {
  font-size: 1.5rem;
  margin-top: var(--spacing-xs);
}

.trend-up {
  color: var(--grade-a);
}
.trend-down {
  color: var(--grade-f);
}
.trend-stable {
  color: var(--text-secondary);
}

.grade-card-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
}

/* Recent Changes */
.changes-list {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
}

.change-item {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.change-item:last-child {
  margin-bottom: 0;
}

/* Grade-based backgrounds for change items */
.change-item.row-grade-a {
  background: var(--row-grade-a);
  border-color: var(--grade-a);
}

.change-item.row-grade-b {
  background: var(--row-grade-b);
  border-color: var(--grade-b);
}

.change-item.row-grade-c {
  background: var(--row-grade-c);
  border-color: var(--grade-c);
}

.change-item.row-grade-d {
  background: var(--row-grade-d);
  border-color: var(--grade-d);
}

.change-item.row-grade-f {
  background: var(--row-grade-f);
  border-color: var(--grade-f);
}

.change-header {
  display: flex;
  align-items: start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.change-icon {
  font-size: 1.25rem;
}

.change-time {
  margin-left: auto;
}

.change-details {
  margin-left: calc(1.25rem + var(--spacing-sm));
}

.change-course {
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.change-field {
  font-family: "SF Mono", "Monaco", "Cascadia Code", "Courier New", monospace;
}

.change-positive {
  color: var(--grade-a);
  font-weight: 600;
}

.change-negative {
  color: var(--grade-f);
  font-weight: 600;
}

/* Class Detail Page */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: var(--spacing-md);
  font-size: 0.875rem;
}

.back-link:hover {
  color: var(--text-primary);
}

.class-header {
  margin-bottom: var(--spacing-xl);
}

.class-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

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

.stats-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.current-grade {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  text-align: center;
}

.current-grade-number {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

.current-grade-letter {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
}

.trend-chart {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
}

.trend-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.sparkline {
  height: 80px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.sparkline-bar {
  flex: 1;
  background: var(--grade-a);
  border-radius: 2px 2px 0 0;
  transition: background 0.2s;
}

.sparkline-bar:hover {
  background: var(--grade-b);
}

/* Recent assignment cards */
.recent-assignment-card {
  flex: 1;
  text-align: center;
  padding: var(--spacing-sm);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.recent-assignment-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Quarter Comparison */
.quarter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-md);
}

.quarter-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  text-align: center;
}

.quarter-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.quarter-grade {
  font-size: 1.5rem;
  font-weight: 700;
}

.quarter-letter {
  color: var(--text-secondary);
}

/* Category Breakdown */
.category-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.category-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.category-label {
  min-width: 150px;
  font-size: 0.875rem;
}

.category-weight {
  color: var(--text-secondary);
}

.progress-bar {
  flex: 1;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--grade-a);
  transition: width 0.3s;
}

.category-score {
  min-width: 50px;
  text-align: right;
  font-weight: 600;
}

/* Assignment Table */
.table-controls {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: var(--spacing-sm);
}

.select {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 0.875rem;
}

.search-input {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  min-width: 200px;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

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

.assignments-table th {
  background: var(--bg-secondary);
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.assignments-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.assignments-table th.sortable:hover {
  background: var(--bg-tertiary);
}

.assignments-table th.sortable::after {
  content: " ⇅";
  color: var(--text-secondary);
  font-size: 0.75rem;
  opacity: 0.5;
}

.assignments-table th.sortable.sorted-asc::after {
  content: " ↑";
  opacity: 1;
}

.assignments-table th.sortable.sorted-desc::after {
  content: " ↓";
  opacity: 1;
}

.assignments-table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
}

.assignments-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.assignments-table tbody tr:last-child td {
  border-bottom: none;
}

/* Row coloring based on grade - very subtle */
.assignments-table tbody tr.row-grade-a {
  background: var(--row-grade-a);
}

.assignments-table tbody tr.row-grade-b {
  background: var(--row-grade-b);
}

.assignments-table tbody tr.row-grade-c {
  background: var(--row-grade-c);
}

.assignments-table tbody tr.row-grade-d {
  background: var(--row-grade-d);
}

.assignments-table tbody tr.row-grade-f {
  background: var(--row-grade-f);
}

.assignments-table tbody tr.row-grade-a:hover,
.assignments-table tbody tr.row-grade-b:hover,
.assignments-table tbody tr.row-grade-c:hover,
.assignments-table tbody tr.row-grade-d:hover,
.assignments-table tbody tr.row-grade-f:hover {
  filter: brightness(0.97);
}

.note-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.note-badge.missing {
  background: var(--alert-critical);
  color: var(--alert-critical-border);
}

.note-badge.late {
  background: var(--alert-warning);
  color: #78350f;
}

.note-badge.low {
  background: var(--alert-warning);
  color: #78350f;
}

/* Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

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

  .table-controls {
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }
}

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

/* Alert clickable links */
.alert-class-link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted currentColor;
}

.alert-class-link:hover {
  border-bottom-style: solid;
}

/* Quarter switcher */
.quarter-switcher {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.quarter-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.quarter-btn:hover {
  background: var(--bg-tertiary);
}

.quarter-btn.active {
  background: var(--grade-a);
  color: white;
  border-color: var(--grade-a);
}

/* Fixed height for grade card subjects */
.grade-card-subject {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Weight indicator bar */
.weight-indicator {
  display: inline-block;
  height: 8px;
  background: var(--grade-b);
  border-radius: 4px;
  min-width: 4px;
}

/* Category breakdown alignment */
.category-item {
  display: grid;
  grid-template-columns: 200px 1fr 80px;
  gap: var(--spacing-md);
  align-items: center;
}

.category-label {
  min-width: auto;
}

.category-label-text {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Filter controls */
.filter-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 0.75rem;
  cursor: pointer;
}

.filter-select:hover {
  border-color: var(--text-secondary);
}

.filter-checkbox {
  cursor: pointer;
  margin-right: 0.25rem;
}

/* Recent assignment cards with color coding */
div.recent-assignment-card {
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  min-width: 80px;
  text-align: center;
  border: 2px solid transparent;
  transform: none !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
}

div.recent-assignment-card.grade-a {
  background: var(--row-grade-a);
  border-color: var(--grade-a);
}

div.recent-assignment-card.grade-b {
  background: var(--row-grade-b);
  border-color: var(--grade-b);
}

div.recent-assignment-card.grade-c {
  background: var(--row-grade-c);
  border-color: var(--grade-c);
}

div.recent-assignment-card.grade-d {
  background: var(--row-grade-d);
  border-color: var(--grade-d);
}

div.recent-assignment-card.grade-f {
  background: var(--row-grade-f);
  border-color: var(--grade-f);
}

/* Quarter comparison boxes with color coding */
.quarter-box.grade-a {
  border-color: var(--grade-a);
  background: var(--row-grade-a);
}

.quarter-box.grade-b {
  border-color: var(--grade-b);
  background: var(--row-grade-b);
}

.quarter-box.grade-c {
  border-color: var(--grade-c);
  background: var(--row-grade-c);
}

.quarter-box.grade-d {
  border-color: var(--grade-d);
  background: var(--row-grade-d);
}

.quarter-box.grade-f {
  border-color: var(--grade-f);
  background: var(--row-grade-f);
}

/* Quarter selected state - keep background, just make border thicker */
a.quarter-box.quarter-selected.grade-a {
  border: 3px solid var(--grade-a);
  transform: scale(1.02);
}

a.quarter-box.quarter-selected.grade-b {
  border: 3px solid var(--grade-b);
  transform: scale(1.02);
}

a.quarter-box.quarter-selected.grade-c {
  border: 3px solid var(--grade-c);
  transform: scale(1.02);
}

a.quarter-box.quarter-selected.grade-d {
  border: 3px solid var(--grade-d);
  transform: scale(1.02);
}

a.quarter-box.quarter-selected.grade-f {
  border: 3px solid var(--grade-f);
  transform: scale(1.02);
}

a.quarter-box:hover {
  transform: scale(1.05);
  transition: transform 0.2s ease;
}

/* Date formatting with muted weekday abbreviations */
.date-weekday {
  color: var(--text-secondary);
  opacity: 0.7;
  font-size: 0.85em;
}

/* Weekly Summary Card Styles */
.week-summary-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.week-summary-card.grade-a {
  border-color: var(--grade-a);
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    var(--row-grade-a) 100%
  );
}

.week-summary-card.grade-b {
  border-color: var(--grade-b);
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    var(--row-grade-b) 100%
  );
}

.week-summary-card.grade-c {
  border-color: var(--grade-c);
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    var(--row-grade-c) 100%
  );
}

.week-summary-card.grade-d {
  border-color: var(--grade-d);
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    var(--row-grade-d) 100%
  );
}

.week-summary-card.grade-f {
  border-color: var(--grade-f);
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    var(--row-grade-f) 100%
  );
}

.week-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
}

.week-summary-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-summary-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.week-summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.week-summary-flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.week-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
}

.week-flag.late {
  background: var(--alert-warning);
  border-color: var(--alert-warning-border);
}

.week-flag.missing {
  background: var(--alert-critical);
  border-color: var(--alert-critical-border);
}

.week-flag.perfect {
  background: var(--row-grade-a);
  border-color: var(--grade-a);
  color: var(--grade-a);
}

.grade-distribution-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
  margin-top: 4px;
}

.grade-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  transition: flex-grow 0.3s ease;
}

.grade-segment.a {
  background: var(--grade-a);
}
.grade-segment.b {
  background: var(--grade-b);
}
.grade-segment.c {
  background: var(--grade-c);
}
.grade-segment.d {
  background: var(--grade-d);
}
.grade-segment.f {
  background: var(--grade-f);
}

.trend-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.trend-indicator.up {
  background: var(--row-grade-a);
  color: var(--grade-a);
}

.trend-indicator.down {
  background: var(--row-grade-d);
  color: var(--grade-d);
}

.trend-indicator.stable {
  background: var(--bg);
  color: var(--text-secondary);
}
