/* mage-picker-plus.css — MagePickerPlus inline dropdown selection with add/search */

/* =============================================
   MagePickerPlus - Inline Dropdown
   ============================================= */

/* Wrapper: positioning context for trigger + dropdown */
.mpp-wrap {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Dropdown panel: appears below trigger */
.mpp-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: auto;
    min-width: 100%;
    /* Nie breiter als der Viewport, mit kleinem Sicherheitsabstand */
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    z-index: 10001;
    background: #fff;
    border: 1px solid #dde4ed;
    border-radius: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    margin-top: 2px;
    max-height: 320px;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}
.mpp-dropdown.open { display: flex; }

/* Flip: dropdown opens upward when near bottom */
.mpp-dropdown.mpp-flip {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 2px;
}

/* Add row (new value input + button) */
.mpp-add-row {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #e3e3e3;
    flex-shrink: 0;
}
.mpp-add-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #dde4ed;
    border-radius: 2px;
    font-size: 13px;
    color: #333;
    outline: none;
}
.mpp-add-input:focus { border-color: #007bdb; }
.mpp-add-input::placeholder { color: #aaa; font-style: italic; }
.mpp-add-btn {
    background: var(--o);
    border: none;
    color: #fff;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 2px;
    white-space: nowrap;
}
.mpp-add-btn:hover { background: var(--o-h); }

/* Search input */
.mpp-search {
    padding: 8px 10px;
    border-bottom: 1px solid #e3e3e3;
    flex-shrink: 0;
}
.mpp-search input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #dde4ed;
    border-radius: 2px;
    font-size: 13px;
    color: #333;
    outline: none;
    box-sizing: border-box;
}
.mpp-search input:focus { border-color: #007bdb; }
.mpp-search input::placeholder { color: #aaa; font-style: italic; }

/* Scrollable body */
.mpp-body {
    flex: 1;
    overflow-y: auto;
    min-height: 60px;
}

/* Table list */
.mpp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.mpp-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #303030;
}
.mpp-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}
.mpp-table tbody tr:hover { background: #e5f3ff !important; }
.mpp-table tbody tr.mpp-selected { background: #d0e8ff !important; }

.mpp-value-cell { flex: 1; }

/* Subtitle column (optional second cell) */
.mpp-table tbody td.mpp-subtitle {
    color: #888;
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inline badge (colored label next to label text) */
.mpp-inline-badge {
    display: inline-block; font-size: 10px; font-weight: 600;
    padding: 1px 7px; border-radius: 2px; line-height: 1.6;
    color: #fff; margin-left: 8px; vertical-align: middle;
}

/* Stacked layout: subtitle below label in same cell */
.mpp-subtitle-stacked {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
    line-height: 1.3;
}
.mpp-subtitle-stacked .badge-type { margin-right: 4px; }
.mpp-script-desc {
    font-size: 11px; color: #999; line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.mpp-script-badges { display: flex; flex-wrap: wrap; gap: 4px; }

/* Empty state */
.mpp-empty {
    padding: 20px 14px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* Footer with count */
.mpp-footer {
    padding: 6px 10px;
    border-top: 1px solid #e3e3e3;
    font-size: 12px;
    color: #888;
    text-align: right;
    flex-shrink: 0;
}

/* MagePickerPlus Trigger (in modals/forms)
   Border, border-radius, padding, font-size, color, background → forms.css (global)
*/
.mpp-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
    user-select: none;
}
/* hover → forms.css (global) */
.mpp-trigger .mpp-trigger-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mpp-trigger .mpp-trigger-arrow {
    font-size: 10px;
    color: #666;
    flex-shrink: 0;
}

/* =============================================
   Contact Mode — Rich contact rows in dropdown
   ============================================= */

/* Contact mode: ensure enough room for avatar + name + role */
.mpp-dropdown.mpp-contact-mode { min-width: 380px; }

/* Avatar column */
.mpp-contact-avatar { width: 40px; padding: 6px 4px 6px 10px; vertical-align: middle; }
.mpp-contact-avatar img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: block; }
.mpp-contact-initials {
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: #fff;
}

/* Name + Labels column */
.mpp-contact-info { padding: 6px 8px; vertical-align: middle; }
.mpp-contact-name { font-size: 13px; color: #303030; font-weight: 600; }
.mpp-contact-labels { display: flex; align-items: center; gap: 4px; margin-top: 2px; flex-wrap: wrap; }
.mpp-contact-labels + .mpp-contact-labels { margin-top: 1px; }
.mpp-contact-address { font-size: 11px; color: #888; margin-top: 1px; }

/* Parent org badge */
.mpp-parent-badge {
    font-size: 10px; padding: 1px 7px; border-radius: 2px; font-weight: 600;
    background: #e5e7eb; color: #4b5563; line-height: 1.6; white-space: nowrap;
}

/* Role column */
.mpp-contact-role {
    font-size: 12px; color: #666; white-space: nowrap;
    padding: 6px 8px; vertical-align: middle;
}

/* Type badge */
.mpp-type-badge { font-size: 10px; padding: 2px 8px; border-radius: 2px; font-weight: 600; }

/* Type badge colors: applied via inline style from window.__lookupColors (same as kontakte table) */

/* =============================================
   Project Mode — Project rows in dropdown
   ============================================= */

.mpp-dropdown.mpp-project-mode { min-width: 380px; }

/* Owner + Name stacked cell */
.mpp-project-info { padding: 6px 8px; vertical-align: middle; }
.mpp-project-owner { font-size: 11px; color: #888; margin-bottom: 1px; }
.mpp-project-name { font-size: 13px; color: #303030; font-weight: 500; }

/* Labels cell (type + status badges) */
.mpp-project-labels { padding: 6px 10px 6px 4px; vertical-align: middle; white-space: nowrap; text-align: right; }
.mpp-prj-badge { font-size: 10px; padding: 2px 8px; border-radius: 2px; font-weight: 600; background: #f3f4f6; color: #374151; display: inline-block; }
.mpp-prj-badge + .mpp-prj-badge { margin-left: 4px; }

/* =============================================
   Monitoring Mode — Monitoring rows in dropdown
   ============================================= */

.mpp-dropdown.mpp-monitoring-mode { min-width: 380px; }

/* Name + Description column */
.mpp-mon-info { padding: 6px 10px; vertical-align: middle; }
.mpp-mon-name { font-size: 13px; color: #303030; font-weight: 500; }
.mpp-mon-desc { font-size: 11px; color: #888; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }

/* Type label column (right-aligned) */
.mpp-mon-type { padding: 6px 10px 6px 4px; vertical-align: middle; white-space: nowrap; text-align: right; }
.mpp-mon-badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.mpp-mon-badge-single { background: #e8f0fe; color: #1a73e8; }
.mpp-mon-badge-group { background: #fef7e0; color: #e37400; }
