/**
 * RM Quiz Builder - Matching question type (drag item -> category)
 */

/* Token bank: unplaced items */
.rmqb-matching-bank {
    list-style: none;
    margin: 0 0 18px 0;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 56px;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
}

/* Item token */
.rmqb-matching-item {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    border: 1px solid #d1d5db;
    border-radius: 20px;
    cursor: grab;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    user-select: none;
}
.rmqb-matching-item-has-image { padding: 6px; }
.rmqb-matching-item-image { max-width: 90px; max-height: 90px; object-fit: contain; display: block; border-radius: 4px; }
.rmqb-matching-mobile-label .rmqb-matching-item-image { max-width: 60px; max-height: 60px; }
.rmqb-matching-item:hover { border-color: #9ca3af; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); }
.rmqb-matching-item:active { cursor: grabbing; }
.rmqb-matching-item:focus { outline: 2px solid #3b82f6; outline-offset: 2px; }
.rmqb-matching-item.dragging { opacity: 0.4; }
.rmqb-matching-item.touch-dragging { opacity: 1; }
.rmqb-matching-item.keyboard-grabbed { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3); }
.rmqb-matching-item.correct { border-color: #22c55e; background: #f0fdf4; }
.rmqb-matching-item.incorrect { border-color: #ef4444; background: #fef2f2; }

/* Zones grid */
.rmqb-matching-zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

/* A single category drop-zone */
.rmqb-matching-dropzone {
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.rmqb-matching-dropzone.drag-over { border-color: #3b82f6; background: #eff6ff; }
.rmqb-matching-bank.drag-over { border-color: #3b82f6; background: #eff6ff; }

.rmqb-matching-zone-heading {
    padding: 10px 14px;
    font-weight: 700;
    color: #1f2937;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-bottom: 1px solid #e5e7eb;
}

.rmqb-matching-zone-items {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 64px;
}
.rmqb-matching-zone-items .rmqb-matching-item {
    border-radius: 8px;
    width: 100%;
    justify-content: flex-start;
}

@media (max-width: 600px) {
    .rmqb-matching-zones { grid-template-columns: 1fr; }
}

/* Mobile dropdown fallback: hidden on desktop, shown at <=640px */
.rmqb-matching-mobile { display: none; }
.rmqb-matching-mobile-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid #eef2f7;
}
.rmqb-matching-mobile-label { font-weight: 600; color: #374151; }

@media (max-width: 640px) {
    /* On phones, swap drag-and-drop for a dropdown per item */
    .rmqb-matching-bank,
    .rmqb-matching-zones { display: none; }
    .rmqb-matching-mobile { display: block; }
    .rmqb-matching-item-select {
        width: 100%;
        padding: 10px;
        border: 2px solid #cbd5e1;
        border-radius: 6px;
        font-size: 16px; /* >=16px avoids iOS zoom-on-focus */
        background: #ffffff;
        color: #374151;
        box-sizing: border-box;
    }
    .rmqb-matching-item-select:focus {
        outline: none;
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    }
    .rmqb-matching-item-select:disabled { background: #f3f4f6; color: #9ca3af; }
}
