/* RMA page — same layout as the Start Date page: header, then a table of requests */

.rma-page{
    margin: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.rma-page::before{
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: #fff;
    z-index: 1000;
}

.rma-page .pannel{
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.rma-page .pTop{
    flex-shrink: 0;
    margin-bottom: 0;
    border-bottom: 2px solid #000000;
    padding: 1%;
    padding-top: max(1%, env(safe-area-inset-top));
}

.rma-page .pBottom{
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 3% 5%;
}

.rma-page .scroll-area{
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
}

.rma-page .scroll-area::-webkit-scrollbar{
    display: none;
}

/* "Request RMA" — same as "Create New Job" */
.rma-new{
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
    border: #000 solid 1px;
    color: black;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s;
}

.rma-new:hover{
    background-color: #f0f0f0;
}

/* #region table */
.row-head, .rma-row{
    display: grid;
    grid-template-columns: 170px 2fr 1.5fr 2fr 130px 100px; /* RMA #, job, vendor, part, status, date */
    align-items: center;
}

.row-head{
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #f2f2f2;
    border-bottom: 2px solid #000000;
    font-weight: bold;
}

.row-head > div, .rma-row > div{
    padding: 10px 12px;
    text-align: left;
    min-width: 0;
}

.rma-row{
    border-bottom: 1px solid #ececec;
    background: #fff;
    cursor: pointer;
}

.rows-container .rma-row:nth-child(even){
    background: #f7f7f7;
}

.rows-container .rma-row:hover{
    background: #f0f0f0;
}

.rma-row .rma-num{
    color: #222;
    font-weight: 500;
    overflow-wrap: anywhere; /* a very long number goes to a second line, never cut off */
}

.rma-row .name{
    font-weight: 600;
    color: #111;
}

/* part · vendor under the job name — phone only (they have their own columns on a computer) */
.rma-sub{
    display: none;
    font-size: 11px;
    font-weight: 400;
    color: #777;
    margin-top: 2px;
}

.rma-row .rma-date{
    color: #222;
}

.rma-empty{
    padding: 24px 12px;
    color: #888;
    border-bottom: 1px solid #ececec;
}

/* status: whole cell colored, like Weeks / Last Updated on the Start Date page */
.rma-row .rma-status{
    align-self: stretch;
    display: flex;
    align-items: center;
    margin: 4px;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid;
}

/* the status pill is the dropdown: no box of its own, the pill's color, a small arrow on the right */
.rma-status-select{
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-width: 0;
    padding: 0 14px 0 0;
    border: none;
    outline: none;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right center;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.rma-status:focus-within{
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

/* Requested = yellow, In Office = blue, Sent Back = green (done) */
.rma-status.requested{ background: #fffde7; color: #7a5d00; border-color: #f0dd8a; }
.rma-status.in_office{ background: #eef3fb; color: #2f5a8f; border-color: #bfd2ee; }
.rma-status.returned { background: #e8f5e9; color: #2e6b33; border-color: #b7dcba; }

/* tap a row → it gets a dark border, and notes / who asked / status / buttons open under it */
.rows-container .rma-row.open,
.rows-container .rma-row.open:nth-child(even),
.rows-container .rma-row.open:hover{
    position: relative;
    z-index: 1;
    margin: 6px 0;
    background: #fff;
    border-bottom-color: transparent;
    border-radius: 8px;
    /* inside the row, so the scroll area can't cut off its edges */
    box-shadow: inset 0 0 0 2px #222;
}

.rma-row .rma-details{
    grid-column: 1 / -1;
    padding: 14px 12px;
    border-top: 1px solid #e6e6e6;
    cursor: default;
}

.rma-row .rma-details[hidden]{
    display: none;
}

/* Requested by (short) | Notes (the rest) | buttons */
.rma-detail-text{
    display: grid;
    grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px 40px;
    word-break: break-word;
}

/* Part in the dropdown: phone / tablet only (a computer has the Part column) */
.rma-detail-part{
    display: none;
}

.rma-detail-label{
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 4px;
}

.rma-notes{
    white-space: pre-wrap; /* keep the line breaks typed in the notes */
    color: #222;
}

.rma-none{
    color: #aaa;
}

/* buttons: the same pills as the filter buttons */
.rma-actions button{
    height: 32px;
    padding: 0 14px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    font-family: inherit;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.rma-actions button:disabled{
    color: #aaa;
    cursor: default;
}

.rma-actions button:not(:disabled):hover{
    background: #fff;
    border-color: #000;
    color: #000;
    outline: none;
}

.rma-actions{
    align-self: end;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 420px;
}

.rma-actions .rma-delete{
    color: #c0392b;
}

.rma-actions .rma-delete:not(:disabled):hover{
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

/* #endregion */

/* #region form — same black popup as "Create New Job" */
.rmaForm{
    position: relative;
    width: 400px;
    background: #111;
    border-radius: 12px;
    padding: 24px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    max-height: 90vh;
    scrollbar-width: none;
}

.rmaForm::-webkit-scrollbar{ display: none; }

.rmaForm h2{
    color: #F5A800;
    font-size: 28px;
    padding: 3%;
    font-weight: 700;
    margin: 0 0 4px;
    text-align: center;
}

.rmaForm p{
    color: #bbb;
    font-size: 12px;
    margin: 0 0 16px;
    text-align: center;
}

.rmaForm .input-group{
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.rmaForm .input-group label{
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #e6e6e6;
    white-space: nowrap;
}

.rmaForm input,
.rmaForm textarea,
.rmaForm select{
    width: 100%;
    padding: 12px 14px;
    background: #1a1a1a;
    border: 1px solid #8a8a8a;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.rmaForm textarea{
    resize: vertical;
}

.rmaForm input::placeholder,
.rmaForm textarea::placeholder{ color: #999; }

.rmaForm input:focus,
.rmaForm textarea:focus,
.rmaForm select:focus{ border-color: #F5A800; }

/* Site Manager dropdown: same dark box as the others, with an arrow */
.rmaForm select{
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background: #1a1a1a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center;
    cursor: pointer;
}

.rmaForm select:invalid,
.rmaForm select option[value=""]{ color: #999; }

.rmaForm input[type="file"]{
    padding: 9px 14px;
    color: #ddd;
    font-size: 12px;
}

.rmaForm input[type="file"]::file-selector-button{
    margin-right: 10px;
    padding: 4px 10px;
    border: 1px solid #F5A800;
    border-radius: 4px;
    background: none;
    color: #F5A800;
    font: inherit;
    cursor: pointer;
}

.rmaForm button[type="submit"]{
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: #F5A800;
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.rmaForm button[type="submit"]:hover{ background: #e09900; }

.rmaForm .form-close{ color: #ddd; }

.rmaForm .picture-hint{
    color: #bbb;
    font-size: 11px;
}

/* status popup: only the In Office or the Sent Back fields show */
.proofForm .proof-office,
.proofForm .proof-sent{
    width: 100%;
}

.proofForm .proof-print{
    width: 100%;
    padding: 10px;
    margin: 2px 0 14px;
    background: none;
    border: 1px solid #F5A800;
    border-radius: 6px;
    color: #F5A800;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.proofForm .proof-print:hover{
    background: #F5A800;
    color: #000;
}
/* #endregion */

/* #region details: who moved it and when */
.rma-history{
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rma-history small{
    display: block;
    color: #888;
    font-size: 12px;
}

.rma-tracking{
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
/* #endregion */

/* #region phone + tablet */
@media (max-width: 1024px) {
    .rma-page .pBottom{
        padding: 16px;
        padding-top: 8px;
        padding-bottom: 76px;
    }

    /* job (with part · vendor under it), status, date */
    .row-head, .rma-row{
        grid-template-columns: minmax(0, 1fr) 88px 56px;
        font-size: 13px;
    }

    .row-head > div:nth-child(1),
    .row-head > div:nth-child(3),
    .row-head > div:nth-child(4),
    .rma-row .rma-num,
    .rma-row .rma-part,
    .rma-row .rma-vendor{
        display: none;
    }

    .rma-sub{
        display: block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .row-head > div, .rma-row > div{
        padding: 8px 6px;
    }

    /* no column headings on a phone / tablet (like the Mechanics page) */
    .row-head{
        display: none;
    }

    .rma-row .rma-date{
        white-space: nowrap;
    }

    .rma-row .rma-details{
        padding: 12px 10px;
    }

    /* phone: Part, Requested by, Notes, then the buttons across the bottom */
    .rma-detail-text{
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .rma-detail-part{
        display: block;
    }

    .rma-actions{
        max-width: none;
    }

    /* two or three buttons a line */
    .rma-actions button{
        flex: 1 1 30%;
        padding: 0 8px;
    }

    .rma-row .rma-status{
        align-self: center;
        height: 26px;
        margin: 0 2px;
        padding: 0 6px;
        border-radius: 999px;
        font-size: 11px;
        white-space: nowrap;
        justify-content: center;
    }

    /* "Request RMA" sits at the bottom like "Create New Job" */
    .rma-new{
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        border-radius: 0;
        border-width: 1px 0 0;
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        background: #fff;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        z-index: 500;
    }

    /* nothing may make the page wider than the phone (it slid sideways and cut both edges off) */
    .rma-page .pannel,
    .rma-page .scroll-area{
        overflow-x: hidden;
    }

    /* header — row 1: logo | icons, row 2: search, row 3: the three filter buttons, equal width */
    .rma-page .pTop{
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 12px;
        row-gap: 0;
        padding: 12px 16px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .rma-page .pTop::before{
        content: '';
        order: 2;
        flex-basis: 100%;
        height: 0;
    }

    .rma-page .pTop > a{ order: 1; }

    .rma-page .pTop .ections{
        order: 1;
        margin-left: auto;
    }

    .rma-page .search{
        order: 3;
        flex: 1 1 100%;
        width: auto;
        min-width: 0;
        margin-top: 12px;
        padding: 5px 10px;
        gap: 6px;
    }

    .rma-page .search-icon{
        width: 14px;
        height: 14px;
    }

    .rma-page .search input{
        min-width: 0;
        width: 100%;
        font-size: 13px;
    }

    .rma-page .pTop .filters{
        order: 4;
        flex: 1 1 100%;
        min-width: 0;
        margin-top: 10px;
        gap: 6px;
        overflow: visible;
    }

    .rma-page .filter-btn{
        flex: 1;
        min-width: 0;
        padding: 6px 4px;
        font-size: 12px;
    }

    .rmaForm{
        width: 90%;
        padding: 20px;
    }

    /* 16px stops iPhone zooming into the field */
    .rmaForm input,
    .rmaForm textarea,
    .rmaForm select{
        font-size: 16px;
    }
}
/* #endregion */
