.webinfo-period-container {
    padding: 32px 24px;
}
.webinfo-period-container .action-header {
    background-image: url("../../img/webinfo/period-background.png");
}
.webinfo-period-container .action-header,
.webinfo-period-container .action-header .action-header-content-wrapper {
    border-bottom-left-radius: 0px;
    border-bottom-right-radius: 0px;
}
.webinfo-period-container .period-tables-wrapper {
    flex-direction: column;
    gap: 24px
}
.webinfo-period-container .period-tables-wrapper table:not(:first-of-type) .primary-header th:first-of-type {
  border-top-left-radius: 24px;
}
.webinfo-period-container .period-tables-wrapper table:not(:first-of-type) .primary-header th:last-of-type {
  border-top-right-radius: 24px;
}
.webinfo-period-container .period-tables-wrapper table tr:last-of-type td:first-of-type {
  border-bottom-left-radius: 24px;
}
.webinfo-period-container .period-tables-wrapper table tr:last-of-type td:last-of-type {
  border-bottom-right-radius: 24px;
}
.webinfo-period-container table .primary-header th {
    font-size: 16px;
    font-weight: 500;
    padding: 22px 0;
    background-color: var(--fux-dark);
    color: #FFFFFF;
    text-align: center;
}
.webinfo-period-container table thead th {
  border-right: solid 1px var(--fux-dark);
  border-bottom: solid 1px var(--fux-dark);
}
.webinfo-period-container table thead th:last-of-type {
  border-right: none;
}
.webinfo-period-container table .secondary-header th {
    font-size: 14px;
    font-weight: 500;
    padding: 15px 0;
}
.webinfo-period-container table .primary-header,
.webinfo-period-container table td.average-cell,
.webinfo-period-container table th.average-cell {
    background-color: var(--fux-dark);
    border-color: var(--fux-dark);
    color: #FFFFFF;
    text-align: center;
}
.webinfo-period-container table .secondary-header,
.webinfo-period-container table td.highlight-cell {
    background-color: var(--fux-blue);
    border-color: var(--fux-dark);
    color: #FFFFFF;
    text-align: center;
    padding: 15px 0;
}
.webinfo-period-container table td {
    text-align: center;
    border: 1px solid var(--fux-blue);
}
.webinfo-period-container table td:not(:first-of-type) {
    width: 80px;
}
.webinfo-period-container table td:first-of-type {
    width: 240px;
}
.webinfo-period-container table tr:not(.highlight-cell) {
    border-color: var(--fux-dark);
}
.webinfo-period-container table td.average-cell,
.webinfo-period-container table th.average-cell {
    color: var(--fux-yellow);
}

.webinfo-period-container table {
  border-collapse: collapse;
  box-shadow: 4px 4px 4px #0000001A;
  border-radius: 24px;
  margin: 0;
}

.webinfo-period-container table td {
  border: 1px solid var(--fux-dark);
}

.webinfo-period-container table tr:first-child td {
  border-top: none;
}

.webinfo-period-container table tr:last-child td {
  border-bottom: none;
}

.webinfo-period-container table tr td:first-child {
  border-left: none;
}

.webinfo-period-container table tr td:last-child {
  border-right: none;
}
.subject-block .primary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--fux-dark);
    color: var(--fux-yellow);
    padding: 14px 28px;
}

.semester-wrapper .subject-block .primary-header {
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}
.semester-wrapper .subject-block .primary-header h3 {
  margin: 0;
}

.semester-wrapper .period-tables-wrapper .subject-block.visible:first-of-type .primary-header,
.semester-wrapper .period-tables-wrapper .subject-block.first-visible .primary-header {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.webinfo-period-container table td:not(.highlight-cell)  {
  vertical-align: middle;
}

.webinfo-period-container .subject-block table td.vertical-bottom  {
  vertical-align: bottom;
}
.webinfo-period-container .subject-block table tr.last-row:not(:last-of-type) {
  border-bottom: 4px solid var(--fux-dark);
}
.webinfo-period-container .subject-block table {
  border-radius: 0;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  overflow: hidden;
  table-layout: fixed;
  width: 100%;
}
.webinfo-period-container .subject-block table td,
.webinfo-period-container .subject-block table th {
  white-space: normal;
}

.webinfo-period-container .table>:not(:last-child)>:last-child>* {
  border-bottom-color: var(--fux-dark);
}

.semester-wrapper .period-tables-wrapper .subject-block.hidden,
.semester-wrapper .period-tables-wrapper .grade-row.hidden {
  display: none;
}
.grade-row.last-visible td {
  border-bottom: none;
}

.grade-row.last-visible td:first-child {
  border-bottom-left-radius: 24px;
}

.grade-row.last-visible td:last-child {
  border-bottom-right-radius: 24px;
}
.detailed-date-table table {
  table-layout: fixed;
}

/* Column width classes (replace inline styles for responsiveness) */
.col-w-nr { width: 50px; }
.col-w-grade { width: 80px; }
.col-w-date { width: 112px; }
.col-w-time { width: 110px; }

/* ============================================================
   SEMESTER COLLAPSE TOGGLE
   ============================================================ */

.semester-collapse-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.semester-collapse-toggle i {
    transition: transform 300ms ease;
}

/* When collapsed, round the bottom of the action header */
.semester-wrapper:has(.collapse:not(.show)) .action-header,
.semester-wrapper:has(.collapse:not(.show)) .action-header .action-header-content-wrapper {
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    transition: border-radius 150ms ease;
}

/* ============================================================
   COMPACT GRADE TABLE — Hybrid (Compact + Expandable)
   ============================================================ */

/* Compact row: clickable cursor, hover feedback */
.grades-table-compact .compact-row {
    cursor: pointer;
    transition: background-color 150ms ease;
}
.grades-table-compact .compact-row:hover {
    background-color: var(--fux-blue);
}
.grades-table-compact .compact-row:hover td {
    color: #ffffff;
}

/* Expand indicator icon */
.compact-row .expand-indicator {
    font-size: 12px;
    margin-left: 6px;
    transition: transform 200ms ease;
    display: inline-block;
}
.compact-row[aria-expanded="true"] .expand-indicator {
    transform: rotate(180deg);
}

/* Detail row: no border, no padding — collapse content handles it */
.grades-table-compact .detail-row td {
    border: none;
    padding: 0;
}

/* Grade detail content container */
.grade-detail-content {
    padding: 16px 24px;
    background-color: #f0f4f8;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-bottom: 2px solid var(--fux-dark);
}

/* Grade type section */
.grade-type-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grade-type-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--fux-blue);
}
.grade-type-header .grade-type-name {
    font-weight: 600;
    color: var(--fux-dark);
}
.grade-type-header .grade-type-avg {
    font-weight: 600;
    color: var(--fux-blue);
}

/* Grade chips: inline badges */
.grade-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.grade-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--fux-dark);
    color: #ffffff;
    border-radius: 12px;
    padding: 6px 12px;
    width: 56px;
    text-align: center;
    cursor: default;
}
.grade-chip .grade-value {
    font-weight: 700;
    font-size: 16px;
}
.grade-chip .grade-date {
    font-size: 10px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Chip fade-in animation when expanded */
.collapse.show .grade-chip {
    animation: chipFadeIn 200ms ease forwards;
}
@keyframes chipFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chips with comments get a visual indicator */
.grade-chip[data-bs-toggle="tooltip"] {
    border: 2px solid var(--fux-yellow);
}

/* ============================================================
   RESPONSIVE SEMESTER / GRADES VIEW
   ============================================================ */

@media (max-width: 1024px) {
    /* Let tables scroll horizontally */
    .webinfo-period-container .period-tables-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Relax fixed column widths */
    .webinfo-period-container table td:first-of-type {
        width: 180px;
        min-width: 140px;
    }
    .webinfo-period-container table td:not(:first-of-type) {
        width: 60px;
        min-width: 50px;
    }

    /* Responsive column width classes */
    .col-w-date { width: 100px; }
    .col-w-time { width: 100px; }
}

@media (max-width: 768px) {
    /* Semester action header */
    .webinfo-period-container .action-header {
        height: auto;
        border-radius: 16px;
    }
    .webinfo-period-container .action-header,
    .webinfo-period-container .action-header .action-header-content-wrapper {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }
    .webinfo-period-container .action-header .action-header-content-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 16px;
    }
    .webinfo-period-container .action-header h1 {
        font-size: 18px;
    }

    /* Buttons wrap on mobile */
    .webinfo-period-container .action-wrapper .d-flex {
        flex-wrap: wrap;
    }
    .webinfo-period-container .action-wrapper .btn {
        font-size: 12px;
        padding: 6px 10px;
        height: auto;
        min-height: 36px;
    }
    .webinfo-period-container .form-select {
        max-width: 100%;
    }

    /* Subject blocks */
    .subject-block .primary-header {
        padding: 10px 16px;
    }
    .subject-block .primary-header h3 {
        font-size: 16px;
    }

    /* Table columns: smaller */
    .webinfo-period-container table td:first-of-type {
        width: 120px;
        min-width: 100px;
    }
    .webinfo-period-container table td:not(:first-of-type) {
        width: 50px;
        min-width: 40px;
    }
    .webinfo-period-container table .primary-header th {
        font-size: 13px;
        padding: 12px 0;
    }
    .webinfo-period-container table .secondary-header th {
        font-size: 12px;
        padding: 8px 0;
    }

    /* Detailed view: auto layout for better mobile fit */
    .webinfo-period-container .subject-block table {
        table-layout: auto;
    }
    .detailed-date-table table {
        table-layout: auto;
    }

    /* Responsive column width classes */
    .col-w-nr { width: 40px; }
    .col-w-grade { width: 60px; }
    .col-w-date { width: 90px; }
    .col-w-time { width: 90px; }

    /* Rounded corners: tighter */
    .semester-wrapper .subject-block .primary-header {
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }

    /* Collapsed semester rounded corners on mobile */
    .semester-wrapper:has(.collapse:not(.show)) .action-header,
    .semester-wrapper:has(.collapse:not(.show)) .action-header .action-header-content-wrapper {
        border-bottom-left-radius: 16px;
        border-bottom-right-radius: 16px;
    }

    /* Grade detail content: tighter on mobile */
    .grade-detail-content {
        padding: 12px 16px;
    }
    .grade-chip {
        padding: 4px 8px;
        width: 46px;
        border-radius: 8px;
    }
    .grade-chip .grade-value {
        font-size: 14px;
    }
    .grade-chip .grade-date {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .webinfo-period-container table td:first-of-type {
        width: 100px;
        min-width: 80px;
        font-size: 12px;
    }
    .webinfo-period-container table td:not(:first-of-type) {
        width: 40px;
        min-width: 36px;
        font-size: 12px;
    }
    .webinfo-period-container table .primary-header th {
        font-size: 12px;
        padding: 8px 0;
    }

    /* Responsive column width classes */
    .col-w-nr { width: 35px; }
    .col-w-grade { width: 50px; }
    .col-w-date { width: 80px; }
    .col-w-time { width: 80px; }

    /* Grade detail content: minimal on small phones */
    .grade-detail-content {
        padding: 8px 12px;
    }
    .grade-chips {
        gap: 6px;
    }
    .grade-chip {
        padding: 3px 6px;
        width: 42px;
    }
}
