/* ==========================================================================
   GRADE CALCULATOR - STYLES
   Exact replica of reference image & Calculator Archive design system
   ========================================================================== */

.grade-page-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 18px 40px;
  font-family: Arial, Helvetica, sans-serif;
  color: #333333;
}

/* Top Bar & Breadcrumbs */
.grade-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.grade-breadcrumbs {
  font-size: 13px;
  color: #555555;
  margin-bottom: 0;
}

.grade-breadcrumbs a {
  color: #0844a4;
  text-decoration: none;
}

.grade-breadcrumbs a:hover {
  text-decoration: underline;
}

.grade-breadcrumbs .sep {
  margin: 0 4px;
  color: #666666;
}

.grade-breadcrumbs .current {
  color: #0844a4;
  font-weight: normal;
}

.grade-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grade-top-btn {
  background: #ffffff;
  border: 1px solid #7f9db9;
  color: #0844a4;
  font-size: 12px;
  font-weight: bold;
  padding: 3px 9px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.grade-top-btn:hover {
  background: #f0f4f8;
  border-color: #0b386b;
  color: #0b386b;
}

.grade-top-btn svg {
  width: 13px;
  height: 13px;
}

/* Page Title & Intro matching Screenshot */
.grade-title {
  font-size: 24px;
  font-weight: bold;
  color: #0844a4;
  margin: 4px 0 6px 0;
  line-height: 1.2;
}

.grade-intro-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #222222;
  margin: 0 0 16px 0;
  max-width: 820px;
}

/* Main Layout: 2 Columns */
.grade-main-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.grade-calc-col {
  flex: 1;
  min-width: 0;
}

.grade-sidebar-col {
  width: 250px;
  flex-shrink: 0;
}

/* Main Grade Calculator Card Container */
.grade-calc-box {
  background: #f2f5f8;
  border: 1px solid #c9d7e4;
  padding: 12px;
  margin-bottom: 24px;
  max-width: 440px;
}

/* Table styling matching exact clone */
.grade-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #7f9db9;
  font-size: 13px;
}

.grade-table th {
  background: #e6edf5;
  color: #1a3962;
  font-weight: bold;
  font-size: 12.5px;
  text-align: center;
  padding: 5px 6px;
  border: 1px solid #b2c5d9;
  line-height: 1.2;
}

.grade-table th.th-assign {
  width: 58%;
  text-align: center;
}

.grade-table th.th-grade {
  width: 22%;
  text-align: center;
}

.grade-table th.th-weight {
  width: 20%;
  text-align: center;
}

.grade-table td {
  padding: 2px 3px;
  border: 1px solid #c9d7e4;
  vertical-align: middle;
}

.grade-input-cell {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 5px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #7f9db9;
  outline: none;
  background: #ffffff;
}

.grade-input-cell:focus {
  border-color: #0844a4;
  box-shadow: inset 0 0 1px #0844a4;
}

.grade-weight-cell-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.grade-weight-cell-wrap input {
  flex: 1;
  min-width: 0;
}

.grade-weight-cell-wrap .pct-sign {
  font-size: 13px;
  color: #333333;
  padding-right: 2px;
}

.grade-add-row-wrap {
  padding: 6px 4px 10px;
  background: #f2f5f8;
}

.grade-add-row-link {
  color: #0844a4;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  display: inline-block;
  font-weight: normal;
}

.grade-add-row-link:hover {
  color: #0b386b;
}

/* Final Grade Planning (Optional) Section inside Box */
.grade-planning-section {
  border: 1px solid #2b5b84;
  background: #ffffff;
  margin-top: 4px;
  margin-bottom: 12px;
}

.grade-planning-header {
  background: #2b5b84;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
  padding: 4px 8px;
  text-align: left;
}

.grade-planning-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #ffffff;
}

.grade-planning-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.grade-planning-label {
  color: #222222;
  display: flex;
  align-items: center;
  gap: 4px;
}

.grade-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c9d7e4;
  color: #1a3962;
  font-size: 10px;
  font-weight: bold;
  cursor: help;
}

.grade-planning-input-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100px;
}

.grade-planning-input {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 5px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #7f9db9;
  outline: none;
}

.grade-planning-input:focus {
  border-color: #0844a4;
}

/* Buttons Row */
.grade-btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.grade-calc-btn {
  background: #2e7d32;
  color: #ffffff;
  border: 1px solid #1b5e20;
  font-size: 13px;
  font-weight: bold;
  padding: 5px 14px;
  cursor: pointer;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.grade-calc-btn:hover {
  background: #256628;
}

.grade-calc-btn .calc-arrow {
  font-size: 10px;
  line-height: 1;
}

.grade-clear-btn {
  background: #888888;
  color: #ffffff;
  border: 1px solid #666666;
  font-size: 13px;
  font-weight: bold;
  padding: 5px 14px;
  cursor: pointer;
  border-radius: 2px;
  font-family: inherit;
}

.grade-clear-btn:hover {
  background: #737373;
}

.grade-settings-link {
  color: #0844a4;
  font-size: 13px;
  font-weight: bold;
  text-decoration: underline;
  cursor: pointer;
  margin-left: 6px;
}

.grade-settings-link:hover {
  color: #0b386b;
}

/* ==========================================================================
   2. FINAL GRADE CALCULATOR (Below the main calculator)
   ========================================================================== */
.final-grade-title {
  font-size: 18px;
  font-weight: bold;
  color: #0844a4;
  margin: 28px 0 6px 0;
  line-height: 1.2;
}

.final-grade-intro {
  font-size: 13px;
  line-height: 1.5;
  color: #222222;
  margin: 0 0 14px 0;
  max-width: 820px;
}

.final-grade-box {
  background: #f2f5f8;
  border: 1px solid #c9d7e4;
  padding: 14px;
  margin-bottom: 24px;
  max-width: 380px;
}

.final-grade-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.final-grade-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.final-grade-label {
  font-weight: bold;
  color: #222222;
}

.final-grade-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 120px;
}

.final-grade-input {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 5px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #7f9db9;
  outline: none;
}

.final-grade-input:focus {
  border-color: #0844a4;
}

/* ==========================================================================
   3. LETTER GRADE REFERENCE TABLE (Exact match to Image 2)
   ========================================================================== */
.grade-ref-text {
  font-size: 13px;
  line-height: 1.5;
  color: #222222;
  margin: 24px 0 12px 0;
  max-width: 820px;
}

.grade-ref-table-wrap {
  max-width: 280px;
  margin-bottom: 32px;
}

.grade-ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid #7f9db9;
  text-align: center;
}

.grade-ref-table th {
  background: #2b5b84;
  color: #ffffff;
  font-weight: bold;
  padding: 4px 6px;
  border: 1px solid #2b5b84;
  font-size: 12.5px;
}

.grade-ref-table td {
  padding: 3px 6px;
  border: 1px solid #d0dbe5;
  background: #ffffff;
}

.grade-ref-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* ==========================================================================
   4. FRACTION ARITHMETIC & MEASUREMENT SOLVER
   ========================================================================== */
.grade-fraction-tool {
  background: #ffffff;
  border: 1px solid #c9d7e4;
  border-radius: 4px;
  padding: 16px;
  margin-top: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.grade-fraction-title {
  font-size: 16px;
  font-weight: bold;
  color: #0844a4;
  margin-bottom: 6px;
}

.grade-fraction-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
  margin-bottom: 14px;
}

.grade-fraction-calc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.grade-fraction-input-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.grade-fraction-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
}

.grade-fraction-stack input {
  width: 100%;
  height: 24px;
  text-align: center;
  font-size: 13px;
  border: 1px solid #7f9db9;
  box-sizing: border-box;
  padding: 2px;
}

.grade-fraction-divider {
  width: 100%;
  height: 1.5px;
  background: #333333;
  margin: 2px 0;
}

.grade-fraction-op-select {
  height: 32px;
  font-size: 16px;
  font-weight: bold;
  border: 1px solid #7f9db9;
  padding: 0 6px;
  background: #ffffff;
  cursor: pointer;
}

.grade-fraction-result {
  background: #f0f7ff;
  border-left: 4px solid #0844a4;
  padding: 10px 14px;
  font-size: 13.5px;
  color: #1e293b;
  margin-top: 10px;
  border-radius: 0 4px 4px 0;
}

/* ==========================================================================
   5. RESULTS CARDS & VISUALIZATIONS
   ========================================================================== */
.grade-result-card {
  background: #ffffff;
  border: 1px solid #7f9db9;
  border-radius: 3px;
  padding: 16px;
  margin-top: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.grade-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0844a4;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.grade-result-title {
  font-size: 16px;
  font-weight: bold;
  color: #0844a4;
  margin: 0;
}

.grade-result-actions {
  display: flex;
  gap: 6px;
}

.grade-res-btn {
  background: #ffffff;
  border: 1px solid #7f9db9;
  color: #0844a4;
  font-size: 11.5px;
  font-weight: bold;
  padding: 2px 7px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.grade-res-btn:hover {
  background: #f0f4f8;
}

.grade-result-highlight {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f4f8fb;
  border: 1px solid #d2e1ee;
  border-radius: 3px;
  padding: 12px 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.grade-big-score {
  font-size: 28px;
  font-weight: bold;
  color: #2e7d32;
}

.grade-letter-badge {
  background: #0844a4;
  color: #ffffff;
  font-size: 15px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 3px;
}

.grade-status-badge {
  font-size: 12.5px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 3px;
}

.status-achievable {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.status-secured {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
}

.status-challenging {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}

.status-unattainable {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

/* Metrics Grid */
.grade-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.grade-metric-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 8px 10px;
  text-align: center;
}

.grade-metric-label {
  font-size: 11.5px;
  color: #64748b;
  display: block;
  margin-bottom: 3px;
}

.grade-metric-val {
  font-size: 15px;
  font-weight: bold;
  color: #1e293b;
}

/* Charts & Visuals Container */
.grade-charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

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

.grade-chart-box {
  background: #fdfdfd;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 10px;
}

.grade-chart-title {
  font-size: 12.5px;
  font-weight: bold;
  color: #1a3962;
  margin-bottom: 8px;
  text-align: center;
}

/* Linear Scale Gauge */
.grade-gauge-wrap {
  margin: 14px 0 10px;
}

.grade-gauge-bar {
  height: 16px;
  background: linear-gradient(to right, #ef4444 0%, #f97316 60%, #eab308 75%, #3b82f6 85%, #22c55e 95%, #15803d 100%);
  border-radius: 3px;
  position: relative;
  margin-bottom: 4px;
}

.grade-gauge-pointer {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  width: 4px;
  height: 24px;
  background: #000000;
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.grade-gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: #64748b;
  font-weight: bold;
}

/* ==========================================================================
   6. RIGHT SIDEBAR (EXACT CLONE OF IMAGE 2)
   ========================================================================== */
.grade-search-form {
  position: relative;
  margin-bottom: 14px;
  display: flex;
  gap: 4px;
}

.grade-search-input {
  flex: 1;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid #7f9db9;
  font-size: 12.5px;
  box-sizing: border-box;
  font-family: inherit;
  outline: none;
}

.grade-search-input:focus {
  border-color: #0844a4;
}

.grade-search-btn {
  background: #2b5b84;
  color: #ffffff;
  border: 1px solid #1c3c57;
  font-size: 12.5px;
  font-weight: bold;
  padding: 0 10px;
  height: 24px;
  cursor: pointer;
  border-radius: 2px;
  font-family: inherit;
}

.grade-search-btn:hover {
  background: #1c3c57;
}

.grade-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #7f9db9;
  border-top: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.grade-search-dropdown.active {
  display: block;
}

.grade-search-item {
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grade-search-item:hover,
.grade-search-item.selected {
  background: #f0f4f8;
  color: #0844a4;
}

.grade-search-item-cat {
  font-size: 10.5px;
  color: #888888;
}

/* Other Calculators Card */
.grade-side-card {
  background: #ffffff;
  border: 1px solid #2b5b84;
  border-radius: 0;
}

.grade-side-card-header {
  background: #2b5b84;
  color: #ffffff;
  font-weight: bold;
  font-size: 13px;
  padding: 4px 8px;
}

.grade-side-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px 10px;
  gap: 4px 12px;
  font-size: 12.5px;
}

.grade-side-card-grid a {
  color: #0844a4;
  text-decoration: underline;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grade-side-card-grid a:hover {
  color: #0b386b;
}

.grade-side-card-grid a.active {
  font-weight: bold;
  color: #000000;
  text-decoration: none;
}

.grade-side-card-footer {
  border-top: 1px solid #e0e0e0;
  padding: 6px 8px;
  font-size: 11.5px;
  background: #f8fafc;
  color: #666666;
  text-align: center;
}

.grade-side-card-footer a {
  color: #0844a4;
  text-decoration: underline;
  margin: 0 2px;
}

.grade-side-card-footer a:hover {
  color: #0b386b;
}

/* ==========================================================================
   7. SEO / AEO / GEO ARTICLES & FAQ
   ========================================================================== */
.grade-content-article {
  margin-top: 36px;
  border-top: 1px solid #e2e8f0;
  padding-top: 24px;
}

.grade-article-title {
  font-size: 20px;
  font-weight: bold;
  color: #0844a4;
  margin-bottom: 14px;
}

.grade-article-p {
  font-size: 13.5px;
  line-height: 1.6;
  color: #334155;
  margin-bottom: 12px;
}

.grade-formula-box {
  background: #f8fafc;
  border-left: 4px solid #2b5b84;
  padding: 12px 16px;
  margin: 14px 0;
  font-family: Consolas, monospace;
  font-size: 13px;
  color: #1e293b;
}

.grade-faq-section {
  margin-top: 28px;
}

.grade-faq-item {
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  margin-bottom: 8px;
  background: #ffffff;
}

.grade-faq-q {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: bold;
  color: #1a3962;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.grade-faq-q:hover {
  background: #f1f5f9;
}

.grade-faq-q svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.grade-faq-item.open .grade-faq-q svg {
  transform: rotate(180deg);
}

.grade-faq-a {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
  border-top: 1px solid #e2e8f0;
  display: none;
}

.grade-faq-item.open .grade-faq-a {
  display: block;
}

/* ==========================================================================
   8. MODALS (History, Settings, Print Preview)
   ========================================================================== */
.grade-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 14px;
}

.grade-modal-backdrop.active {
  display: flex;
}

.grade-modal-dialog {
  background: #ffffff;
  border-radius: 4px;
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  overflow: hidden;
}

.grade-modal-header {
  background: #2b5b84;
  color: #ffffff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grade-modal-title {
  font-size: 15px;
  font-weight: bold;
  margin: 0;
}

.grade-modal-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.grade-modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 13px;
}

.grade-modal-footer {
  padding: 10px 14px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.grade-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 9px 16px;
  border-radius: 4px;
  font-size: 12.5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 20000;
}

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

/* Print Sheet Styling */
@media print {
  .site-header,
  .grade-top-bar,
  .grade-sidebar-col,
  .grade-fraction-tool,
  .grade-content-article,
  .site-footer,
  .grade-modal-backdrop,
  .grade-btn-row,
  .grade-add-row-wrap {
    display: none !important;
  }

  body, .grade-page-container {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .grade-main-layout {
    display: block !important;
  }

  .grade-calc-box, .final-grade-box {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
  }

  .grade-result-card {
    border: 2px solid #000000 !important;
    page-break-inside: avoid;
    margin-top: 20px !important;
  }
}

/* Responsive adjustments */
@media (max-width: 800px) {
  .grade-main-layout {
    flex-direction: column;
  }

  .grade-sidebar-col {
    width: 100%;
    margin-top: 24px;
  }

  .grade-calc-box, .final-grade-box {
    max-width: 100%;
  }
}
