/* FinalGrade — calculator widget: shared inputs, four panels, letter table. */

.fg {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.3rem 1.25rem 1.1rem;
  margin: 1.4rem 0 1.8rem;
}

/* shared inputs */
.fg-controls,
.fg-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: flex-end;
}
.fg-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-dim);
  flex: 1 1 9rem;
  min-width: 0;
  max-width: 100%;
}
.fg-field--s { flex: 0 1 8.5rem; }

.fg input[type="text"],
.fg select {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  width: 100%;
  max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fg select { cursor: pointer; }
.fg input:focus,
.fg select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

/* panels */
.fg-panel {
  margin-top: 1.3rem;
  border-top: 2px dashed var(--border);
  padding-top: 1rem;
}
.fg-panel > h2 { margin-top: 0; font-size: 1.15rem; }
.fg-panel-sub {
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.fg-panel .fg-field { max-width: 16rem; }

/* outputs */
.fg-out {
  display: block;
  margin-top: 0.9rem;
  min-height: 1.6rem;
}
.fg-scoreline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.fg-scoreline strong {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.fg-sub {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 550;
}
.fg-hint { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); }
.fg-error { font-size: 0.95rem; font-weight: 600; color: #b91c1c; }
.fg-dim { color: var(--text-dim); font-weight: 500; }

/* chips */
.fg-chip {
  display: inline-block;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  color: #fff;
  background: var(--text-dim);
}
.g-A { background: #15803d; }
.g-B { background: #0f766e; }
.g-C { background: #b45309; }
.g-D { background: #c2410c; }
.g-F { background: #b91c1c; }
.g-ok { background: #15803d; }

/* tables (letter boundaries, multi items, categories) */
.fg-scroll { overflow-x: auto; margin-top: 0.9rem; }
.fg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}
.fg-table th,
.fg-table td {
  padding: 0.3rem 0.45rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.fg-table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.fg-num { font-variant-numeric: tabular-nums; }
.fg-st { font-weight: 700; font-size: 0.85rem; }
.fg-st-ok { color: #15803d; }
.fg-st-yes { color: #0f766e; }
.fg-st-no { color: #b91c1c; }
tr.fg-no td { opacity: 0.55; }

.fg-table input { padding: 0.35rem 0.5rem !important; font-size: 0.92rem !important; }
.fg-table th.fg-w, .fg-table td[data-th="Weight %"],
.fg-table td[data-th="Peso %"] { width: 6rem; }
.fg-table td[data-th="Average %"],
.fg-table td[data-th="Promedio %"] { width: 7rem; }
.fg-rowx { width: 2.2rem; text-align: center !important; }
.fg-rowx button {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  min-width: 2.25rem;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fg-rowx button:hover { color: #b91c1c; background: color-mix(in srgb, #b91c1c 10%, transparent); }

.fg-add {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--primary);
  background: var(--bg);
  border: 1.5px solid color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  margin-top: 0.6rem;
}
.fg-add:hover { border-color: var(--primary); }

@media (max-width: 560px) {
  .fg { padding: 1rem 0.85rem; }
  .fg-scoreline strong { font-size: 1.75rem; }
  /* stacked-row table on narrow screens */
  .fg-table.fg-stack thead { display: none; }
  .fg-table.fg-stack tr {
    display: grid;
    grid-template-columns: 1fr 5rem;
    gap: 0.35rem 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }
  .fg-table.fg-stack td { border: none; padding: 0; }
  .fg-table.fg-stack td::before {
    content: attr(data-th);
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 700;
    margin-bottom: 0.15rem;
  }
  .fg-table.fg-stack .fg-rowx { grid-row: 1 / 3; grid-column: 2; align-self: center; width: auto; }
}
