/* =========================================================
   MEMBER RELATIONS
   ========================================================= */

.member-relations-page {
    width: 100%;
    max-width: 1250px;
    margin: 0 auto;
}


/* =========================================================
   PAGE HEADER
   ========================================================= */

.relations-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 22px;
}

.relations-page-header h1 {
    margin: 0;

    color: var(--primary-dark);

    font-family: "Merriweather", serif;

    font-size: 1.8rem;
}

.relations-page-header h1 i {
    margin-right: 8px;

    color: var(--accent);
}

.relations-page-header p {
    margin: 6px 0 0;

    color: var(--muted);

    font-size: .88rem;
}

.relations-back-btn {
    display: inline-flex;
    align-items: center;

    gap: 7px;

    padding: 9px 15px;

    background: var(--primary);

    color: #ffffff;

    border-radius: 7px;

    text-decoration: none;

    font-size: .82rem;
    font-weight: 600;
}

.relations-back-btn:hover {
    background: var(--primary-dark);

    color: #ffffff;
}


/* =========================================================
   ADD RELATION CARD
   ========================================================= */

.relation-add-card {
    padding: 24px 26px;

    background: #ffffff;

    border: 1px solid var(--border);

    border-radius: 14px;

    box-shadow: var(--shadow);

    margin-bottom: 20px;
}

.relation-card-header {
    display: flex;
    align-items: center;

    gap: 13px;

    margin-bottom: 22px;
}

.relation-header-icon {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 42px;

    border-radius: 10px;

    background:
        linear-gradient(
            135deg,
            #d97706,
            #9a3412
        );

    color: #ffffff;
}

.relation-card-header h2 {
    margin: 0;

    color: var(--primary-dark);

    font-size: 1.08rem;
}

.relation-card-header p {
    margin: 3px 0 0;

    color: var(--muted);

    font-size: .78rem;
}


/* =========================================================
   FORM
   ========================================================= */

.relation-form-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 2fr)
        minmax(190px, 1fr)
        auto;

    gap: 14px;

    align-items: end;
}

.relation-form-field {
    position: relative;
}

.relation-form-field label {
    display: block;

    margin-bottom: 7px;

    color: var(--text);

    font-size: .78rem;

    font-weight: 600;
}

.relation-form-field label span {
    color: #b42318;
}

.relation-form-field select,
.member-search-box input {
    width: 100%;

    min-height: 42px;

    padding: 9px 12px;

    box-sizing: border-box;

    background: #fffdf9;

    border: 1px solid #decdb8;

    border-radius: 7px;

    color: var(--text);

    font-family: inherit;

    font-size: .82rem;

    outline: none;
}

.member-search-box {
    position: relative;
}

.member-search-box i {
    position: absolute;

    left: 12px;
    top: 50%;

    transform: translateY(-50%);

    color: var(--muted);

    font-size: .78rem;

    pointer-events: none;
}

.member-search-box input {
    padding-left: 34px;
}

.relation-form-field select:focus,
.member-search-box input:focus {
    border-color: var(--accent);

    box-shadow:
        0 0 0 3px rgba(217,119,6,.10);
}


/* =========================================================
   SEARCH RESULTS
   ========================================================= */

.member-search-results {
    position: absolute;

    left: 0;
    right: 0;

    top: calc(100% + 4px);

    z-index: 100;

    display: none;

    max-height: 260px;

    overflow-y: auto;

    background: #ffffff;

    border: 1px solid #decdb8;

    border-radius: 8px;

    box-shadow:
        0 8px 22px rgba(79,49,23,.15);
}

.member-search-result {
    display: flex;
    align-items: center;

    gap: 10px;

    width: 100%;

    padding: 10px 12px;

    box-sizing: border-box;

    background: #ffffff;

    border: 0;

    border-bottom: 1px solid #f0e7dc;

    text-align: left;

    cursor: pointer;
}

.member-search-result:last-child {
    border-bottom: 0;
}

.member-search-result:hover {
    background: #fff6e9;
}

.search-result-icon {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 34px;

    border-radius: 50%;

    background: #fff1df;

    color: var(--accent);

    font-size: .75rem;
}

.search-result-info {
    min-width: 0;
}

.search-result-name {
    display: block;

    color: var(--primary-dark);

    font-size: .8rem;
    font-weight: 700;
}

.search-result-details {
    display: block;

    margin-top: 2px;

    color: var(--muted);

    font-size: .7rem;

    white-space: normal;
}


/* =========================================================
   SELECTED MEMBER
   ========================================================= */

.selected-member {
    display: flex;
    align-items: center;

    gap: 9px;

    margin-top: 7px;

    padding: 7px 9px;

    background: #fff7e9;

    border: 1px solid #efd7b7;

    border-radius: 7px;
}

.selected-member-icon {
    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 30px;

    border-radius: 50%;

    background: var(--accent);

    color: #ffffff;

    font-size: .68rem;
}

.selected-member-info {
    flex: 1;

    min-width: 0;
}

.selected-member-info strong {
    display: block;

    color: var(--primary-dark);

    font-size: .76rem;
}

.selected-member-info span {
    display: block;

    margin-top: 2px;

    color: var(--muted);

    font-size: .68rem;
}

.clear-member-btn {
    width: 28px;
    height: 28px;

    border: 0;

    border-radius: 50%;

    background: transparent;

    color: var(--muted);

    cursor: pointer;
}

.clear-member-btn:hover {
    background: #f2dfca;

    color: #a32d1d;
}


/* =========================================================
   ADD BUTTON
   ========================================================= */

.add-relation-btn {
    min-height: 42px;

    padding: 9px 17px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    border: 0;

    border-radius: 7px;

    background: var(--primary);

    color: #ffffff;

    font-family: inherit;

    font-size: .82rem;

    font-weight: 600;

    cursor: pointer;

    white-space: nowrap;
}

.add-relation-btn:hover {
    background: var(--primary-dark);
}


/* =========================================================
   RELATIONS LIST
   ========================================================= */

.relations-list-card {
    background: #ffffff;

    border: 1px solid var(--border);

    border-radius: 14px;

    box-shadow: var(--shadow);

    overflow: hidden;
}

.relations-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 20px 24px;

    border-bottom: 1px solid #eee4d8;

    background: #fffdf9;
}

.relations-list-header h2 {
    margin: 0;

    color: var(--primary-dark);

    font-family: "Merriweather", serif;

    font-size: 1.1rem;
}

.relations-list-header h2 i {
    margin-right: 6px;

    color: var(--accent);
}

.relations-list-header p {
    margin: 4px 0 0;

    color: var(--muted);

    font-size: .76rem;
}

.relation-count {
    min-width: 32px;
    height: 32px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 8px;

    box-sizing: border-box;

    border-radius: 16px;

    background: #fff1df;

    color: var(--primary-dark);

    font-size: .78rem;

    font-weight: 700;
}


/* =========================================================
   TABLE
   ========================================================= */

.relations-table-wrapper {
    width: 100%;

    overflow-x: auto;
}

.relations-table {
    width: 100%;

    border-collapse: collapse;

    font-size: .8rem;
}

.relations-table th {
    padding: 11px 18px;

    background: #fff7ec;

    border-bottom: 1px solid #ead9c5;

    color: var(--muted);

    text-align: left;

    font-size: .72rem;

    font-weight: 700;

    white-space: nowrap;
}

.relations-table td {
    padding: 13px 18px;

    border-bottom: 1px solid #f0e7dc;

    vertical-align: middle;
}

.relations-table tbody tr:hover {
    background: #fffdf9;
}

.relations-table tbody tr:last-child td {
    border-bottom: 0;
}


/* =========================================================
   MEMBER CELL
   ========================================================= */

.relation-member-cell {
    display: flex;
    align-items: center;

    gap: 10px;
}

.relation-member-avatar {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 38px;

    border-radius: 50%;

    background:
        linear-gradient(
            135deg,
            #fff0d9,
            #f5d5ae
        );

    color: var(--accent);

    font-size: .8rem;
}

.relation-member-cell strong {
    display: block;

    color: var(--primary-dark);

    font-size: .8rem;
}

.relation-member-cell span {
    display: block;

    margin-top: 2px;

    color: var(--muted);

    font-size: .68rem;
}


/* =========================================================
   RELATION BADGE
   ========================================================= */

.relation-badge {
    display: inline-flex;

    padding: 5px 10px;

    background: #fff3df;

    border: 1px solid #efd8b8;

    border-radius: 14px;

    color: var(--primary-dark);

    font-size: .72rem;

    font-weight: 600;
}

.relation-member-id {
    color: var(--muted);

    font-size: .76rem;

    font-family: monospace;
}


/* =========================================================
   DELETE
   ========================================================= */

.delete-relation-form {
    margin: 0;
}

.delete-relation-btn {
    width: 32px;
    height: 32px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid #ead1ca;

    border-radius: 7px;

    background: #fff8f6;

    color: #a33a2b;

    cursor: pointer;
}

.delete-relation-btn:hover {
    background: #fbe9e5;

    border-color: #dca99e;
}


/* =========================================================
   NO RELATIONS
   ========================================================= */

.no-relations {
    padding: 55px 20px;

    text-align: center;
}

.no-relations-icon {
    width: 62px;
    height: 62px;

    margin: 0 auto 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #fff1df;

    color: var(--accent);

    font-size: 1.4rem;
}

.no-relations h3 {
    margin: 0;

    color: var(--primary-dark);

    font-size: 1rem;
}

.no-relations p {
    max-width: 430px;

    margin: 6px auto 0;

    color: var(--muted);

    font-size: .78rem;

    line-height: 1.5;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

    .relation-form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .relation-form-action {
        grid-column: 1 / -1;
    }

    .add-relation-btn {
        width: 100%;
    }

}


@media (max-width: 600px) {

    .relations-page-header {
        align-items: flex-start;

        flex-direction: column;
    }

    .relation-add-card {
        padding: 20px;
    }

    .relation-form-grid {
        grid-template-columns: 1fr;
    }

    .relation-form-action {
        grid-column: auto;
    }

    .relations-list-header {
        padding: 17px;
    }

    .relations-table th,
    .relations-table td {
        padding: 10px 12px;
    }

}
