/* =========================================================
   MODAL
========================================================= */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: auto;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #1e293b;
    color: #f8fafc;
    margin: 4% auto;
    padding: 24px;
    width: min(1100px, 92%);
    border: 1px solid #334155;
    border-radius: 10px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 30px;
    cursor: pointer;
    flex: none !important;
}

.close-btn:hover {
    color: white;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #334155;
    padding-top: 20px;
    margin-top: 28px;
}

/* =========================================================
   SECTION HEADINGS
========================================================= */

.modal-section-title {
    margin: 0 0 18px;
    font-size: 1rem;
    font-weight: 600;
    color: #f8fafc;
}

/* =========================================================
   SHARED INPUTS
========================================================= */

.modal-input,
.modal-table input[type="text"],
.modal-table input[type="number"],
.add-substance-grid input {

    width: 100%;
    box-sizing: border-box;

    padding: 9px 12px;

    background: #0f172a;
    color: white;

    border: 1px solid #475569;
    border-radius: 6px;

    transition: border-color .2s ease,
                box-shadow .2s ease;
}

.modal-input:focus,
.modal-table input:focus,
.add-substance-grid input:focus {

    outline: none;

    border-color: #3b82f6;

    box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

/* =========================================================
   EXISTING SUBSTANCES TABLE
========================================================= */

.modal-table {
    display: flex;
    flex-direction: column;
}

.modal-table-header,
.modal-table-row {

    display: grid;

    grid-template-columns:
        90px
        170px
        60px
        130px
        1fr
        110px;

    gap: 18px;
    align-items: center;
}

.modal-table-header {

    padding-bottom: 12px;
    margin-bottom: 6px;

    border-bottom: 2px solid #334155;

    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;

    color: #94a3b8;
}

.modal-table-row {
    padding: 16px 0;
}

.modal-table-row:last-child {
    border-bottom: none;
}

.substance-name {

    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.checkbox-cell {

    display: flex;
    justify-content: center;
    align-items: center;
}

.checkbox-cell input {

    width: 18px;
    height: 18px;

    cursor: pointer;
}

.delete-substance-btn {
    justify-self: end;
    width: 100%;
    white-space: nowrap;
}

/* =========================================================
   ADD SUBSTANCE
========================================================= */

.add-substance-grid {

    display: grid;

    grid-template-columns:
        140px
        170px
        150px
        auto;

    gap: 16px;
    align-items: end;
}

.add-substance-grid label {

    display: block;

    margin-bottom: 6px;

    font-size: .82rem;
    font-weight: 500;

    color: #94a3b8;
}

.add-substance-grid button {

    height: 41px;
    white-space: nowrap;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 900px) {

    .modal-content {
        width: 95%;
        margin: 20px auto;
    }

    .modal-table-header {
        display: none;
    }

    .modal-table-row {

        grid-template-columns: 1fr;
        gap: 12px;

        padding: 18px 0;
    }

    .delete-substance-btn {
        justify-self: stretch;
    }

    .checkbox-cell {
        justify-content: flex-start;
    }

    .modal-table-row .checkbox-cell {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .add-substance-grid {
        grid-template-columns: 1fr;
    }

    .add-substance-grid button {
        width: 100%;
    }
}