﻿/* ============================================================
   MappingDefinitionManager.css
   Theme: XManagementPro — matches existing blue/slate UI.
   All classes prefixed .mdm- to avoid collision.
   ============================================================ */

/* ── Root shell ────────────────────────────────────────────── */
.mdm-root {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: 500px;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 13px;
    color: #1e2a45;
    background: #f0f2f8;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #d4daea;
    box-shadow: 0 4px 16px rgba(30,42,69,0.10);
}

    .mdm-root * {
        box-sizing: border-box;
    }

/* ── Left panel — definition list ─────────────────────────── */
.mdm-list-panel {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid #d4daea;
    overflow: hidden;
    max-height: 65vh;
}

.mdm-list-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px 9px;
    background: linear-gradient(135deg, #2c3e72 0%, #3a5298 100%);
    flex-shrink: 0;
}

.mdm-list-title {
    flex: 1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.78);
    white-space: nowrap;
    overflow: hidden;
}

.mdm-list-count {
    font-size: 10px;
    font-weight: 600;
    background: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.9);
    border-radius: 10px;
    padding: 1px 7px;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.mdm-list-search {
    padding: 7px 8px;
    background: #f6f8fc;
    border-bottom: 1px solid #d4daea;
    flex-shrink: 0;
}

.mdm-search-input {
    width: 100%;
    height: 27px;
    padding: 0 8px;
    background: #ffffff;
    border: 1px solid #d4daea;
    border-radius: 5px;
    color: #1e2a45;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .mdm-search-input::placeholder {
        color: #a0aabf;
    }

    .mdm-search-input:focus {
        border-color: #5b8dee;
        box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
    }

.mdm-list-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 6px 12px;
}

    .mdm-list-body::-webkit-scrollbar {
        width: 4px;
    }

    .mdm-list-body::-webkit-scrollbar-track {
        background: #f0f2f8;
    }

    .mdm-list-body::-webkit-scrollbar-thumb {
        background: #bcc5d9;
        border-radius: 2px;
    }

        .mdm-list-body::-webkit-scrollbar-thumb:hover {
            background: #8898bb;
        }

.mdm-list-empty {
    padding: 20px 10px;
    font-size: 11px;
    color: #a0aabf;
    text-align: center;
}

/* ── Definition card ───────────────────────────────────────── */
.mdm-def-card {
    padding: 8px 9px 6px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 3px;
    transition: background 0.13s, border-color 0.13s;
}

    .mdm-def-card:hover {
        background: #f6f8fc;
        border-color: #d4daea;
    }

.mdm-def-card--active {
    background: #e8f0fd;
    border-color: #5b8dee;
}

.mdm-def-card-top {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}

.mdm-def-name {
    font-size: 12px;
    font-weight: 600;
    color: #1e2a45;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mdm-def-card--active .mdm-def-name {
    color: #3a6fd8;
}

.mdm-def-domain {
    font-size: 10px;
    font-weight: 600;
    color: #5b8dee;
    background: #e8f0fd;
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.mdm-def-expr {
    font-size: 10px;
    color: #6b7a99;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

/* Action row — visible on hover / active */
.mdm-def-actions {
    display: flex;
    gap: 4px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.18s ease, opacity 0.18s ease;
}

.mdm-def-card:hover .mdm-def-actions,
.mdm-def-card--active .mdm-def-actions {
    max-height: 30px;
    opacity: 1;
}

.mdm-act-btn {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.12s;
}

.mdm-act-edit {
    background: #e8f0fd;
    border-color: #c5d8fb;
    color: #3a6fd8;
}

.mdm-act-delete {
    background: #fdeef0;
    border-color: #f5b8be;
    color: #c0404e;
}

.mdm-act-edit:hover {
    background: #d5e5fc;
}

.mdm-act-delete:hover {
    background: #fbd9dd;
}

/* ── Right panel — builder ─────────────────────────────────── */
.mdm-builder-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

.mdm-builder-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 9px;
    background: linear-gradient(135deg, #2c3e72 0%, #3a5298 100%);
    flex-shrink: 0;
}

.mdm-builder-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.78);
}

.mdm-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 10px;
    margin-left: auto;
}

.mdm-status--ok {
    background: rgba(39,176,139,0.25);
    color: #7effd6;
}

.mdm-status--error {
    background: rgba(224,92,106,0.30);
    color: #ffb3ba;
}

.mdm-builder-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
}

    .mdm-builder-body::-webkit-scrollbar {
        width: 4px;
    }

    .mdm-builder-body::-webkit-scrollbar-track {
        background: #f0f2f8;
    }

    .mdm-builder-body::-webkit-scrollbar-thumb {
        background: #bcc5d9;
        border-radius: 2px;
    }

.mdm-builder-footer {
    display: flex;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid #edf0f7;
    margin-top: 4px;
}

/* ── Form controls ─────────────────────────────────────────── */
.mdm-field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mdm-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7a99;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 5px;
}

.mdm-required {
    color: #e05c6a;
}

.mdm-hint {
    font-size: 10px;
    font-weight: 400;
    color: #a0aabf;
    text-transform: none;
    letter-spacing: 0;
}

.mdm-input,
.mdm-select,
.mdm-textarea {
    background: #ffffff;
    border: 1px solid #d4daea;
    border-radius: 5px;
    color: #1e2a45;
    font-family: inherit;
    font-size: 13px;
    padding: 6px 9px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    width: 100%;
}

    .mdm-input:focus,
    .mdm-select:focus,
    .mdm-textarea:focus {
        border-color: #5b8dee;
        box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
    }

.mdm-input-sm {
    height: 28px;
    font-size: 12px;
    padding: 4px 8px;
}

.mdm-textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

/* ── Toggle group ──────────────────────────────────────────── */
.mdm-toggle-group {
    display: flex;
    gap: 0;
    border: 1px solid #d4daea;
    border-radius: 5px;
    overflow: hidden;
    width: fit-content;
}

.mdm-toggle {
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    background: #f6f8fc;
    color: #6b7a99;
    border: none;
    border-right: 1px solid #d4daea;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
}

    .mdm-toggle:last-child {
        border-right: none;
    }

.mdm-toggle--on {
    background: #5b8dee;
    color: #ffffff;
    font-weight: 600;
}

.mdm-toggle:hover:not(.mdm-toggle--on) {
    background: #edf0f7;
    color: #1e2a45;
}

/* ── Checkbox rows ─────────────────────────────────────────── */
.mdm-check-row-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mdm-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: #1e2a45;
}

    .mdm-check-row input[type="checkbox"] {
        accent-color: #5b8dee;
        width: 14px;
        height: 14px;
        cursor: pointer;
        flex-shrink: 0;
    }

/* ── Action row (Add Field / Literal) ──────────────────────── */
.mdm-action-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.mdm-literal-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

/* ── Buttons ───────────────────────────────────────────────── */
.mdm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 5px;
    border: 1px solid #d4daea;
    background: #f6f8fc;
    color: #1e2a45;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.13s, border-color 0.13s, color 0.13s;
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
}

    .mdm-btn:hover:not(:disabled) {
        background: #edf0f7;
        border-color: #bcc5d9;
    }

    .mdm-btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

.mdm-btn-primary {
    background: #5b8dee;
    border-color: #5b8dee;
    color: #ffffff;
}

    .mdm-btn-primary:hover:not(:disabled) {
        background: #3a6fd8;
        border-color: #3a6fd8;
    }

.mdm-btn-danger {
    background: #fdeef0;
    border-color: #f5b8be;
    color: #c0404e;
}

    .mdm-btn-danger:hover:not(:disabled) {
        background: #fbd9dd;
        border-color: #e05c6a;
    }

.mdm-btn-icon {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 14px;
    /* override glass-button defaults from MyGlass.css */
    background: rgba(255,255,255,0.14) !important;
    border: 1px solid rgba(255,255,255,0.22) !important;
    color: rgba(255,255,255,0.8) !important;
    border-radius: 4px;
}

    .mdm-btn-icon:hover:not(:disabled) {
        background: rgba(255,255,255,0.26) !important;
        color: #ffffff !important;
    }

.mdm-btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.mdm-clear-btn {
    background: none;
    border: none;
    color: #a0aabf;
    cursor: pointer;
    font-size: 11px;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.13s;
}

    .mdm-clear-btn:hover {
        color: #e05c6a;
    }

/* ── Badge ─────────────────────────────────────────────────── */
.mdm-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    background: #e8f0fd;
    color: #3a6fd8;
    border: 1px solid #c5d8fb;
    border-radius: 4px;
    padding: 2px 8px;
}

/* ── Animate-in for conditional sections ───────────────────── */
.mdm-animate-in {
    animation: mdm-fade-slide 0.18s ease both;
}

@keyframes mdm-fade-slide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Delete confirmation overlay ───────────────────────────── */
.mdm-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30,42,69,0.42);
    backdrop-filter: blur(2px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: mdm-fade-slide 0.14s ease both;
}

.mdm-confirm-box {
    background: #ffffff;
    border: 1px solid #d4daea;
    border-radius: 8px;
    box-shadow: 0 8px 36px rgba(30,42,69,0.18);
    width: 100%;
    max-width: 400px;
    padding: 20px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: mdm-confirm-in 0.18s cubic-bezier(0.34,1.4,0.64,1) both;
}

@keyframes mdm-confirm-in {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.mdm-confirm-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e2a45;
}

.mdm-confirm-body {
    font-size: 13px;
    color: #4b5c7e;
    line-height: 1.5;
}

.mdm-confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 700px) {
    .mdm-root {
        flex-direction: column;
    }

    .mdm-list-panel {
        width: 100%;
        min-width: unset;
        height: 240px;
        border-right: none;
        border-bottom: 1px solid #d4daea;
    }
}
