/* Embedded contacts */

.d4-contacts {
    width: 100%;
}

.d4-contacts > input[type="hidden"] {
    display: none;
}

/* --- Card list (simple layout) --- */
.d4-contacts--cards .d4-contacts-list-toolbar {
    margin: 0;
    background: transparent;
}

.d4-contacts--cards .d4-contacts-list-toolbar.D4DataTable .card-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    border-top: 0 !important;
    border-bottom: 1px solid #e8edf4 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 16px 20px !important;
}

.d4-contacts--cards .d4-contacts-list-toolbar .d-flex {
    gap: 12px;
}

.d4-contacts--cards .d4-contacts-list-toolbar .table-tools-right {
    margin-left: auto;
}

.d4-contacts--cards .d4-contacts-list-toolbar .search-box {
    min-width: 240px;
}

.d4-contacts-cards-scroll {
    max-height: var(--d4-contacts-max-height, 520px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: #ffffff;
}

.d4-contacts-card-list {
    display: block;
    margin: 0;
    padding: 0;
}

.d4-contacts-card-list .d4-contact-card {
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid #e8edf4;
    background: #ffffff;
    box-shadow: none;
    padding: 14px 20px;
    margin-bottom: 0;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.d4-contacts-card-list .d4-contact-card:last-child {
    border-bottom: 0;
}

.d4-contacts-card-list .d4-contact-card:hover,
.d4-contacts-card-list .d4-contact-card:focus {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    outline: none;
}

.d4-contact-card__inner {
    display: flex;
    align-items: center;
    gap: 14px;
}

.d4-contact-card__avatar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: hsl(var(--d4-contact-avatar-hue, 210), 58%, 48%);
}

.d4-contact-card__body {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 38%;
    padding-top: 0;
}

.d4-contact-card__comment {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(46%, 360px);
    margin-left: auto;
    padding-left: 20px;
    text-align: left;
    font-size: 12px;
    line-height: 1.4;
    color: #64748b;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
}

.d4-contact-card__name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
    margin-bottom: 2px;
    word-break: break-word;
}

.d4-contact-card__meta {
    font-size: 12px;
    line-height: 1.35;
    color: #64748b;
    word-break: break-word;
}

.d4-contact-card__meta--email {
    color: #475569;
}

.d4-contacts-cards-empty {
    padding: 32px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
}

@media (max-width: 767px) {
    .d4-contact-card__inner {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .d4-contact-card__body {
        flex: 1 1 0;
        max-width: none;
    }

    .d4-contact-card__comment {
        flex: 1 1 100%;
        max-width: none;
        margin-left: 0;
        padding-left: 56px;
        padding-top: 6px;
        -webkit-line-clamp: 2;
    }
}

/* --- Simple contact modal --- */
.d4-contacts-modal-simple .d4-contact-simple-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.d4-contacts-modal-simple .d4-contact-simple-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 16px;
    margin-bottom: 8px;
}

.d4-contacts-modal-simple .d4-contact-simple-avatar {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    background: #6366f1;
}

.d4-contacts-modal-simple .d4-contact-simple-hero-fields {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.d4-contacts-modal-simple .d4-contact-simple-hero-fields .form-control,
.d4-contacts-modal-simple .d4-contact-simple-name-input.form-control,
.d4-contacts-modal-simple .d4-contact-simple-sub-input.form-control {
    width: 100% !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #f5f5f7 !important;
    box-shadow: none !important;
    color: #1f2937 !important;
}

.d4-contacts-modal-simple .d4-contact-simple-name-input.form-control {
    font-size: 16px !important;
    font-weight: 600 !important;
    padding: 10px 12px !important;
    min-height: 40px !important;
    height: auto !important;
}

.d4-contacts-modal-simple .d4-contact-simple-sub-input.form-control {
    font-size: 14px !important;
    font-weight: 400 !important;
    padding: 8px 12px !important;
    min-height: 36px !important;
    height: auto !important;
    color: #374151 !important;
}

.d4-contacts-modal-simple .d4-contact-simple-name-input.form-control:focus,
.d4-contacts-modal-simple .d4-contact-simple-sub-input.form-control:focus {
    background: #efeff2 !important;
}

.d4-contacts-modal-simple .d4-contact-simple-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.d4-contacts-modal-simple .d4-contact-simple-row:last-child {
    border-bottom: 0;
}

.d4-contacts-modal-simple .d4-contact-simple-row--desc {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 10px;
    border-bottom: 0;
}

.d4-contacts-modal-simple .d4-contact-simple-label {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 400;
    color: #9ca3af;
    white-space: nowrap;
}

.d4-contacts-modal-simple .d4-contact-simple-row--desc .d4-contact-simple-label {
    text-align: left;
}

.d4-contacts-modal-simple .d4-contact-simple-control {
    flex: 1 1 auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-width: 0;
}

.d4-contacts-modal-simple .d4-contact-simple-row--email {
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
}

.d4-contacts-modal-simple .d4-contact-simple-row--email .d4-contact-simple-label {
    flex: 0 0 auto;
    min-width: 48px;
}

.d4-contacts-modal-simple .d4-contact-simple-control--email {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: none;
    margin-left: 0;
    justify-content: stretch;
    align-self: stretch;
}

.d4-contacts-modal-simple .d4-contact-simple-control--email .form-group,
.d4-contacts-modal-simple .d4-contact-simple-control--email .form-control-wrap,
.d4-contacts-modal-simple .d4-contact-simple-control--email .input-group {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    display: block;
}

.d4-contacts-modal-simple .d4-contact-simple-control--email .input-group {
    display: flex !important;
}

.d4-contacts-modal-simple .d4-contact-simple-control--email .form-control,
.d4-contacts-modal-simple .d4-contact-simple-control--email input {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    text-align: left !important;
}

.d4-contacts-modal-simple .d4-contact-simple-control--desc {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
    justify-content: stretch;
}

.d4-contacts-modal-simple .d4-contact-simple-control--desc > *,
.d4-contacts-modal-simple .d4-contact-simple-control--desc .mb-3,
.d4-contacts-modal-simple .d4-contact-simple-control--desc [class*="col"] {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.d4-contacts-modal-simple .d4-contact-simple-row .form-control:not(textarea) {
    border: 0 !important;
    border-radius: 10px !important;
    background: #f5f5f7 !important;
    min-height: 34px !important;
    height: 34px !important;
    font-size: 14px !important;
    color: #1f2937 !important;
    box-shadow: none !important;
}

.d4-contacts-modal-simple .d4-contact-simple-row .form-control:not(textarea):focus {
    background: #efeff2 !important;
}

.d4-contacts-modal-simple .d4-contact-simple-row--desc textarea.form-control {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 12px !important;
    background: #f5f5f7 !important;
    border: 0 !important;
    min-height: 100px;
    height: 100px;
    font-size: 14px !important;
    text-align: left;
    padding: 12px 14px;
    resize: vertical;
    color: #1f2937 !important;
    box-sizing: border-box;
}

.d4-contacts-modal-simple .d4-contact-simple-row--desc textarea.form-control:focus {
    background: #efeff2 !important;
}

.d4-contacts-modal-simple .d4-contact-simple-row .form-check.form-switch {
    margin: 0;
    padding: 0;
    justify-content: flex-end;
}

/* --- Standard DataTable embed --- */
.d4-contacts .D4DataTable.card {
    width: 100%;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin-bottom: 0;
    background: transparent;
}

.d4-contacts .D4DataTable > .card-header {
    border-radius: 0 !important;
    border-bottom: 1px solid var(--bs-border-color, #e9ebec);
    background: transparent !important;
    box-shadow: none !important;
}

.d4-contacts .D4DataTable > .card-body {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.d4-contacts .D4DataTable .dataTables_wrapper,
.d4-contacts .D4DataTable .table-responsive {
    border: none !important;
    border-radius: 0 !important;
}

.d4-contacts .D4DataTable table.dataTable {
    width: 100% !important;
    margin-bottom: 0 !important;
}

.d4-contacts .D4DataTable table.dataTable thead th {
    border-bottom: 1px solid var(--bs-border-color, #e9ebec) !important;
    border-top: none !important;
}

.d4-contacts .D4DataTable table.dataTable tbody td {
    border-bottom: 1px solid var(--bs-border-color, #e9ebec) !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

.d4-contacts .D4DataTable table.dataTable tbody tr:last-child td {
    border-bottom: none !important;
}

.d4-contacts .D4DataTable .dataTables_scrollBody {
    max-height: var(--d4-contacts-max-height, 520px);
}

.d4-contacts-table-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.d4-contacts-table-row__avatar {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #6366f1;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.d4-contacts-table-row__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.d4-contacts-table-row__name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.25;
}

.d4-contacts-table-row__meta {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.35;
}
