/* ============================================================
   UFAZ GPA Calculator — Exam Schedule Module  (v2 – fixed)
   File:    exam-schedule.css

   FIX #4: .exam-row uses CSS Grid so columns always align.
   FIX #5: Responsive mobile layout — compact, full-width btns.
============================================================ */

.exam-module {
    margin-top: 1.8rem;
    background: var(--bg-ue, #0d150d);
    border: 2px solid var(--blue-accent, #5fbfd0);
    border-radius: 24px;
    padding: clamp(0.7rem, 2.5vw, 1.2rem) clamp(0.8rem, 2.5vw, 1.5rem);
    box-shadow: 0 0 0 1px rgba(0,204,77,0.4), 0 4px 12px rgba(0,0,0,0.2);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.exam-module-header {
    text-align: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0,204,77,0.25);
}
.exam-module-header h2 {
    font-size: clamp(0.95rem, 4vw, 1.3rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--grad-main-a, #c0ffc0), var(--accent, #00cc4d));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}
.exam-module-sub {
    font-size: 0.72rem;
    color: var(--text-muted, #9bbf9b);
    margin-top: 0.25rem;
}

/* ---- Notification permission banner ---- */
.exam-notify-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(230, 184, 62, 0.08);
    border: 1px solid var(--gold-border, #d4a230);
    border-radius: 14px;
    padding: 0.55rem 0.8rem;
    margin-bottom: 1rem;
    font-size: 0.78rem;
    color: var(--comp-label-text, #f7e5b3);
}
.exam-notify-banner[hidden] { display: none; }

.exam-enable-btn {
    background: linear-gradient(135deg, var(--gold, #e6b83e), var(--gold-border, #d4a230));
    color: #1a1400;
    flex-shrink: 0;
}
.exam-enable-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Add-exam form ---- */
.exam-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.7rem;
    align-items: end;
    margin-bottom: 1.2rem;
}
.exam-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}
.exam-field label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted, #9bbf9b);
    white-space: nowrap;
}
.exam-field select,
.exam-field input[type="datetime-local"] {
    background: var(--field-bg, #0b140b);
    border: 1px solid var(--border-medium, #2e6a2e);
    color: var(--text-bright, #e2ffe2);
    padding: 0.48rem 0.55rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.82rem;
    width: 100%;
    min-width: 0;
}
/*
  iOS Safari renders <input type="datetime-local"> at its own
  intrinsic content width and ignores a plain `width: 100%` set on
  a flex/grid child, which is why the field pushed past the
  Academic Planner card on iPhone/iPad while Android/desktop were
  fine. The 1px/min-width:100% pair forces Safari to compute the
  width from the surrounding layout instead of the field's content.
*/
.exam-field input[type="datetime-local"] {
    width: 1px;
    min-width: 100%;
    max-width: 100%;
}
.exam-field select:disabled { opacity: 0.5; cursor: not-allowed; }
.exam-field select:focus,
.exam-field input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--accent, #00cc4d);
    box-shadow: 0 0 0 2px var(--accent-glow, rgba(0,204,77,0.25));
}
.exam-field input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.6);
    cursor: pointer;
}

.exam-add-btn {
    background: linear-gradient(135deg, var(--accent, #00cc4d), #009933);
    color: #ffffff;
    white-space: nowrap;
    align-self: end;
    padding: 0.48rem 1rem;
}

/* ---- FIX #4: Exam list — grid alignment ---- */
.exam-list-wrap { margin-top: 0.4rem; }
.exam-list-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted, #9bbf9b);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}
.exam-empty-state {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted, #9bbf9b);
    padding: 0.8rem 0;
}

.exam-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/*
  Desktop grid — 4 explicit columns:
    [subject+comp] [date 190px] [countdown 110px] [del 36px]
  .exam-row-meta uses display:contents so its children (date, countdown)
  flow directly into the parent grid as individual cells.
*/
.exam-row {
    background: var(--bg-card, #111a11);
    border: 1px solid var(--border-medium, #3a5a3a);
    border-left: 4px solid var(--accent, #00cc4d);
    border-radius: 14px;
    padding: 0.55rem 0.8rem;
    display: grid;
    grid-template-columns: 1fr 190px 110px 36px;
    align-items: center;
    gap: 0 0.6rem;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Makes the wrapper transparent to the grid — its children become direct cells */
.exam-row-meta {
    display: contents;
}

.exam-row-main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    padding: 0.2rem 0;
}
.exam-row-subject {
    font-weight: 700;
    color: var(--text-bright, #e2ffe2);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.exam-row-component {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gold, #e6b83e);
    letter-spacing: 0.3px;
}
.exam-row-date {
    font-size: 0.72rem;
    color: var(--text-muted, #9bbf9b);
    font-family: monospace;
    white-space: nowrap;
    line-height: 1.3;
}
.exam-row-countdown {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent, #00cc4d);
    background: #0e1a0e;
    padding: 0.18rem 0.5rem;
    border-radius: 20px;
    white-space: nowrap;
    text-align: center;
    justify-self: start;
}
.exam-row-countdown.overdue {
    color: var(--red-elegant, #b55757);
    background: var(--red-glow, rgba(181,87,87,0.1));
}
.exam-delete-btn {
    background: transparent;
    border: 1px solid var(--red-elegant, #b55757);
    color: var(--red-elegant, #b55757);
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.exam-delete-btn:hover {
    background: var(--red-elegant, #b55757);
    color: #fff;
}

/* ---- FIX #5: Mobile ≤ 600px ---- */
@media (max-width: 600px) {
    /* Form: 2 columns */
    .exam-form {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
    }
    .exam-form .exam-field:nth-child(1) { grid-column: 1 / -1; }
    .exam-form .exam-field:nth-child(2) { grid-column: 1; }
    .exam-form .exam-field:nth-child(3) { grid-column: 2; }
    .exam-add-btn { grid-column: 1 / -1; width: 100%; justify-content: center; }

    /*
      Mobile rows: 2-column grid. exam-row-meta reverts from
      display:contents to a normal flex row so date+countdown
      sit together on one line under the subject.
    */
    .exam-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.3rem 0.5rem;
        padding: 0.5rem 0.6rem;
    }
    .exam-row-main        { grid-column: 1; grid-row: 1; }
    .exam-row-meta        { display: flex; flex-direction: row; flex-wrap: wrap;
                            gap: 0.4rem; align-items: center;
                            grid-column: 1; grid-row: 2; }
    .exam-delete-btn      { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

    .exam-row-subject     { white-space: normal; font-size: 0.84rem; }
    .exam-row-date        { font-size: 0.67rem; white-space: normal; }
    .exam-row-countdown   { font-size: 0.64rem; }
}

@media (max-width: 380px) {
    .exam-module { padding: 0.55rem 0.55rem; }
    .exam-row    { padding: 0.4rem 0.5rem; }
}
