main{
    width: 100%;
    padding: 0px 4em;
}

.banner{
    margin-top: 150px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.banner-left{
    display: flex;
    gap: 20px;
    align-items: center;
}

.banner-icon{
    width: 75px;
    height: 75px;
    background-color: var(--secondary-color);
    border-radius: 15px;
    padding: 16px;
    outline: 1px solid var(--tertiary-color);
}

.banner-icon img{
    width: 100%;
    height: auto;
}

.banner-info h1{
    margin: 0;
    padding: 0;
}

.banner-info p{
    margin: 5px 0;
    padding: 0;
}

.tip{
    display: flex;
    justify-content: center;
    background: var(--secondary-color);
    border: 1px solid var(--tertiary-color);
    border-radius: 15px;
    padding: 10px 20px;
    gap: 15px;
    max-width: 500px;
}

.tip img{
    width: 30px;
}

.past-papers-search{
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 20px;
}

.past-paper-filters{
    display: flex;
    gap: 20px;
}

/* Field */
.field{
    position: relative;
    width: 200px;
    padding: 14px 20px 14px 22px;
    background: var(--secondary-color);
    border: 1px solid var(--tertiary-color);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color 0.2s ease;
    display: block;
    user-select: none;
}

.field-value {
    display: block;
    color: var(--black);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
}

.field:hover{ 
    border-color: var(--accent-color);
}
.field:focus-within{ 
    border-color: var(--accent-color); 
}

.field-label{
    display: block;
    color: var(--black);
    opacity: 0.8;
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 4px;
    letter-spacing: 0.01em;
    pointer-events: none;
}

.field-select{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: transparent;        /* native value text is hidden — we render our own */
    font-size: 17px;           /* keeps select's invisible-row height stable */
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* iOS Safari adds a tap highlight; suppress it */
    -webkit-tap-highlight-color: transparent;
    z-index: 2;
}

.field-select option{
    background: var(--white);
    color: var(--black);
    font-weight: 500;
}

.field-label,
.field-value {
    position: relative;
    z-index: 1;
}

.field-chevron{
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--tertiary-color);
    transition: transform 0.2s ease;
    z-index: 1;
}

.field:focus-within .field-chevron{
    transform: translateY(-50%) rotate(180deg);
}


.search-bar{
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
}

.search-bar input{
    height: 50px;
    padding: 14px 20px 14px 45px;
    background: var(--secondary-color);
    border: 1px solid var(--tertiary-color);
    border-radius: 14px;
    width: 350px;
}

.search-btn{
    border: none;
    background: none;
    cursor: pointer;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-btn img{
    width: 100%;
    opacity: 50%;
}

.past-papers{
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.past-paper-table{
    width: 100%;
    border: 1px solid var(--tertiary-color);
    border-radius: 8px;
    overflow: hidden;
}

/* Collapsible */
.collapsible{
    background-color: var(--secondary-color);
    color: var(--black);
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1em;
    display: flex;
    justify-content: space-between;
    align-items: center;

}

.collapsible-title{
    display: flex;
    align-items: center;
    gap: 15px;
}

.collapsible-title h2{
    margin: 0;
    padding: 0;
}

.collapsible img{
    width: 40px;
}

.content{
    overflow: hidden;
    background-color: var(--primary-color);
    transition: max-height 0.2s ease-out;
    max-height: 0;
}

.collapsible:after {
    content: 'Expand';
    font-size: 1em;
    color: var(--accent-color);
    float: right;
    margin-left: 5px;
}

.active:after {
    content: "Collapse";
}

/* Table */
table{
    width: 100%;
    border-collapse: collapse;
}

td, th {
  padding: 8px;
}

th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: var(--primary-color);
  color: var(--black);
}

tr{
    background-color: var(--secondary-color);
    border-bottom: 1px solid var(--tertiary-color);
}

.table-files{
    height: 67px;
    display: flex;
    align-items: center;
}

.file-type{
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-type img{
    width: 24px;
}

.table-year{
    width: 100px;
    text-align: center;
}

.table-paper{
    width: 30%;
    padding-left: 20px;
}

.table-files{
    display: flex;
    gap: 10%;
}

.table-downloads{
    width: 200px;
}

.table-downloads a{
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-color);
    font-weight: 600;
    text-decoration: none;
}

.table-downloads a:hover{
    text-decoration: underline;
}

.table-downloads a img{
    width: 20px;
}

.file-type-download{
    text-decoration: none;
    color: var(--black);
}

.file-type-download:hover{
    text-decoration: underline;
}

.past-papers-status {
    text-align: center;
    padding: 18px 20px;
    margin: 16px 0 0;
    color: var(--black);
    opacity: 0.7;
    font-size: 0.95rem;
    background: var(--secondary-color);
    border-radius: 12px;
}

.past-papers-status.is-error {
    color: var(--accent-color);
    opacity: 1;
    font-weight: 600;
}

/* "No papers in this period" message inside an empty bucket */
.bucket-empty {
    margin: 0;
    padding: 24px 20px;
    text-align: center;
    color: var(--black);
    opacity: 0.55;
    font-size: 0.95rem;
}

/* ============================================================
   Responsive — Tablet  (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    main {
        padding: 0 2em;
    }

    .past-papers-search {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .past-paper-search-form,
    .search-bar {
        width: 100%;
    }

    .search-bar input {
        width: 100%;
    }

    .table-files {
        flex-direction: column;
        height: auto;
        gap: 8px;
        padding: 8px 0;
    }
}

/* ============================================================
   Responsive — Mobile  (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
    main {
        padding: 0 1em;
    }

    .banner {
        margin-top: 90px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .tip-desktop {
        display: none;
    }

    .banner-icon {
        width: 56px;
        height: 56px;
        padding: 12px;
    }

    .past-paper-filters {
        flex-direction: column;
    }

    .field {
        width: 100%;
    }

    /* ---- Card layout for table rows ---- */
    table,
    tbody,
    tr,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    table {
        padding: 12px;
    }

    tr {
        border: 1px solid var(--tertiary-color);
        border-radius: 8px;
        padding: 12px 14px;
        margin-bottom: 8px;
    }

    tr:last-child {
        margin-bottom: 0;
    }

    td {
        padding: 3px 0;
        text-align: left;
    }

    .table-year {
        width: auto;
        text-align: left;
        font-size: 0.82rem;
        opacity: 0.65;
    }

    .table-paper {
        width: auto;
        padding-left: 0;
        font-weight: 600;
        padding-bottom: 10px;
        border-bottom: 1px solid color-mix(in srgb, var(--tertiary-color) 40%, transparent);
        margin-bottom: 8px;
    }

    .table-files {
        display: flex;
        flex-direction: column;
        height: auto;
        gap: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid color-mix(in srgb, var(--tertiary-color) 40%, transparent);
        margin-bottom: 6px;
    }

    .table-downloads {
        width: auto;
    }
}
